From 135213704ee98c2c1ad0d3e5cb16bee08a02dfd0 Mon Sep 17 00:00:00 2001 From: Drew T <50529377+Druthulu@users.noreply.github.com> Date: Sun, 19 Jul 2026 13:32:36 -0600 Subject: [PATCH] =?UTF-8?q?feat(phase-29=20crack-wave3):=20func=5F8015C32C?= =?UTF-8?q?=20jtbl=20family=20bank=20+110=20members=20(=C2=A78=20jtbl=5Fca?= =?UTF-8?q?rve)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Propagated the func_8015C32C jump-table exemplar to 110 more overlays via jtbl_family_bank (carve + ld_interleave + remap, per-sibling whole-binary gated). Run halted by an uncaught exception at member 111 (ov_SC06_018); 110/119 attempted banked clean. Remaining ~19 members to follow. --- config/overlays.mk | 220 +- config/splat.ov_SC01_080.yaml | 11 +- config/splat.ov_SC01_084.yaml | 13 +- config/splat.ov_SC02_000.yaml | 13 +- config/splat.ov_SC02_003.yaml | 13 +- config/splat.ov_SC02_004.yaml | 11 +- config/splat.ov_SC02_005.yaml | 11 +- config/splat.ov_SC02_011.yaml | 11 +- config/splat.ov_SC02_015.yaml | 11 +- config/splat.ov_SC02_016.yaml | 13 +- config/splat.ov_SC02_017.yaml | 13 +- config/splat.ov_SC02_021.yaml | 13 +- config/splat.ov_SC02_026.yaml | 13 +- config/splat.ov_SC02_027.yaml | 13 +- config/splat.ov_SC02_028.yaml | 13 +- config/splat.ov_SC02_031.yaml | 11 +- config/splat.ov_SC02_035.yaml | 13 +- config/splat.ov_SC02_039.yaml | 13 +- config/splat.ov_SC02_041.yaml | 13 +- config/splat.ov_SC03_001.yaml | 11 +- config/splat.ov_SC03_002.yaml | 13 +- config/splat.ov_SC03_003.yaml | 11 +- config/splat.ov_SC03_006.yaml | 11 +- config/splat.ov_SC03_007.yaml | 11 +- config/splat.ov_SC03_010.yaml | 11 +- config/splat.ov_SC03_011.yaml | 13 +- config/splat.ov_SC03_012.yaml | 11 +- config/splat.ov_SC03_013.yaml | 11 +- config/splat.ov_SC03_014.yaml | 13 +- config/splat.ov_SC03_015.yaml | 13 +- config/splat.ov_SC03_023.yaml | 11 +- config/splat.ov_SC03_024.yaml | 13 +- config/splat.ov_SC03_028.yaml | 11 +- config/splat.ov_SC03_029.yaml | 13 +- config/splat.ov_SC03_030.yaml | 11 +- config/splat.ov_SC03_031.yaml | 13 +- config/splat.ov_SC03_089.yaml | 13 +- config/splat.ov_SC03_090.yaml | 13 +- config/splat.ov_SC03_091.yaml | 13 +- config/splat.ov_SC03_092.yaml | 11 +- config/splat.ov_SC03_093.yaml | 13 +- config/splat.ov_SC03_094.yaml | 13 +- config/splat.ov_SC03_095.yaml | 13 +- config/splat.ov_SC03_096.yaml | 13 +- config/splat.ov_SC03_097.yaml | 13 +- config/splat.ov_SC03_098.yaml | 13 +- config/splat.ov_SC03_099.yaml | 13 +- config/splat.ov_SC03_100.yaml | 13 +- config/splat.ov_SC03_101.yaml | 13 +- config/splat.ov_SC03_102.yaml | 13 +- config/splat.ov_SC03_103.yaml | 13 +- config/splat.ov_SC03_104.yaml | 13 +- config/splat.ov_SC03_105.yaml | 13 +- config/splat.ov_SC03_108.yaml | 13 +- config/splat.ov_SC03_109.yaml | 13 +- config/splat.ov_SC03_110.yaml | 13 +- config/splat.ov_SC03_111.yaml | 13 +- config/splat.ov_SC03_112.yaml | 13 +- config/splat.ov_SC03_113.yaml | 13 +- config/splat.ov_SC03_114.yaml | 13 +- config/splat.ov_SC03_115.yaml | 13 +- config/splat.ov_SC03_116.yaml | 11 +- config/splat.ov_SC03_117.yaml | 13 +- config/splat.ov_SC03_118.yaml | 13 +- config/splat.ov_SC03_119.yaml | 13 +- config/splat.ov_SC03_121.yaml | 13 +- config/splat.ov_SC03_124.yaml | 11 +- config/splat.ov_SC03_125.yaml | 13 +- config/splat.ov_SC03_126.yaml | 13 +- config/splat.ov_SC04_000.yaml | 13 +- config/splat.ov_SC04_002.yaml | 13 +- config/splat.ov_SC04_003.yaml | 13 +- config/splat.ov_SC04_004.yaml | 11 +- config/splat.ov_SC04_005.yaml | 13 +- config/splat.ov_SC04_006.yaml | 13 +- config/splat.ov_SC04_007.yaml | 13 +- config/splat.ov_SC04_008.yaml | 11 +- config/splat.ov_SC04_009.yaml | 13 +- config/splat.ov_SC04_010.yaml | 13 +- config/splat.ov_SC04_011.yaml | 13 +- config/splat.ov_SC04_012.yaml | 11 +- config/splat.ov_SC04_015.yaml | 11 +- config/splat.ov_SC04_016.yaml | 13 +- config/splat.ov_SC04_018.yaml | 11 +- config/splat.ov_SC04_019.yaml | 11 +- config/splat.ov_SC04_020.yaml | 13 +- config/splat.ov_SC04_021.yaml | 13 +- config/splat.ov_SC05_000.yaml | 13 +- config/splat.ov_SC05_001.yaml | 13 +- config/splat.ov_SC05_002.yaml | 13 +- config/splat.ov_SC05_003.yaml | 13 +- config/splat.ov_SC05_004.yaml | 13 +- config/splat.ov_SC05_005.yaml | 13 +- config/splat.ov_SC05_006.yaml | 13 +- config/splat.ov_SC05_007.yaml | 13 +- config/splat.ov_SC05_008.yaml | 11 +- config/splat.ov_SC05_009.yaml | 13 +- config/splat.ov_SC05_010.yaml | 13 +- config/splat.ov_SC05_011.yaml | 13 +- config/splat.ov_SC05_017.yaml | 11 +- config/splat.ov_SC05_018.yaml | 13 +- config/splat.ov_SC05_019.yaml | 13 +- config/splat.ov_SC06_000.yaml | 11 +- config/splat.ov_SC06_006.yaml | 13 +- config/splat.ov_SC06_008.yaml | 13 +- config/splat.ov_SC06_010.yaml | 11 +- config/splat.ov_SC06_011.yaml | 13 +- config/splat.ov_SC06_013.yaml | 13 +- config/splat.ov_SC06_014.yaml | 13 +- config/splat.ov_SC06_015.yaml | 13 +- config/splat.ov_SC06_016.yaml | 13 +- src/ov_SC01_080/ov_SC01_080_jr_8015AE2C.c | 4587 ---------------- src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC01_084/ov_SC01_084_jr_8015AE2C.c | 4586 ---------------- src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c | 5946 ++++++++++++++++++++ src/ov_SC02_000/ov_SC02_000_jr_8015AE2C.c | 4585 ---------------- src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c | 5945 ++++++++++++++++++++ src/ov_SC02_003/ov_SC02_003_jr_8015AE2C.c | 4585 ---------------- src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c | 5945 ++++++++++++++++++++ src/ov_SC02_004/ov_SC02_004_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_005/ov_SC02_005_jr_8015AE2C.c | 4585 ---------------- src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c | 5945 ++++++++++++++++++++ src/ov_SC02_011/ov_SC02_011_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_015/ov_SC02_015_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c | 5945 ++++++++++++++++++++ src/ov_SC02_016/ov_SC02_016_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_017/ov_SC02_017_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_021/ov_SC02_021_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_026/ov_SC02_026_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_027/ov_SC02_027_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_028/ov_SC02_028_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_031/ov_SC02_031_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_035/ov_SC02_035_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_039/ov_SC02_039_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC02_041/ov_SC02_041_jr_8015AE2C.c | 4587 ---------------- src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_001/ov_SC03_001_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_002/ov_SC03_002_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_003/ov_SC03_003_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_006/ov_SC03_006_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_007/ov_SC03_007_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_010/ov_SC03_010_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_011/ov_SC03_011_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_012/ov_SC03_012_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_013/ov_SC03_013_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_014/ov_SC03_014_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_015/ov_SC03_015_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_023/ov_SC03_023_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_024/ov_SC03_024_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_028/ov_SC03_028_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_029/ov_SC03_029_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_030/ov_SC03_030_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_031/ov_SC03_031_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_089/ov_SC03_089_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_090/ov_SC03_090_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_091/ov_SC03_091_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_092/ov_SC03_092_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_093/ov_SC03_093_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_094/ov_SC03_094_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_095/ov_SC03_095_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_096/ov_SC03_096_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_097/ov_SC03_097_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_098/ov_SC03_098_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_099/ov_SC03_099_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_100/ov_SC03_100_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_101/ov_SC03_101_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_102/ov_SC03_102_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_103/ov_SC03_103_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_104/ov_SC03_104_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_105/ov_SC03_105_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_108/ov_SC03_108_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_109/ov_SC03_109_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_110/ov_SC03_110_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_111/ov_SC03_111_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c | 5947 +++++++++++++++++++++ src/ov_SC03_112/ov_SC03_112_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_113/ov_SC03_113_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_114/ov_SC03_114_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_115/ov_SC03_115_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_116/ov_SC03_116_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_117/ov_SC03_117_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_118/ov_SC03_118_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_119/ov_SC03_119_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_121/ov_SC03_121_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_124/ov_SC03_124_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_125/ov_SC03_125_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC03_126/ov_SC03_126_jr_8015AE2C.c | 4587 ---------------- src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_000/ov_SC04_000_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_002/ov_SC04_002_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_003/ov_SC04_003_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_004/ov_SC04_004_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_005/ov_SC04_005_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_006/ov_SC04_006_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_007/ov_SC04_007_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_008/ov_SC04_008_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_009/ov_SC04_009_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_010/ov_SC04_010_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_011/ov_SC04_011_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_012/ov_SC04_012_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_015/ov_SC04_015_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_016/ov_SC04_016_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_018/ov_SC04_018_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_019/ov_SC04_019_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_020/ov_SC04_020_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC04_021/ov_SC04_021_jr_8015AE2C.c | 4587 ---------------- src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_000/ov_SC05_000_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c | 5924 ++++++++++++++++++++ src/ov_SC05_001/ov_SC05_001_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_002/ov_SC05_002_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_003/ov_SC05_003_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_004/ov_SC05_004_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_005/ov_SC05_005_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_006/ov_SC05_006_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_007/ov_SC05_007_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_008/ov_SC05_008_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_009/ov_SC05_009_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_010/ov_SC05_010_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_011/ov_SC05_011_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_017/ov_SC05_017_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_018/ov_SC05_018_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC05_019/ov_SC05_019_jr_8015AE2C.c | 4587 ---------------- src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_000/ov_SC06_000_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_006/ov_SC06_006_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_008/ov_SC06_008_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_010/ov_SC06_010_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_011/ov_SC06_011_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_013/ov_SC06_013_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_014/ov_SC06_014_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_015/ov_SC06_015_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c | 5926 ++++++++++++++++++++ src/ov_SC06_016/ov_SC06_016_jr_8015AE2C.c | 4587 ---------------- src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c | 5926 ++++++++++++++++++++ 331 files changed, 653986 insertions(+), 505194 deletions(-) create mode 100644 src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c create mode 100644 src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c create mode 100644 src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c create mode 100644 src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c create mode 100644 src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c create mode 100644 src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c create mode 100644 src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c create mode 100644 src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c create mode 100644 src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c create mode 100644 src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c create mode 100644 src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c create mode 100644 src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c create mode 100644 src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c create mode 100644 src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c create mode 100644 src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c create mode 100644 src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c create mode 100644 src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c create mode 100644 src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c create mode 100644 src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c create mode 100644 src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c create mode 100644 src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c create mode 100644 src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c create mode 100644 src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c create mode 100644 src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c create mode 100644 src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c create mode 100644 src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c create mode 100644 src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c create mode 100644 src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c create mode 100644 src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c create mode 100644 src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c create mode 100644 src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c create mode 100644 src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c create mode 100644 src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c create mode 100644 src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c create mode 100644 src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c create mode 100644 src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c create mode 100644 src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c create mode 100644 src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c create mode 100644 src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c create mode 100644 src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c create mode 100644 src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c create mode 100644 src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c create mode 100644 src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c create mode 100644 src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c create mode 100644 src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c create mode 100644 src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c create mode 100644 src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c create mode 100644 src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c create mode 100644 src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c create mode 100644 src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c create mode 100644 src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c create mode 100644 src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c create mode 100644 src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c create mode 100644 src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c create mode 100644 src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c create mode 100644 src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c create mode 100644 src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c create mode 100644 src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c create mode 100644 src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c create mode 100644 src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c create mode 100644 src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c create mode 100644 src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c create mode 100644 src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c create mode 100644 src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c create mode 100644 src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c create mode 100644 src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c create mode 100644 src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c create mode 100644 src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c create mode 100644 src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c create mode 100644 src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c create mode 100644 src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c create mode 100644 src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c create mode 100644 src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c create mode 100644 src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c create mode 100644 src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c create mode 100644 src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c create mode 100644 src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c create mode 100644 src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c create mode 100644 src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c create mode 100644 src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c create mode 100644 src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c create mode 100644 src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c create mode 100644 src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c create mode 100644 src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c create mode 100644 src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c create mode 100644 src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c create mode 100644 src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c create mode 100644 src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c create mode 100644 src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c create mode 100644 src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c create mode 100644 src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c create mode 100644 src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c create mode 100644 src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c create mode 100644 src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c create mode 100644 src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c create mode 100644 src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c create mode 100644 src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c create mode 100644 src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c create mode 100644 src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c create mode 100644 src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c create mode 100644 src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c create mode 100644 src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c create mode 100644 src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c create mode 100644 src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c create mode 100644 src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c create mode 100644 src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c create mode 100644 src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c create mode 100644 src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c create mode 100644 src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c create mode 100644 src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c diff --git a/config/overlays.mk b/config/overlays.mk index 4cb772a56..ad80bac4c 100644 --- a/config/overlays.mk +++ b/config/overlays.mk @@ -96,7 +96,7 @@ ov_SC03_001_ELF := $(ov_SC03_001_OUT).elf ov_SC03_001_MAPFILE := $(ov_SC03_001_OUT).map ov_SC03_001_LD_SCRIPT := $(ov_SC03_001_OUT).ld ov_SC03_001_SPLAT_YAML := config/splat.ov_SC03_001.yaml -ov_SC03_001_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_001_jr_8012ACE0.o,tail2.data.o,ov_SC03_001_jr_801380E0.o,tail3.data.o,ov_SC03_001_jr_8013F350.o,tail4.data.o,ov_SC03_001_jr_8013FFD8.o,tail5.data.o,ov_SC03_001_jr_8015444C.o,tail6.data.o,ov_SC03_001_jr_80159C84.o,tail7.data.o,ov_SC03_001_jr_8015A3C8.o,tail8.data.o,ov_SC03_001_jr_8015AE2C.o,tail9.data.o,ov_SC03_001_jr_8016AB6C.o,tail10.data.o,ov_SC03_001_jr_801734BC.o,tail11.data.o,ov_SC03_001_jr_80178D40.o,tail12.data.o,ov_SC03_001_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_001_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_001_jr_8012ACE0.o,tail2.data.o,ov_SC03_001_jr_801380E0.o,tail3.data.o,ov_SC03_001_jr_8013F350.o,tail4.data.o,ov_SC03_001_jr_8013FFD8.o,tail5.data.o,ov_SC03_001_jr_8015444C.o,tail6.data.o,ov_SC03_001_jr_80159C84.o,tail7.data.o,ov_SC03_001_jr_8015A3C8.o,tail8.data.o,ov_SC03_001_jr_8015AE2C.o,tail9.data.o,ov_SC03_001_jr_8015C32C.o,tail10.data.o,ov_SC03_001_jr_8016AB6C.o,tail11.data.o,ov_SC03_001_jr_801734BC.o,tail12.data.o,ov_SC03_001_jr_80178D40.o,tail13.data.o,ov_SC03_001_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_001/ov_SC03_001_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_001/ov_SC03_001_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_001/ov_SC03_001_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -171,7 +171,7 @@ ov_SC02_000_ELF := $(ov_SC02_000_OUT).elf ov_SC02_000_MAPFILE := $(ov_SC02_000_OUT).map ov_SC02_000_LD_SCRIPT := $(ov_SC02_000_OUT).ld ov_SC02_000_SPLAT_YAML := config/splat.ov_SC02_000.yaml -ov_SC02_000_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_000_jr_8012ACE0.o,tail2.data.o,ov_SC02_000_jr_801380E0.o,tail3.data.o,ov_SC02_000_jr_8013F350.o,tail4.data.o,ov_SC02_000_jr_8013FFD8.o,tail5.data.o,ov_SC02_000_jr_8015444C.o,tail6.data.o,ov_SC02_000_jr_80159C84.o,tail7.data.o,ov_SC02_000_jr_8015A3C8.o,tail8.data.o,ov_SC02_000_jr_8015AE2C.o,tail9.data.o,ov_SC02_000_jr_8016AB6C.o,tail10.data.o,ov_SC02_000_jr_801734BC.o,tail11.data.o,ov_SC02_000_jr_80178D40.o,tail12.data.o,ov_SC02_000_jr_8017A4AC.o,tail13.data.o,ov_SC02_000_jr_8017FCB0.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_000_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_000_jr_8012ACE0.o,tail2.data.o,ov_SC02_000_jr_801380E0.o,tail3.data.o,ov_SC02_000_jr_8013F350.o,tail4.data.o,ov_SC02_000_jr_8013FFD8.o,tail5.data.o,ov_SC02_000_jr_8015444C.o,tail6.data.o,ov_SC02_000_jr_80159C84.o,tail7.data.o,ov_SC02_000_jr_8015A3C8.o,tail8.data.o,ov_SC02_000_jr_8015AE2C.o,tail9.data.o,ov_SC02_000_jr_8015C32C.o,tail10.data.o,ov_SC02_000_jr_8016AB6C.o,tail11.data.o,ov_SC02_000_jr_801734BC.o,tail12.data.o,ov_SC02_000_jr_80178D40.o,tail13.data.o,ov_SC02_000_jr_8017A4AC.o,tail14.data.o,ov_SC02_000_jr_8017FCB0.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_000/ov_SC02_000_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_000/ov_SC02_000_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_000/ov_SC02_000_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -196,7 +196,7 @@ ov_SC02_003_ELF := $(ov_SC02_003_OUT).elf ov_SC02_003_MAPFILE := $(ov_SC02_003_OUT).map ov_SC02_003_LD_SCRIPT := $(ov_SC02_003_OUT).ld ov_SC02_003_SPLAT_YAML := config/splat.ov_SC02_003.yaml -ov_SC02_003_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_003_jr_8012ACE0.o,tail2.data.o,ov_SC02_003_jr_801380E0.o,tail3.data.o,ov_SC02_003_jr_8013F350.o,tail4.data.o,ov_SC02_003_jr_8013FFD8.o,tail5.data.o,ov_SC02_003_jr_8015444C.o,tail6.data.o,ov_SC02_003_jr_80159C84.o,tail7.data.o,ov_SC02_003_jr_8015A3C8.o,tail8.data.o,ov_SC02_003_jr_8015AE2C.o,tail9.data.o,ov_SC02_003_jr_8016AB6C.o,tail10.data.o,ov_SC02_003_jr_801734BC.o,tail11.data.o,ov_SC02_003_jr_80178D40.o,tail12.data.o,ov_SC02_003_jr_8017A4AC.o,tail13.data.o,ov_SC02_003_jr_8017FCB0.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_003_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_003_jr_8012ACE0.o,tail2.data.o,ov_SC02_003_jr_801380E0.o,tail3.data.o,ov_SC02_003_jr_8013F350.o,tail4.data.o,ov_SC02_003_jr_8013FFD8.o,tail5.data.o,ov_SC02_003_jr_8015444C.o,tail6.data.o,ov_SC02_003_jr_80159C84.o,tail7.data.o,ov_SC02_003_jr_8015A3C8.o,tail8.data.o,ov_SC02_003_jr_8015AE2C.o,tail9.data.o,ov_SC02_003_jr_8015C32C.o,tail10.data.o,ov_SC02_003_jr_8016AB6C.o,tail11.data.o,ov_SC02_003_jr_801734BC.o,tail12.data.o,ov_SC02_003_jr_80178D40.o,tail13.data.o,ov_SC02_003_jr_8017A4AC.o,tail14.data.o,ov_SC02_003_jr_8017FCB0.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_003/ov_SC02_003_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_003/ov_SC02_003_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_003/ov_SC02_003_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -221,7 +221,7 @@ ov_SC03_002_ELF := $(ov_SC03_002_OUT).elf ov_SC03_002_MAPFILE := $(ov_SC03_002_OUT).map ov_SC03_002_LD_SCRIPT := $(ov_SC03_002_OUT).ld ov_SC03_002_SPLAT_YAML := config/splat.ov_SC03_002.yaml -ov_SC03_002_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_002_jr_8012ACE0.o,tail2.data.o,ov_SC03_002_jr_801380E0.o,tail3.data.o,ov_SC03_002_jr_8013F350.o,tail4.data.o,ov_SC03_002_jr_8013FFD8.o,tail5.data.o,ov_SC03_002_jr_8015444C.o,tail6.data.o,ov_SC03_002_jr_80159C84.o,tail7.data.o,ov_SC03_002_jr_8015A3C8.o,tail8.data.o,ov_SC03_002_jr_8015AE2C.o,tail9.data.o,ov_SC03_002_jr_8016AB6C.o,tail10.data.o,ov_SC03_002_jr_801734BC.o,tail11.data.o,ov_SC03_002_jr_80178D40.o,tail12.data.o,ov_SC03_002_jr_8017A4AC.o,tail13.data.o,ov_SC03_002_jr_8017D604.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_002_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_002_jr_8012ACE0.o,tail2.data.o,ov_SC03_002_jr_801380E0.o,tail3.data.o,ov_SC03_002_jr_8013F350.o,tail4.data.o,ov_SC03_002_jr_8013FFD8.o,tail5.data.o,ov_SC03_002_jr_8015444C.o,tail6.data.o,ov_SC03_002_jr_80159C84.o,tail7.data.o,ov_SC03_002_jr_8015A3C8.o,tail8.data.o,ov_SC03_002_jr_8015AE2C.o,tail9.data.o,ov_SC03_002_jr_8015C32C.o,tail10.data.o,ov_SC03_002_jr_8016AB6C.o,tail11.data.o,ov_SC03_002_jr_801734BC.o,tail12.data.o,ov_SC03_002_jr_80178D40.o,tail13.data.o,ov_SC03_002_jr_8017A4AC.o,tail14.data.o,ov_SC03_002_jr_8017D604.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_002/ov_SC03_002_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_002/ov_SC03_002_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_002/ov_SC03_002_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -246,7 +246,7 @@ ov_SC03_006_ELF := $(ov_SC03_006_OUT).elf ov_SC03_006_MAPFILE := $(ov_SC03_006_OUT).map ov_SC03_006_LD_SCRIPT := $(ov_SC03_006_OUT).ld ov_SC03_006_SPLAT_YAML := config/splat.ov_SC03_006.yaml -ov_SC03_006_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_006_jr_8012ACE0.o,tail2.data.o,ov_SC03_006_jr_801380E0.o,tail3.data.o,ov_SC03_006_jr_8013F350.o,tail4.data.o,ov_SC03_006_jr_8013FFD8.o,tail5.data.o,ov_SC03_006_jr_8015444C.o,tail6.data.o,ov_SC03_006_jr_80159C84.o,tail7.data.o,ov_SC03_006_jr_8015A3C8.o,tail8.data.o,ov_SC03_006_jr_8015AE2C.o,tail9.data.o,ov_SC03_006_jr_8016AB6C.o,tail10.data.o,ov_SC03_006_jr_801734BC.o,tail11.data.o,ov_SC03_006_jr_80178D40.o,tail12.data.o,ov_SC03_006_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_006_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_006_jr_8012ACE0.o,tail2.data.o,ov_SC03_006_jr_801380E0.o,tail3.data.o,ov_SC03_006_jr_8013F350.o,tail4.data.o,ov_SC03_006_jr_8013FFD8.o,tail5.data.o,ov_SC03_006_jr_8015444C.o,tail6.data.o,ov_SC03_006_jr_80159C84.o,tail7.data.o,ov_SC03_006_jr_8015A3C8.o,tail8.data.o,ov_SC03_006_jr_8015AE2C.o,tail9.data.o,ov_SC03_006_jr_8015C32C.o,tail10.data.o,ov_SC03_006_jr_8016AB6C.o,tail11.data.o,ov_SC03_006_jr_801734BC.o,tail12.data.o,ov_SC03_006_jr_80178D40.o,tail13.data.o,ov_SC03_006_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_006/ov_SC03_006_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_006/ov_SC03_006_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_006/ov_SC03_006_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -271,7 +271,7 @@ ov_SC04_000_ELF := $(ov_SC04_000_OUT).elf ov_SC04_000_MAPFILE := $(ov_SC04_000_OUT).map ov_SC04_000_LD_SCRIPT := $(ov_SC04_000_OUT).ld ov_SC04_000_SPLAT_YAML := config/splat.ov_SC04_000.yaml -ov_SC04_000_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_000_jr_8012ACE0.o,tail2.data.o,ov_SC04_000_jr_801380E0.o,tail3.data.o,ov_SC04_000_jr_8013F350.o,tail4.data.o,ov_SC04_000_jr_8013FFD8.o,tail5.data.o,ov_SC04_000_jr_8015444C.o,tail6.data.o,ov_SC04_000_jr_80159C84.o,tail7.data.o,ov_SC04_000_jr_8015A3C8.o,tail8.data.o,ov_SC04_000_jr_8015AE2C.o,tail9.data.o,ov_SC04_000_jr_8016AB6C.o,tail10.data.o,ov_SC04_000_jr_801734BC.o,tail11.data.o,ov_SC04_000_jr_80178D40.o,tail12.data.o,ov_SC04_000_jr_8017A4AC.o,tail13.data.o,ov_SC04_000_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_000_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_000_jr_8012ACE0.o,tail2.data.o,ov_SC04_000_jr_801380E0.o,tail3.data.o,ov_SC04_000_jr_8013F350.o,tail4.data.o,ov_SC04_000_jr_8013FFD8.o,tail5.data.o,ov_SC04_000_jr_8015444C.o,tail6.data.o,ov_SC04_000_jr_80159C84.o,tail7.data.o,ov_SC04_000_jr_8015A3C8.o,tail8.data.o,ov_SC04_000_jr_8015AE2C.o,tail9.data.o,ov_SC04_000_jr_8015C32C.o,tail10.data.o,ov_SC04_000_jr_8016AB6C.o,tail11.data.o,ov_SC04_000_jr_801734BC.o,tail12.data.o,ov_SC04_000_jr_80178D40.o,tail13.data.o,ov_SC04_000_jr_8017A4AC.o,tail14.data.o,ov_SC04_000_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_000/ov_SC04_000_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_000/ov_SC04_000_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_000/ov_SC04_000_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -296,7 +296,7 @@ ov_SC04_018_ELF := $(ov_SC04_018_OUT).elf ov_SC04_018_MAPFILE := $(ov_SC04_018_OUT).map ov_SC04_018_LD_SCRIPT := $(ov_SC04_018_OUT).ld ov_SC04_018_SPLAT_YAML := config/splat.ov_SC04_018.yaml -ov_SC04_018_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_018_jr_8012ACE0.o,tail2.data.o,ov_SC04_018_jr_801380E0.o,tail3.data.o,ov_SC04_018_jr_8013F350.o,tail4.data.o,ov_SC04_018_jr_8013FFD8.o,tail5.data.o,ov_SC04_018_jr_8015444C.o,tail6.data.o,ov_SC04_018_jr_80159C84.o,tail7.data.o,ov_SC04_018_jr_8015A3C8.o,tail8.data.o,ov_SC04_018_jr_8015AE2C.o,tail9.data.o,ov_SC04_018_jr_8016AB6C.o,tail10.data.o,ov_SC04_018_jr_801734BC.o,tail11.data.o,ov_SC04_018_jr_80178D40.o,tail12.data.o,ov_SC04_018_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_018_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_018_jr_8012ACE0.o,tail2.data.o,ov_SC04_018_jr_801380E0.o,tail3.data.o,ov_SC04_018_jr_8013F350.o,tail4.data.o,ov_SC04_018_jr_8013FFD8.o,tail5.data.o,ov_SC04_018_jr_8015444C.o,tail6.data.o,ov_SC04_018_jr_80159C84.o,tail7.data.o,ov_SC04_018_jr_8015A3C8.o,tail8.data.o,ov_SC04_018_jr_8015AE2C.o,tail9.data.o,ov_SC04_018_jr_8015C32C.o,tail10.data.o,ov_SC04_018_jr_8016AB6C.o,tail11.data.o,ov_SC04_018_jr_801734BC.o,tail12.data.o,ov_SC04_018_jr_80178D40.o,tail13.data.o,ov_SC04_018_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_018/ov_SC04_018_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_018/ov_SC04_018_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_018/ov_SC04_018_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -321,7 +321,7 @@ ov_SC04_019_ELF := $(ov_SC04_019_OUT).elf ov_SC04_019_MAPFILE := $(ov_SC04_019_OUT).map ov_SC04_019_LD_SCRIPT := $(ov_SC04_019_OUT).ld ov_SC04_019_SPLAT_YAML := config/splat.ov_SC04_019.yaml -ov_SC04_019_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_019_jr_8012ACE0.o,tail2.data.o,ov_SC04_019_jr_801380E0.o,tail3.data.o,ov_SC04_019_jr_8013F350.o,tail4.data.o,ov_SC04_019_jr_8013FFD8.o,tail5.data.o,ov_SC04_019_jr_8015444C.o,tail6.data.o,ov_SC04_019_jr_80159C84.o,tail7.data.o,ov_SC04_019_jr_8015A3C8.o,tail8.data.o,ov_SC04_019_jr_8015AE2C.o,tail9.data.o,ov_SC04_019_jr_8016AB6C.o,tail10.data.o,ov_SC04_019_jr_801734BC.o,tail11.data.o,ov_SC04_019_jr_80178D40.o,tail12.data.o,ov_SC04_019_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_019_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_019_jr_8012ACE0.o,tail2.data.o,ov_SC04_019_jr_801380E0.o,tail3.data.o,ov_SC04_019_jr_8013F350.o,tail4.data.o,ov_SC04_019_jr_8013FFD8.o,tail5.data.o,ov_SC04_019_jr_8015444C.o,tail6.data.o,ov_SC04_019_jr_80159C84.o,tail7.data.o,ov_SC04_019_jr_8015A3C8.o,tail8.data.o,ov_SC04_019_jr_8015AE2C.o,tail9.data.o,ov_SC04_019_jr_8015C32C.o,tail10.data.o,ov_SC04_019_jr_8016AB6C.o,tail11.data.o,ov_SC04_019_jr_801734BC.o,tail12.data.o,ov_SC04_019_jr_80178D40.o,tail13.data.o,ov_SC04_019_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_019/ov_SC04_019_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_019/ov_SC04_019_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_019/ov_SC04_019_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -346,7 +346,7 @@ ov_SC05_000_ELF := $(ov_SC05_000_OUT).elf ov_SC05_000_MAPFILE := $(ov_SC05_000_OUT).map ov_SC05_000_LD_SCRIPT := $(ov_SC05_000_OUT).ld ov_SC05_000_SPLAT_YAML := config/splat.ov_SC05_000.yaml -ov_SC05_000_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_000_jr_8012ACE0.o,tail2.data.o,ov_SC05_000_jr_801380E0.o,tail3.data.o,ov_SC05_000_jr_8013F350.o,tail4.data.o,ov_SC05_000_jr_8013FFD8.o,tail5.data.o,ov_SC05_000_jr_8015444C.o,tail6.data.o,ov_SC05_000_jr_80159C84.o,tail7.data.o,ov_SC05_000_jr_8015A3C8.o,tail8.data.o,ov_SC05_000_jr_8015AE2C.o,tail9.data.o,ov_SC05_000_jr_8016AB6C.o,tail10.data.o,ov_SC05_000_jr_801734BC.o,tail11.data.o,ov_SC05_000_jr_80178D40.o,tail12.data.o,ov_SC05_000_jr_8017A4AC.o,tail13.data.o,ov_SC05_000_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_000_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_000_jr_8012ACE0.o,tail2.data.o,ov_SC05_000_jr_801380E0.o,tail3.data.o,ov_SC05_000_jr_8013F350.o,tail4.data.o,ov_SC05_000_jr_8013FFD8.o,tail5.data.o,ov_SC05_000_jr_8015444C.o,tail6.data.o,ov_SC05_000_jr_80159C84.o,tail7.data.o,ov_SC05_000_jr_8015A3C8.o,tail8.data.o,ov_SC05_000_jr_8015AE2C.o,tail9.data.o,ov_SC05_000_jr_8015C32C.o,tail10.data.o,ov_SC05_000_jr_8016AB6C.o,tail11.data.o,ov_SC05_000_jr_801734BC.o,tail12.data.o,ov_SC05_000_jr_80178D40.o,tail13.data.o,ov_SC05_000_jr_8017A4AC.o,tail14.data.o,ov_SC05_000_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_000/ov_SC05_000_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_000/ov_SC05_000_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_000/ov_SC05_000_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -371,7 +371,7 @@ ov_SC06_000_ELF := $(ov_SC06_000_OUT).elf ov_SC06_000_MAPFILE := $(ov_SC06_000_OUT).map ov_SC06_000_LD_SCRIPT := $(ov_SC06_000_OUT).ld ov_SC06_000_SPLAT_YAML := config/splat.ov_SC06_000.yaml -ov_SC06_000_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_000_jr_8012ACE0.o,tail2.data.o,ov_SC06_000_jr_801380E0.o,tail3.data.o,ov_SC06_000_jr_8013F350.o,tail4.data.o,ov_SC06_000_jr_8015444C.o,tail5.data.o,ov_SC06_000_jr_80159C84.o,tail6.data.o,ov_SC06_000_jr_8015A3C8.o,tail7.data.o,ov_SC06_000_jr_8015AE2C.o,tail8.data.o,ov_SC06_000_jr_8016AB6C.o,tail9.data.o,ov_SC06_000_jr_801734BC.o,tail10.data.o,ov_SC06_000_jr_80178D40.o,tail11.data.o,ov_SC06_000_jr_8017A4AC.o,tail12.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_000_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_000_jr_8012ACE0.o,tail2.data.o,ov_SC06_000_jr_801380E0.o,tail3.data.o,ov_SC06_000_jr_8013F350.o,tail4.data.o,ov_SC06_000_jr_8015444C.o,tail5.data.o,ov_SC06_000_jr_80159C84.o,tail6.data.o,ov_SC06_000_jr_8015A3C8.o,tail7.data.o,ov_SC06_000_jr_8015AE2C.o,tail8.data.o,ov_SC06_000_jr_8015C32C.o,tail9.data.o,ov_SC06_000_jr_8016AB6C.o,tail10.data.o,ov_SC06_000_jr_801734BC.o,tail11.data.o,ov_SC06_000_jr_80178D40.o,tail12.data.o,ov_SC06_000_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_000/ov_SC06_000_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_000/ov_SC06_000_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_000/ov_SC06_000_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -521,7 +521,7 @@ ov_SC01_080_ELF := $(ov_SC01_080_OUT).elf ov_SC01_080_MAPFILE := $(ov_SC01_080_OUT).map ov_SC01_080_LD_SCRIPT := $(ov_SC01_080_OUT).ld ov_SC01_080_SPLAT_YAML := config/splat.ov_SC01_080.yaml -ov_SC01_080_JTBL_INTERLEAVE := --order tail.data.o,ov_SC01_080_jr_8012ACE0.o,tail2.data.o,ov_SC01_080_jr_801380E0.o,tail3.data.o,ov_SC01_080_jr_8013F350.o,tail4.data.o,ov_SC01_080_jr_8013FFD8.o,tail5.data.o,ov_SC01_080_jr_8015444C.o,tail6.data.o,ov_SC01_080_jr_80159C84.o,tail7.data.o,ov_SC01_080_jr_8015A3C8.o,tail8.data.o,ov_SC01_080_jr_8015AE2C.o,tail9.data.o,ov_SC01_080_jr_8016AB6C.o,tail10.data.o,ov_SC01_080_jr_801734BC.o,tail11.data.o,ov_SC01_080_jr_80178D40.o,tail12.data.o,ov_SC01_080_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC01_080_JTBL_INTERLEAVE := --order tail.data.o,ov_SC01_080_jr_8012ACE0.o,tail2.data.o,ov_SC01_080_jr_801380E0.o,tail3.data.o,ov_SC01_080_jr_8013F350.o,tail4.data.o,ov_SC01_080_jr_8013FFD8.o,tail5.data.o,ov_SC01_080_jr_8015444C.o,tail6.data.o,ov_SC01_080_jr_80159C84.o,tail7.data.o,ov_SC01_080_jr_8015A3C8.o,tail8.data.o,ov_SC01_080_jr_8015AE2C.o,tail9.data.o,ov_SC01_080_jr_8015C32C.o,tail10.data.o,ov_SC01_080_jr_8016AB6C.o,tail11.data.o,ov_SC01_080_jr_801734BC.o,tail12.data.o,ov_SC01_080_jr_80178D40.o,tail13.data.o,ov_SC01_080_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC01_080/ov_SC01_080_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC01_080/ov_SC01_080_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC01_080/ov_SC01_080_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -546,7 +546,7 @@ ov_SC01_084_ELF := $(ov_SC01_084_OUT).elf ov_SC01_084_MAPFILE := $(ov_SC01_084_OUT).map ov_SC01_084_LD_SCRIPT := $(ov_SC01_084_OUT).ld ov_SC01_084_SPLAT_YAML := config/splat.ov_SC01_084.yaml -ov_SC01_084_JTBL_INTERLEAVE := --order tail.data.o,ov_SC01_084_jr_8012ACE0.o,tail2.data.o,ov_SC01_084_jr_801380E0.o,tail3.data.o,ov_SC01_084_jr_8013F350.o,tail4.data.o,ov_SC01_084_jr_8013FFD8.o,tail5.data.o,ov_SC01_084_jr_8015444C.o,tail6.data.o,ov_SC01_084_jr_80159C84.o,tail7.data.o,ov_SC01_084_jr_8015A3C8.o,tail8.data.o,ov_SC01_084_jr_8015AE2C.o,tail9.data.o,ov_SC01_084_jr_8016AB6C.o,tail10.data.o,ov_SC01_084_jr_801734BC.o,tail11.data.o,ov_SC01_084_jr_80178D40.o,tail12.data.o,ov_SC01_084_jr_8017A4AC.o,tail13.data.o,ov_SC01_084_jr_8017CA80.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC01_084_JTBL_INTERLEAVE := --order tail.data.o,ov_SC01_084_jr_8012ACE0.o,tail2.data.o,ov_SC01_084_jr_801380E0.o,tail3.data.o,ov_SC01_084_jr_8013F350.o,tail4.data.o,ov_SC01_084_jr_8013FFD8.o,tail5.data.o,ov_SC01_084_jr_8015444C.o,tail6.data.o,ov_SC01_084_jr_80159C84.o,tail7.data.o,ov_SC01_084_jr_8015A3C8.o,tail8.data.o,ov_SC01_084_jr_8015AE2C.o,tail9.data.o,ov_SC01_084_jr_8015C32C.o,tail10.data.o,ov_SC01_084_jr_8016AB6C.o,tail11.data.o,ov_SC01_084_jr_801734BC.o,tail12.data.o,ov_SC01_084_jr_80178D40.o,tail13.data.o,ov_SC01_084_jr_8017A4AC.o,tail14.data.o,ov_SC01_084_jr_8017CA80.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC01_084/ov_SC01_084_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC01_084/ov_SC01_084_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC01_084/ov_SC01_084_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -571,7 +571,7 @@ ov_SC02_004_ELF := $(ov_SC02_004_OUT).elf ov_SC02_004_MAPFILE := $(ov_SC02_004_OUT).map ov_SC02_004_LD_SCRIPT := $(ov_SC02_004_OUT).ld ov_SC02_004_SPLAT_YAML := config/splat.ov_SC02_004.yaml -ov_SC02_004_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_004_jr_8012ACE0.o,tail2.data.o,ov_SC02_004_jr_801380E0.o,tail3.data.o,ov_SC02_004_jr_8013F350.o,tail4.data.o,ov_SC02_004_jr_8013FFD8.o,tail5.data.o,ov_SC02_004_jr_8015444C.o,tail6.data.o,ov_SC02_004_jr_80159C84.o,tail7.data.o,ov_SC02_004_jr_8015A3C8.o,tail8.data.o,ov_SC02_004_jr_8015AE2C.o,tail9.data.o,ov_SC02_004_jr_8016AB6C.o,tail10.data.o,ov_SC02_004_jr_801734BC.o,tail11.data.o,ov_SC02_004_jr_80178D40.o,tail12.data.o,ov_SC02_004_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_004_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_004_jr_8012ACE0.o,tail2.data.o,ov_SC02_004_jr_801380E0.o,tail3.data.o,ov_SC02_004_jr_8013F350.o,tail4.data.o,ov_SC02_004_jr_8013FFD8.o,tail5.data.o,ov_SC02_004_jr_8015444C.o,tail6.data.o,ov_SC02_004_jr_80159C84.o,tail7.data.o,ov_SC02_004_jr_8015A3C8.o,tail8.data.o,ov_SC02_004_jr_8015AE2C.o,tail9.data.o,ov_SC02_004_jr_8015C32C.o,tail10.data.o,ov_SC02_004_jr_8016AB6C.o,tail11.data.o,ov_SC02_004_jr_801734BC.o,tail12.data.o,ov_SC02_004_jr_80178D40.o,tail13.data.o,ov_SC02_004_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_004/ov_SC02_004_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_004/ov_SC02_004_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_004/ov_SC02_004_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -596,7 +596,7 @@ ov_SC02_005_ELF := $(ov_SC02_005_OUT).elf ov_SC02_005_MAPFILE := $(ov_SC02_005_OUT).map ov_SC02_005_LD_SCRIPT := $(ov_SC02_005_OUT).ld ov_SC02_005_SPLAT_YAML := config/splat.ov_SC02_005.yaml -ov_SC02_005_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_005_jr_8012ACE0.o,tail2.data.o,ov_SC02_005_jr_801380E0.o,tail3.data.o,ov_SC02_005_jr_8013F350.o,tail4.data.o,ov_SC02_005_jr_8013FFD8.o,tail5.data.o,ov_SC02_005_jr_8015444C.o,tail6.data.o,ov_SC02_005_jr_80159C84.o,tail7.data.o,ov_SC02_005_jr_8015A3C8.o,tail8.data.o,ov_SC02_005_jr_8015AE2C.o,tail9.data.o,ov_SC02_005_jr_8016AB6C.o,tail10.data.o,ov_SC02_005_jr_801734BC.o,tail11.data.o,ov_SC02_005_jr_80178D40.o,tail12.data.o,ov_SC02_005_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_005_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_005_jr_8012ACE0.o,tail2.data.o,ov_SC02_005_jr_801380E0.o,tail3.data.o,ov_SC02_005_jr_8013F350.o,tail4.data.o,ov_SC02_005_jr_8013FFD8.o,tail5.data.o,ov_SC02_005_jr_8015444C.o,tail6.data.o,ov_SC02_005_jr_80159C84.o,tail7.data.o,ov_SC02_005_jr_8015A3C8.o,tail8.data.o,ov_SC02_005_jr_8015AE2C.o,tail9.data.o,ov_SC02_005_jr_8015C32C.o,tail10.data.o,ov_SC02_005_jr_8016AB6C.o,tail11.data.o,ov_SC02_005_jr_801734BC.o,tail12.data.o,ov_SC02_005_jr_80178D40.o,tail13.data.o,ov_SC02_005_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_005/ov_SC02_005_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_005/ov_SC02_005_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_005/ov_SC02_005_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -621,7 +621,7 @@ ov_SC02_011_ELF := $(ov_SC02_011_OUT).elf ov_SC02_011_MAPFILE := $(ov_SC02_011_OUT).map ov_SC02_011_LD_SCRIPT := $(ov_SC02_011_OUT).ld ov_SC02_011_SPLAT_YAML := config/splat.ov_SC02_011.yaml -ov_SC02_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_011_jr_8012ACE0.o,tail2.data.o,ov_SC02_011_jr_801380E0.o,tail3.data.o,ov_SC02_011_jr_8013F350.o,tail4.data.o,ov_SC02_011_jr_8013FFD8.o,tail5.data.o,ov_SC02_011_jr_8015444C.o,tail6.data.o,ov_SC02_011_jr_80159C84.o,tail7.data.o,ov_SC02_011_jr_8015A3C8.o,tail8.data.o,ov_SC02_011_jr_8015AE2C.o,tail9.data.o,ov_SC02_011_jr_8016AB6C.o,tail10.data.o,ov_SC02_011_jr_801734BC.o,tail11.data.o,ov_SC02_011_jr_80178D40.o,tail12.data.o,ov_SC02_011_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_011_jr_8012ACE0.o,tail2.data.o,ov_SC02_011_jr_801380E0.o,tail3.data.o,ov_SC02_011_jr_8013F350.o,tail4.data.o,ov_SC02_011_jr_8013FFD8.o,tail5.data.o,ov_SC02_011_jr_8015444C.o,tail6.data.o,ov_SC02_011_jr_80159C84.o,tail7.data.o,ov_SC02_011_jr_8015A3C8.o,tail8.data.o,ov_SC02_011_jr_8015AE2C.o,tail9.data.o,ov_SC02_011_jr_8015C32C.o,tail10.data.o,ov_SC02_011_jr_8016AB6C.o,tail11.data.o,ov_SC02_011_jr_801734BC.o,tail12.data.o,ov_SC02_011_jr_80178D40.o,tail13.data.o,ov_SC02_011_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_011/ov_SC02_011_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_011/ov_SC02_011_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_011/ov_SC02_011_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -646,7 +646,7 @@ ov_SC02_015_ELF := $(ov_SC02_015_OUT).elf ov_SC02_015_MAPFILE := $(ov_SC02_015_OUT).map ov_SC02_015_LD_SCRIPT := $(ov_SC02_015_OUT).ld ov_SC02_015_SPLAT_YAML := config/splat.ov_SC02_015.yaml -ov_SC02_015_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_015_jr_8012ACE0.o,tail2.data.o,ov_SC02_015_jr_801380E0.o,tail3.data.o,ov_SC02_015_jr_8013F350.o,tail4.data.o,ov_SC02_015_jr_8013FFD8.o,tail5.data.o,ov_SC02_015_jr_8015444C.o,tail6.data.o,ov_SC02_015_jr_80159C84.o,tail7.data.o,ov_SC02_015_jr_8015A3C8.o,tail8.data.o,ov_SC02_015_jr_8015AE2C.o,tail9.data.o,ov_SC02_015_jr_8016AB6C.o,tail10.data.o,ov_SC02_015_jr_801734BC.o,tail11.data.o,ov_SC02_015_jr_80178D40.o,tail12.data.o,ov_SC02_015_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_015_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_015_jr_8012ACE0.o,tail2.data.o,ov_SC02_015_jr_801380E0.o,tail3.data.o,ov_SC02_015_jr_8013F350.o,tail4.data.o,ov_SC02_015_jr_8013FFD8.o,tail5.data.o,ov_SC02_015_jr_8015444C.o,tail6.data.o,ov_SC02_015_jr_80159C84.o,tail7.data.o,ov_SC02_015_jr_8015A3C8.o,tail8.data.o,ov_SC02_015_jr_8015AE2C.o,tail9.data.o,ov_SC02_015_jr_8015C32C.o,tail10.data.o,ov_SC02_015_jr_8016AB6C.o,tail11.data.o,ov_SC02_015_jr_801734BC.o,tail12.data.o,ov_SC02_015_jr_80178D40.o,tail13.data.o,ov_SC02_015_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_015/ov_SC02_015_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_015/ov_SC02_015_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_015/ov_SC02_015_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -671,7 +671,7 @@ ov_SC02_016_ELF := $(ov_SC02_016_OUT).elf ov_SC02_016_MAPFILE := $(ov_SC02_016_OUT).map ov_SC02_016_LD_SCRIPT := $(ov_SC02_016_OUT).ld ov_SC02_016_SPLAT_YAML := config/splat.ov_SC02_016.yaml -ov_SC02_016_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_016_jr_8012ACE0.o,tail2.data.o,ov_SC02_016_jr_801380E0.o,tail3.data.o,ov_SC02_016_jr_8013F350.o,tail4.data.o,ov_SC02_016_jr_8013FFD8.o,tail5.data.o,ov_SC02_016_jr_8015444C.o,tail6.data.o,ov_SC02_016_jr_80159C84.o,tail7.data.o,ov_SC02_016_jr_8015A3C8.o,tail8.data.o,ov_SC02_016_jr_8015AE2C.o,tail9.data.o,ov_SC02_016_jr_8016AB6C.o,tail10.data.o,ov_SC02_016_jr_801734BC.o,tail11.data.o,ov_SC02_016_jr_80178D40.o,tail12.data.o,ov_SC02_016_jr_8017A4AC.o,tail13.data.o,ov_SC02_016_jr_8017DC70.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_016_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_016_jr_8012ACE0.o,tail2.data.o,ov_SC02_016_jr_801380E0.o,tail3.data.o,ov_SC02_016_jr_8013F350.o,tail4.data.o,ov_SC02_016_jr_8013FFD8.o,tail5.data.o,ov_SC02_016_jr_8015444C.o,tail6.data.o,ov_SC02_016_jr_80159C84.o,tail7.data.o,ov_SC02_016_jr_8015A3C8.o,tail8.data.o,ov_SC02_016_jr_8015AE2C.o,tail9.data.o,ov_SC02_016_jr_8015C32C.o,tail10.data.o,ov_SC02_016_jr_8016AB6C.o,tail11.data.o,ov_SC02_016_jr_801734BC.o,tail12.data.o,ov_SC02_016_jr_80178D40.o,tail13.data.o,ov_SC02_016_jr_8017A4AC.o,tail14.data.o,ov_SC02_016_jr_8017DC70.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_016/ov_SC02_016_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_016/ov_SC02_016_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_016/ov_SC02_016_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -696,7 +696,7 @@ ov_SC02_017_ELF := $(ov_SC02_017_OUT).elf ov_SC02_017_MAPFILE := $(ov_SC02_017_OUT).map ov_SC02_017_LD_SCRIPT := $(ov_SC02_017_OUT).ld ov_SC02_017_SPLAT_YAML := config/splat.ov_SC02_017.yaml -ov_SC02_017_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_017_jr_8012ACE0.o,tail2.data.o,ov_SC02_017_jr_801380E0.o,tail3.data.o,ov_SC02_017_jr_8013F350.o,tail4.data.o,ov_SC02_017_jr_8013FFD8.o,tail5.data.o,ov_SC02_017_jr_8015444C.o,tail6.data.o,ov_SC02_017_jr_80159C84.o,tail7.data.o,ov_SC02_017_jr_8015A3C8.o,tail8.data.o,ov_SC02_017_jr_8015AE2C.o,tail9.data.o,ov_SC02_017_jr_8016AB6C.o,tail10.data.o,ov_SC02_017_jr_801734BC.o,tail11.data.o,ov_SC02_017_jr_80178D40.o,tail12.data.o,ov_SC02_017_jr_8017A4AC.o,tail13.data.o,ov_SC02_017_jr_8017DF34.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_017_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_017_jr_8012ACE0.o,tail2.data.o,ov_SC02_017_jr_801380E0.o,tail3.data.o,ov_SC02_017_jr_8013F350.o,tail4.data.o,ov_SC02_017_jr_8013FFD8.o,tail5.data.o,ov_SC02_017_jr_8015444C.o,tail6.data.o,ov_SC02_017_jr_80159C84.o,tail7.data.o,ov_SC02_017_jr_8015A3C8.o,tail8.data.o,ov_SC02_017_jr_8015AE2C.o,tail9.data.o,ov_SC02_017_jr_8015C32C.o,tail10.data.o,ov_SC02_017_jr_8016AB6C.o,tail11.data.o,ov_SC02_017_jr_801734BC.o,tail12.data.o,ov_SC02_017_jr_80178D40.o,tail13.data.o,ov_SC02_017_jr_8017A4AC.o,tail14.data.o,ov_SC02_017_jr_8017DF34.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_017/ov_SC02_017_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_017/ov_SC02_017_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_017/ov_SC02_017_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -721,7 +721,7 @@ ov_SC02_021_ELF := $(ov_SC02_021_OUT).elf ov_SC02_021_MAPFILE := $(ov_SC02_021_OUT).map ov_SC02_021_LD_SCRIPT := $(ov_SC02_021_OUT).ld ov_SC02_021_SPLAT_YAML := config/splat.ov_SC02_021.yaml -ov_SC02_021_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_021_jr_8012ACE0.o,tail2.data.o,ov_SC02_021_jr_801380E0.o,tail3.data.o,ov_SC02_021_jr_8013F350.o,tail4.data.o,ov_SC02_021_jr_8013FFD8.o,tail5.data.o,ov_SC02_021_jr_8015444C.o,tail6.data.o,ov_SC02_021_jr_80159C84.o,tail7.data.o,ov_SC02_021_jr_8015A3C8.o,tail8.data.o,ov_SC02_021_jr_8015AE2C.o,tail9.data.o,ov_SC02_021_jr_8016AB6C.o,tail10.data.o,ov_SC02_021_jr_801734BC.o,tail11.data.o,ov_SC02_021_jr_80178D40.o,tail12.data.o,ov_SC02_021_jr_8017A4AC.o,tail13.data.o,ov_SC02_021_jr_8017C294.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_021_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_021_jr_8012ACE0.o,tail2.data.o,ov_SC02_021_jr_801380E0.o,tail3.data.o,ov_SC02_021_jr_8013F350.o,tail4.data.o,ov_SC02_021_jr_8013FFD8.o,tail5.data.o,ov_SC02_021_jr_8015444C.o,tail6.data.o,ov_SC02_021_jr_80159C84.o,tail7.data.o,ov_SC02_021_jr_8015A3C8.o,tail8.data.o,ov_SC02_021_jr_8015AE2C.o,tail9.data.o,ov_SC02_021_jr_8015C32C.o,tail10.data.o,ov_SC02_021_jr_8016AB6C.o,tail11.data.o,ov_SC02_021_jr_801734BC.o,tail12.data.o,ov_SC02_021_jr_80178D40.o,tail13.data.o,ov_SC02_021_jr_8017A4AC.o,tail14.data.o,ov_SC02_021_jr_8017C294.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_021/ov_SC02_021_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_021/ov_SC02_021_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_021/ov_SC02_021_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -746,7 +746,7 @@ ov_SC02_026_ELF := $(ov_SC02_026_OUT).elf ov_SC02_026_MAPFILE := $(ov_SC02_026_OUT).map ov_SC02_026_LD_SCRIPT := $(ov_SC02_026_OUT).ld ov_SC02_026_SPLAT_YAML := config/splat.ov_SC02_026.yaml -ov_SC02_026_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_026_jr_8012ACE0.o,tail2.data.o,ov_SC02_026_jr_801380E0.o,tail3.data.o,ov_SC02_026_jr_8013F350.o,tail4.data.o,ov_SC02_026_jr_8013FFD8.o,tail5.data.o,ov_SC02_026_jr_8015444C.o,tail6.data.o,ov_SC02_026_jr_80159C84.o,tail7.data.o,ov_SC02_026_jr_8015A3C8.o,tail8.data.o,ov_SC02_026_jr_8015AE2C.o,tail9.data.o,ov_SC02_026_jr_8016AB6C.o,tail10.data.o,ov_SC02_026_jr_801734BC.o,tail11.data.o,ov_SC02_026_jr_80178D40.o,tail12.data.o,ov_SC02_026_jr_8017A4AC.o,tail13.data.o,ov_SC02_026_jr_8017C180.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_026_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_026_jr_8012ACE0.o,tail2.data.o,ov_SC02_026_jr_801380E0.o,tail3.data.o,ov_SC02_026_jr_8013F350.o,tail4.data.o,ov_SC02_026_jr_8013FFD8.o,tail5.data.o,ov_SC02_026_jr_8015444C.o,tail6.data.o,ov_SC02_026_jr_80159C84.o,tail7.data.o,ov_SC02_026_jr_8015A3C8.o,tail8.data.o,ov_SC02_026_jr_8015AE2C.o,tail9.data.o,ov_SC02_026_jr_8015C32C.o,tail10.data.o,ov_SC02_026_jr_8016AB6C.o,tail11.data.o,ov_SC02_026_jr_801734BC.o,tail12.data.o,ov_SC02_026_jr_80178D40.o,tail13.data.o,ov_SC02_026_jr_8017A4AC.o,tail14.data.o,ov_SC02_026_jr_8017C180.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_026/ov_SC02_026_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_026/ov_SC02_026_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_026/ov_SC02_026_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -771,7 +771,7 @@ ov_SC02_027_ELF := $(ov_SC02_027_OUT).elf ov_SC02_027_MAPFILE := $(ov_SC02_027_OUT).map ov_SC02_027_LD_SCRIPT := $(ov_SC02_027_OUT).ld ov_SC02_027_SPLAT_YAML := config/splat.ov_SC02_027.yaml -ov_SC02_027_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_027_jr_8012ACE0.o,tail2.data.o,ov_SC02_027_jr_801380E0.o,tail3.data.o,ov_SC02_027_jr_8013F350.o,tail4.data.o,ov_SC02_027_jr_8013FFD8.o,tail5.data.o,ov_SC02_027_jr_8015444C.o,tail6.data.o,ov_SC02_027_jr_80159C84.o,tail7.data.o,ov_SC02_027_jr_8015A3C8.o,tail8.data.o,ov_SC02_027_jr_8015AE2C.o,tail9.data.o,ov_SC02_027_jr_8016AB6C.o,tail10.data.o,ov_SC02_027_jr_801734BC.o,tail11.data.o,ov_SC02_027_jr_80178D40.o,tail12.data.o,ov_SC02_027_jr_8017A4AC.o,tail13.data.o,ov_SC02_027_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_027_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_027_jr_8012ACE0.o,tail2.data.o,ov_SC02_027_jr_801380E0.o,tail3.data.o,ov_SC02_027_jr_8013F350.o,tail4.data.o,ov_SC02_027_jr_8013FFD8.o,tail5.data.o,ov_SC02_027_jr_8015444C.o,tail6.data.o,ov_SC02_027_jr_80159C84.o,tail7.data.o,ov_SC02_027_jr_8015A3C8.o,tail8.data.o,ov_SC02_027_jr_8015AE2C.o,tail9.data.o,ov_SC02_027_jr_8015C32C.o,tail10.data.o,ov_SC02_027_jr_8016AB6C.o,tail11.data.o,ov_SC02_027_jr_801734BC.o,tail12.data.o,ov_SC02_027_jr_80178D40.o,tail13.data.o,ov_SC02_027_jr_8017A4AC.o,tail14.data.o,ov_SC02_027_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_027/ov_SC02_027_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_027/ov_SC02_027_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_027/ov_SC02_027_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -796,7 +796,7 @@ ov_SC02_028_ELF := $(ov_SC02_028_OUT).elf ov_SC02_028_MAPFILE := $(ov_SC02_028_OUT).map ov_SC02_028_LD_SCRIPT := $(ov_SC02_028_OUT).ld ov_SC02_028_SPLAT_YAML := config/splat.ov_SC02_028.yaml -ov_SC02_028_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_028_jr_8012ACE0.o,tail2.data.o,ov_SC02_028_jr_801380E0.o,tail3.data.o,ov_SC02_028_jr_8013F350.o,tail4.data.o,ov_SC02_028_jr_8013FFD8.o,tail5.data.o,ov_SC02_028_jr_8015444C.o,tail6.data.o,ov_SC02_028_jr_80159C84.o,tail7.data.o,ov_SC02_028_jr_8015A3C8.o,tail8.data.o,ov_SC02_028_jr_8015AE2C.o,tail9.data.o,ov_SC02_028_jr_8016AB6C.o,tail10.data.o,ov_SC02_028_jr_801734BC.o,tail11.data.o,ov_SC02_028_jr_80178D40.o,tail12.data.o,ov_SC02_028_jr_8017A4AC.o,tail13.data.o,ov_SC02_028_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_028_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_028_jr_8012ACE0.o,tail2.data.o,ov_SC02_028_jr_801380E0.o,tail3.data.o,ov_SC02_028_jr_8013F350.o,tail4.data.o,ov_SC02_028_jr_8013FFD8.o,tail5.data.o,ov_SC02_028_jr_8015444C.o,tail6.data.o,ov_SC02_028_jr_80159C84.o,tail7.data.o,ov_SC02_028_jr_8015A3C8.o,tail8.data.o,ov_SC02_028_jr_8015AE2C.o,tail9.data.o,ov_SC02_028_jr_8015C32C.o,tail10.data.o,ov_SC02_028_jr_8016AB6C.o,tail11.data.o,ov_SC02_028_jr_801734BC.o,tail12.data.o,ov_SC02_028_jr_80178D40.o,tail13.data.o,ov_SC02_028_jr_8017A4AC.o,tail14.data.o,ov_SC02_028_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_028/ov_SC02_028_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_028/ov_SC02_028_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_028/ov_SC02_028_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -821,7 +821,7 @@ ov_SC02_031_ELF := $(ov_SC02_031_OUT).elf ov_SC02_031_MAPFILE := $(ov_SC02_031_OUT).map ov_SC02_031_LD_SCRIPT := $(ov_SC02_031_OUT).ld ov_SC02_031_SPLAT_YAML := config/splat.ov_SC02_031.yaml -ov_SC02_031_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_031_jr_8012ACE0.o,tail2.data.o,ov_SC02_031_jr_801380E0.o,tail3.data.o,ov_SC02_031_jr_8013F350.o,tail4.data.o,ov_SC02_031_jr_8013FFD8.o,tail5.data.o,ov_SC02_031_jr_8015444C.o,tail6.data.o,ov_SC02_031_jr_80159C84.o,tail7.data.o,ov_SC02_031_jr_8015A3C8.o,tail8.data.o,ov_SC02_031_jr_8015AE2C.o,tail9.data.o,ov_SC02_031_jr_8016AB6C.o,tail10.data.o,ov_SC02_031_jr_801734BC.o,tail11.data.o,ov_SC02_031_jr_80178D40.o,tail12.data.o,ov_SC02_031_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_031_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_031_jr_8012ACE0.o,tail2.data.o,ov_SC02_031_jr_801380E0.o,tail3.data.o,ov_SC02_031_jr_8013F350.o,tail4.data.o,ov_SC02_031_jr_8013FFD8.o,tail5.data.o,ov_SC02_031_jr_8015444C.o,tail6.data.o,ov_SC02_031_jr_80159C84.o,tail7.data.o,ov_SC02_031_jr_8015A3C8.o,tail8.data.o,ov_SC02_031_jr_8015AE2C.o,tail9.data.o,ov_SC02_031_jr_8015C32C.o,tail10.data.o,ov_SC02_031_jr_8016AB6C.o,tail11.data.o,ov_SC02_031_jr_801734BC.o,tail12.data.o,ov_SC02_031_jr_80178D40.o,tail13.data.o,ov_SC02_031_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_031/ov_SC02_031_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_031/ov_SC02_031_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_031/ov_SC02_031_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -846,7 +846,7 @@ ov_SC02_035_ELF := $(ov_SC02_035_OUT).elf ov_SC02_035_MAPFILE := $(ov_SC02_035_OUT).map ov_SC02_035_LD_SCRIPT := $(ov_SC02_035_OUT).ld ov_SC02_035_SPLAT_YAML := config/splat.ov_SC02_035.yaml -ov_SC02_035_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_035_jr_8012ACE0.o,tail2.data.o,ov_SC02_035_jr_801380E0.o,tail3.data.o,ov_SC02_035_jr_8013F350.o,tail4.data.o,ov_SC02_035_jr_8013FFD8.o,tail5.data.o,ov_SC02_035_jr_8015444C.o,tail6.data.o,ov_SC02_035_jr_80159C84.o,tail7.data.o,ov_SC02_035_jr_8015A3C8.o,tail8.data.o,ov_SC02_035_jr_8015AE2C.o,tail9.data.o,ov_SC02_035_jr_8016AB6C.o,tail10.data.o,ov_SC02_035_jr_801734BC.o,tail11.data.o,ov_SC02_035_jr_80178D40.o,tail12.data.o,ov_SC02_035_jr_8017A4AC.o,tail13.data.o,ov_SC02_035_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_035_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_035_jr_8012ACE0.o,tail2.data.o,ov_SC02_035_jr_801380E0.o,tail3.data.o,ov_SC02_035_jr_8013F350.o,tail4.data.o,ov_SC02_035_jr_8013FFD8.o,tail5.data.o,ov_SC02_035_jr_8015444C.o,tail6.data.o,ov_SC02_035_jr_80159C84.o,tail7.data.o,ov_SC02_035_jr_8015A3C8.o,tail8.data.o,ov_SC02_035_jr_8015AE2C.o,tail9.data.o,ov_SC02_035_jr_8015C32C.o,tail10.data.o,ov_SC02_035_jr_8016AB6C.o,tail11.data.o,ov_SC02_035_jr_801734BC.o,tail12.data.o,ov_SC02_035_jr_80178D40.o,tail13.data.o,ov_SC02_035_jr_8017A4AC.o,tail14.data.o,ov_SC02_035_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_035/ov_SC02_035_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_035/ov_SC02_035_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_035/ov_SC02_035_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -871,7 +871,7 @@ ov_SC02_039_ELF := $(ov_SC02_039_OUT).elf ov_SC02_039_MAPFILE := $(ov_SC02_039_OUT).map ov_SC02_039_LD_SCRIPT := $(ov_SC02_039_OUT).ld ov_SC02_039_SPLAT_YAML := config/splat.ov_SC02_039.yaml -ov_SC02_039_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_039_jr_8012ACE0.o,tail2.data.o,ov_SC02_039_jr_801380E0.o,tail3.data.o,ov_SC02_039_jr_8013F350.o,tail4.data.o,ov_SC02_039_jr_8013FFD8.o,tail5.data.o,ov_SC02_039_jr_8015444C.o,tail6.data.o,ov_SC02_039_jr_80159C84.o,tail7.data.o,ov_SC02_039_jr_8015A3C8.o,tail8.data.o,ov_SC02_039_jr_8015AE2C.o,tail9.data.o,ov_SC02_039_jr_8016AB6C.o,tail10.data.o,ov_SC02_039_jr_801734BC.o,tail11.data.o,ov_SC02_039_jr_80178D40.o,tail12.data.o,ov_SC02_039_jr_8017A4AC.o,tail13.data.o,ov_SC02_039_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_039_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_039_jr_8012ACE0.o,tail2.data.o,ov_SC02_039_jr_801380E0.o,tail3.data.o,ov_SC02_039_jr_8013F350.o,tail4.data.o,ov_SC02_039_jr_8013FFD8.o,tail5.data.o,ov_SC02_039_jr_8015444C.o,tail6.data.o,ov_SC02_039_jr_80159C84.o,tail7.data.o,ov_SC02_039_jr_8015A3C8.o,tail8.data.o,ov_SC02_039_jr_8015AE2C.o,tail9.data.o,ov_SC02_039_jr_8015C32C.o,tail10.data.o,ov_SC02_039_jr_8016AB6C.o,tail11.data.o,ov_SC02_039_jr_801734BC.o,tail12.data.o,ov_SC02_039_jr_80178D40.o,tail13.data.o,ov_SC02_039_jr_8017A4AC.o,tail14.data.o,ov_SC02_039_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_039/ov_SC02_039_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_039/ov_SC02_039_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_039/ov_SC02_039_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -896,7 +896,7 @@ ov_SC02_041_ELF := $(ov_SC02_041_OUT).elf ov_SC02_041_MAPFILE := $(ov_SC02_041_OUT).map ov_SC02_041_LD_SCRIPT := $(ov_SC02_041_OUT).ld ov_SC02_041_SPLAT_YAML := config/splat.ov_SC02_041.yaml -ov_SC02_041_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_041_jr_8012ACE0.o,tail2.data.o,ov_SC02_041_jr_801380E0.o,tail3.data.o,ov_SC02_041_jr_8013F350.o,tail4.data.o,ov_SC02_041_jr_8013FFD8.o,tail5.data.o,ov_SC02_041_jr_8015444C.o,tail6.data.o,ov_SC02_041_jr_80159C84.o,tail7.data.o,ov_SC02_041_jr_8015A3C8.o,tail8.data.o,ov_SC02_041_jr_8015AE2C.o,tail9.data.o,ov_SC02_041_jr_8016AB6C.o,tail10.data.o,ov_SC02_041_jr_801734BC.o,tail11.data.o,ov_SC02_041_jr_80178D40.o,tail12.data.o,ov_SC02_041_jr_8017A4AC.o,tail13.data.o,ov_SC02_041_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC02_041_JTBL_INTERLEAVE := --order tail.data.o,ov_SC02_041_jr_8012ACE0.o,tail2.data.o,ov_SC02_041_jr_801380E0.o,tail3.data.o,ov_SC02_041_jr_8013F350.o,tail4.data.o,ov_SC02_041_jr_8013FFD8.o,tail5.data.o,ov_SC02_041_jr_8015444C.o,tail6.data.o,ov_SC02_041_jr_80159C84.o,tail7.data.o,ov_SC02_041_jr_8015A3C8.o,tail8.data.o,ov_SC02_041_jr_8015AE2C.o,tail9.data.o,ov_SC02_041_jr_8015C32C.o,tail10.data.o,ov_SC02_041_jr_8016AB6C.o,tail11.data.o,ov_SC02_041_jr_801734BC.o,tail12.data.o,ov_SC02_041_jr_80178D40.o,tail13.data.o,ov_SC02_041_jr_8017A4AC.o,tail14.data.o,ov_SC02_041_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC02_041/ov_SC02_041_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC02_041/ov_SC02_041_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC02_041/ov_SC02_041_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -921,7 +921,7 @@ ov_SC03_003_ELF := $(ov_SC03_003_OUT).elf ov_SC03_003_MAPFILE := $(ov_SC03_003_OUT).map ov_SC03_003_LD_SCRIPT := $(ov_SC03_003_OUT).ld ov_SC03_003_SPLAT_YAML := config/splat.ov_SC03_003.yaml -ov_SC03_003_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_003_jr_8012ACE0.o,tail2.data.o,ov_SC03_003_jr_801380E0.o,tail3.data.o,ov_SC03_003_jr_8013F350.o,tail4.data.o,ov_SC03_003_jr_8013FFD8.o,tail5.data.o,ov_SC03_003_jr_8015444C.o,tail6.data.o,ov_SC03_003_jr_80159C84.o,tail7.data.o,ov_SC03_003_jr_8015A3C8.o,tail8.data.o,ov_SC03_003_jr_8015AE2C.o,tail9.data.o,ov_SC03_003_jr_8016AB6C.o,tail10.data.o,ov_SC03_003_jr_801734BC.o,tail11.data.o,ov_SC03_003_jr_80178D40.o,tail12.data.o,ov_SC03_003_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_003_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_003_jr_8012ACE0.o,tail2.data.o,ov_SC03_003_jr_801380E0.o,tail3.data.o,ov_SC03_003_jr_8013F350.o,tail4.data.o,ov_SC03_003_jr_8013FFD8.o,tail5.data.o,ov_SC03_003_jr_8015444C.o,tail6.data.o,ov_SC03_003_jr_80159C84.o,tail7.data.o,ov_SC03_003_jr_8015A3C8.o,tail8.data.o,ov_SC03_003_jr_8015AE2C.o,tail9.data.o,ov_SC03_003_jr_8015C32C.o,tail10.data.o,ov_SC03_003_jr_8016AB6C.o,tail11.data.o,ov_SC03_003_jr_801734BC.o,tail12.data.o,ov_SC03_003_jr_80178D40.o,tail13.data.o,ov_SC03_003_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_003/ov_SC03_003_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_003/ov_SC03_003_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_003/ov_SC03_003_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -946,7 +946,7 @@ ov_SC03_007_ELF := $(ov_SC03_007_OUT).elf ov_SC03_007_MAPFILE := $(ov_SC03_007_OUT).map ov_SC03_007_LD_SCRIPT := $(ov_SC03_007_OUT).ld ov_SC03_007_SPLAT_YAML := config/splat.ov_SC03_007.yaml -ov_SC03_007_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_007_jr_8012ACE0.o,tail2.data.o,ov_SC03_007_jr_801380E0.o,tail3.data.o,ov_SC03_007_jr_8013F350.o,tail4.data.o,ov_SC03_007_jr_8013FFD8.o,tail5.data.o,ov_SC03_007_jr_8015444C.o,tail6.data.o,ov_SC03_007_jr_80159C84.o,tail7.data.o,ov_SC03_007_jr_8015A3C8.o,tail8.data.o,ov_SC03_007_jr_8015AE2C.o,tail9.data.o,ov_SC03_007_jr_8016AB6C.o,tail10.data.o,ov_SC03_007_jr_801734BC.o,tail11.data.o,ov_SC03_007_jr_80178D40.o,tail12.data.o,ov_SC03_007_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_007_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_007_jr_8012ACE0.o,tail2.data.o,ov_SC03_007_jr_801380E0.o,tail3.data.o,ov_SC03_007_jr_8013F350.o,tail4.data.o,ov_SC03_007_jr_8013FFD8.o,tail5.data.o,ov_SC03_007_jr_8015444C.o,tail6.data.o,ov_SC03_007_jr_80159C84.o,tail7.data.o,ov_SC03_007_jr_8015A3C8.o,tail8.data.o,ov_SC03_007_jr_8015AE2C.o,tail9.data.o,ov_SC03_007_jr_8015C32C.o,tail10.data.o,ov_SC03_007_jr_8016AB6C.o,tail11.data.o,ov_SC03_007_jr_801734BC.o,tail12.data.o,ov_SC03_007_jr_80178D40.o,tail13.data.o,ov_SC03_007_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_007/ov_SC03_007_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_007/ov_SC03_007_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_007/ov_SC03_007_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -971,7 +971,7 @@ ov_SC03_010_ELF := $(ov_SC03_010_OUT).elf ov_SC03_010_MAPFILE := $(ov_SC03_010_OUT).map ov_SC03_010_LD_SCRIPT := $(ov_SC03_010_OUT).ld ov_SC03_010_SPLAT_YAML := config/splat.ov_SC03_010.yaml -ov_SC03_010_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_010_jr_8012ACE0.o,tail2.data.o,ov_SC03_010_jr_801380E0.o,tail3.data.o,ov_SC03_010_jr_8013F350.o,tail4.data.o,ov_SC03_010_jr_8013FFD8.o,tail5.data.o,ov_SC03_010_jr_8015444C.o,tail6.data.o,ov_SC03_010_jr_80159C84.o,tail7.data.o,ov_SC03_010_jr_8015A3C8.o,tail8.data.o,ov_SC03_010_jr_8015AE2C.o,tail9.data.o,ov_SC03_010_jr_8016AB6C.o,tail10.data.o,ov_SC03_010_jr_801734BC.o,tail11.data.o,ov_SC03_010_jr_80178D40.o,tail12.data.o,ov_SC03_010_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_010_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_010_jr_8012ACE0.o,tail2.data.o,ov_SC03_010_jr_801380E0.o,tail3.data.o,ov_SC03_010_jr_8013F350.o,tail4.data.o,ov_SC03_010_jr_8013FFD8.o,tail5.data.o,ov_SC03_010_jr_8015444C.o,tail6.data.o,ov_SC03_010_jr_80159C84.o,tail7.data.o,ov_SC03_010_jr_8015A3C8.o,tail8.data.o,ov_SC03_010_jr_8015AE2C.o,tail9.data.o,ov_SC03_010_jr_8015C32C.o,tail10.data.o,ov_SC03_010_jr_8016AB6C.o,tail11.data.o,ov_SC03_010_jr_801734BC.o,tail12.data.o,ov_SC03_010_jr_80178D40.o,tail13.data.o,ov_SC03_010_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_010/ov_SC03_010_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_010/ov_SC03_010_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_010/ov_SC03_010_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -996,7 +996,7 @@ ov_SC03_011_ELF := $(ov_SC03_011_OUT).elf ov_SC03_011_MAPFILE := $(ov_SC03_011_OUT).map ov_SC03_011_LD_SCRIPT := $(ov_SC03_011_OUT).ld ov_SC03_011_SPLAT_YAML := config/splat.ov_SC03_011.yaml -ov_SC03_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_011_jr_8012ACE0.o,tail2.data.o,ov_SC03_011_jr_801380E0.o,tail3.data.o,ov_SC03_011_jr_8013F350.o,tail4.data.o,ov_SC03_011_jr_8015444C.o,tail5.data.o,ov_SC03_011_jr_80159C84.o,tail6.data.o,ov_SC03_011_jr_8015A3C8.o,tail7.data.o,ov_SC03_011_jr_8015AE2C.o,tail8.data.o,ov_SC03_011_jr_8016AB6C.o,tail9.data.o,ov_SC03_011_jr_801734BC.o,tail10.data.o,ov_SC03_011_jr_80178D40.o,tail11.data.o,ov_SC03_011_jr_8017A4AC.o,tail12.data.o,ov_SC03_011_jr_8017C730.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_011_jr_8012ACE0.o,tail2.data.o,ov_SC03_011_jr_801380E0.o,tail3.data.o,ov_SC03_011_jr_8013F350.o,tail4.data.o,ov_SC03_011_jr_8015444C.o,tail5.data.o,ov_SC03_011_jr_80159C84.o,tail6.data.o,ov_SC03_011_jr_8015A3C8.o,tail7.data.o,ov_SC03_011_jr_8015AE2C.o,tail8.data.o,ov_SC03_011_jr_8015C32C.o,tail9.data.o,ov_SC03_011_jr_8016AB6C.o,tail10.data.o,ov_SC03_011_jr_801734BC.o,tail11.data.o,ov_SC03_011_jr_80178D40.o,tail12.data.o,ov_SC03_011_jr_8017A4AC.o,tail13.data.o,ov_SC03_011_jr_8017C730.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_011/ov_SC03_011_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_011/ov_SC03_011_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_011/ov_SC03_011_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1021,7 +1021,7 @@ ov_SC03_012_ELF := $(ov_SC03_012_OUT).elf ov_SC03_012_MAPFILE := $(ov_SC03_012_OUT).map ov_SC03_012_LD_SCRIPT := $(ov_SC03_012_OUT).ld ov_SC03_012_SPLAT_YAML := config/splat.ov_SC03_012.yaml -ov_SC03_012_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_012_jr_8012ACE0.o,tail2.data.o,ov_SC03_012_jr_801380E0.o,tail3.data.o,ov_SC03_012_jr_8013F350.o,tail4.data.o,ov_SC03_012_jr_8013FFD8.o,tail5.data.o,ov_SC03_012_jr_8015444C.o,tail6.data.o,ov_SC03_012_jr_80159C84.o,tail7.data.o,ov_SC03_012_jr_8015A3C8.o,tail8.data.o,ov_SC03_012_jr_8015AE2C.o,tail9.data.o,ov_SC03_012_jr_8016AB6C.o,tail10.data.o,ov_SC03_012_jr_801734BC.o,tail11.data.o,ov_SC03_012_jr_80178D40.o,tail12.data.o,ov_SC03_012_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_012_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_012_jr_8012ACE0.o,tail2.data.o,ov_SC03_012_jr_801380E0.o,tail3.data.o,ov_SC03_012_jr_8013F350.o,tail4.data.o,ov_SC03_012_jr_8013FFD8.o,tail5.data.o,ov_SC03_012_jr_8015444C.o,tail6.data.o,ov_SC03_012_jr_80159C84.o,tail7.data.o,ov_SC03_012_jr_8015A3C8.o,tail8.data.o,ov_SC03_012_jr_8015AE2C.o,tail9.data.o,ov_SC03_012_jr_8015C32C.o,tail10.data.o,ov_SC03_012_jr_8016AB6C.o,tail11.data.o,ov_SC03_012_jr_801734BC.o,tail12.data.o,ov_SC03_012_jr_80178D40.o,tail13.data.o,ov_SC03_012_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_012/ov_SC03_012_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_012/ov_SC03_012_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_012/ov_SC03_012_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1046,7 +1046,7 @@ ov_SC03_013_ELF := $(ov_SC03_013_OUT).elf ov_SC03_013_MAPFILE := $(ov_SC03_013_OUT).map ov_SC03_013_LD_SCRIPT := $(ov_SC03_013_OUT).ld ov_SC03_013_SPLAT_YAML := config/splat.ov_SC03_013.yaml -ov_SC03_013_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_013_jr_8012ACE0.o,tail2.data.o,ov_SC03_013_jr_801380E0.o,tail3.data.o,ov_SC03_013_jr_8013F350.o,tail4.data.o,ov_SC03_013_jr_8013FFD8.o,tail5.data.o,ov_SC03_013_jr_8015444C.o,tail6.data.o,ov_SC03_013_jr_80159C84.o,tail7.data.o,ov_SC03_013_jr_8015A3C8.o,tail8.data.o,ov_SC03_013_jr_8015AE2C.o,tail9.data.o,ov_SC03_013_jr_8016AB6C.o,tail10.data.o,ov_SC03_013_jr_801734BC.o,tail11.data.o,ov_SC03_013_jr_80178D40.o,tail12.data.o,ov_SC03_013_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_013_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_013_jr_8012ACE0.o,tail2.data.o,ov_SC03_013_jr_801380E0.o,tail3.data.o,ov_SC03_013_jr_8013F350.o,tail4.data.o,ov_SC03_013_jr_8013FFD8.o,tail5.data.o,ov_SC03_013_jr_8015444C.o,tail6.data.o,ov_SC03_013_jr_80159C84.o,tail7.data.o,ov_SC03_013_jr_8015A3C8.o,tail8.data.o,ov_SC03_013_jr_8015AE2C.o,tail9.data.o,ov_SC03_013_jr_8015C32C.o,tail10.data.o,ov_SC03_013_jr_8016AB6C.o,tail11.data.o,ov_SC03_013_jr_801734BC.o,tail12.data.o,ov_SC03_013_jr_80178D40.o,tail13.data.o,ov_SC03_013_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_013/ov_SC03_013_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_013/ov_SC03_013_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_013/ov_SC03_013_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1071,7 +1071,7 @@ ov_SC03_014_ELF := $(ov_SC03_014_OUT).elf ov_SC03_014_MAPFILE := $(ov_SC03_014_OUT).map ov_SC03_014_LD_SCRIPT := $(ov_SC03_014_OUT).ld ov_SC03_014_SPLAT_YAML := config/splat.ov_SC03_014.yaml -ov_SC03_014_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_014_jr_8012ACE0.o,tail2.data.o,ov_SC03_014_jr_801380E0.o,tail3.data.o,ov_SC03_014_jr_8013F350.o,tail4.data.o,ov_SC03_014_jr_8013FFD8.o,tail5.data.o,ov_SC03_014_jr_8015444C.o,tail6.data.o,ov_SC03_014_jr_80159C84.o,tail7.data.o,ov_SC03_014_jr_8015A3C8.o,tail8.data.o,ov_SC03_014_jr_8015AE2C.o,tail9.data.o,ov_SC03_014_jr_8016AB6C.o,tail10.data.o,ov_SC03_014_jr_801734BC.o,tail11.data.o,ov_SC03_014_jr_80178D40.o,tail12.data.o,ov_SC03_014_jr_8017A4AC.o,tail13.data.o,ov_SC03_014_jr_8017EB7C.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_014_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_014_jr_8012ACE0.o,tail2.data.o,ov_SC03_014_jr_801380E0.o,tail3.data.o,ov_SC03_014_jr_8013F350.o,tail4.data.o,ov_SC03_014_jr_8013FFD8.o,tail5.data.o,ov_SC03_014_jr_8015444C.o,tail6.data.o,ov_SC03_014_jr_80159C84.o,tail7.data.o,ov_SC03_014_jr_8015A3C8.o,tail8.data.o,ov_SC03_014_jr_8015AE2C.o,tail9.data.o,ov_SC03_014_jr_8015C32C.o,tail10.data.o,ov_SC03_014_jr_8016AB6C.o,tail11.data.o,ov_SC03_014_jr_801734BC.o,tail12.data.o,ov_SC03_014_jr_80178D40.o,tail13.data.o,ov_SC03_014_jr_8017A4AC.o,tail14.data.o,ov_SC03_014_jr_8017EB7C.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_014/ov_SC03_014_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_014/ov_SC03_014_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_014/ov_SC03_014_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1096,7 +1096,7 @@ ov_SC03_015_ELF := $(ov_SC03_015_OUT).elf ov_SC03_015_MAPFILE := $(ov_SC03_015_OUT).map ov_SC03_015_LD_SCRIPT := $(ov_SC03_015_OUT).ld ov_SC03_015_SPLAT_YAML := config/splat.ov_SC03_015.yaml -ov_SC03_015_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_015_jr_8012ACE0.o,tail2.data.o,ov_SC03_015_jr_801380E0.o,tail3.data.o,ov_SC03_015_jr_8013F350.o,tail4.data.o,ov_SC03_015_jr_8013FFD8.o,tail5.data.o,ov_SC03_015_jr_8015444C.o,tail6.data.o,ov_SC03_015_jr_80159C84.o,tail7.data.o,ov_SC03_015_jr_8015A3C8.o,tail8.data.o,ov_SC03_015_jr_8015AE2C.o,tail9.data.o,ov_SC03_015_jr_8016AB6C.o,tail10.data.o,ov_SC03_015_jr_801734BC.o,tail11.data.o,ov_SC03_015_jr_80178D40.o,tail12.data.o,ov_SC03_015_jr_8017A4AC.o,tail13.data.o,ov_SC03_015_jr_8017EB7C.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_015_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_015_jr_8012ACE0.o,tail2.data.o,ov_SC03_015_jr_801380E0.o,tail3.data.o,ov_SC03_015_jr_8013F350.o,tail4.data.o,ov_SC03_015_jr_8013FFD8.o,tail5.data.o,ov_SC03_015_jr_8015444C.o,tail6.data.o,ov_SC03_015_jr_80159C84.o,tail7.data.o,ov_SC03_015_jr_8015A3C8.o,tail8.data.o,ov_SC03_015_jr_8015AE2C.o,tail9.data.o,ov_SC03_015_jr_8015C32C.o,tail10.data.o,ov_SC03_015_jr_8016AB6C.o,tail11.data.o,ov_SC03_015_jr_801734BC.o,tail12.data.o,ov_SC03_015_jr_80178D40.o,tail13.data.o,ov_SC03_015_jr_8017A4AC.o,tail14.data.o,ov_SC03_015_jr_8017EB7C.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_015/ov_SC03_015_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_015/ov_SC03_015_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_015/ov_SC03_015_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1121,7 +1121,7 @@ ov_SC03_023_ELF := $(ov_SC03_023_OUT).elf ov_SC03_023_MAPFILE := $(ov_SC03_023_OUT).map ov_SC03_023_LD_SCRIPT := $(ov_SC03_023_OUT).ld ov_SC03_023_SPLAT_YAML := config/splat.ov_SC03_023.yaml -ov_SC03_023_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_023_jr_8012ACE0.o,tail2.data.o,ov_SC03_023_jr_801380E0.o,tail3.data.o,ov_SC03_023_jr_8013F350.o,tail4.data.o,ov_SC03_023_jr_8013FFD8.o,tail5.data.o,ov_SC03_023_jr_8015444C.o,tail6.data.o,ov_SC03_023_jr_80159C84.o,tail7.data.o,ov_SC03_023_jr_8015A3C8.o,tail8.data.o,ov_SC03_023_jr_8015AE2C.o,tail9.data.o,ov_SC03_023_jr_8016AB6C.o,tail10.data.o,ov_SC03_023_jr_801734BC.o,tail11.data.o,ov_SC03_023_jr_80178D40.o,tail12.data.o,ov_SC03_023_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_023_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_023_jr_8012ACE0.o,tail2.data.o,ov_SC03_023_jr_801380E0.o,tail3.data.o,ov_SC03_023_jr_8013F350.o,tail4.data.o,ov_SC03_023_jr_8013FFD8.o,tail5.data.o,ov_SC03_023_jr_8015444C.o,tail6.data.o,ov_SC03_023_jr_80159C84.o,tail7.data.o,ov_SC03_023_jr_8015A3C8.o,tail8.data.o,ov_SC03_023_jr_8015AE2C.o,tail9.data.o,ov_SC03_023_jr_8015C32C.o,tail10.data.o,ov_SC03_023_jr_8016AB6C.o,tail11.data.o,ov_SC03_023_jr_801734BC.o,tail12.data.o,ov_SC03_023_jr_80178D40.o,tail13.data.o,ov_SC03_023_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_023/ov_SC03_023_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_023/ov_SC03_023_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_023/ov_SC03_023_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1146,7 +1146,7 @@ ov_SC03_024_ELF := $(ov_SC03_024_OUT).elf ov_SC03_024_MAPFILE := $(ov_SC03_024_OUT).map ov_SC03_024_LD_SCRIPT := $(ov_SC03_024_OUT).ld ov_SC03_024_SPLAT_YAML := config/splat.ov_SC03_024.yaml -ov_SC03_024_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_024_jr_8012ACE0.o,tail2.data.o,ov_SC03_024_jr_801380E0.o,tail3.data.o,ov_SC03_024_jr_8013F350.o,tail4.data.o,ov_SC03_024_jr_8013FFD8.o,tail5.data.o,ov_SC03_024_jr_8015444C.o,tail6.data.o,ov_SC03_024_jr_80159C84.o,tail7.data.o,ov_SC03_024_jr_8015A3C8.o,tail8.data.o,ov_SC03_024_jr_8015AE2C.o,tail9.data.o,ov_SC03_024_jr_8016AB6C.o,tail10.data.o,ov_SC03_024_jr_801734BC.o,tail11.data.o,ov_SC03_024_jr_80178D40.o,tail12.data.o,ov_SC03_024_jr_8017A4AC.o,tail13.data.o,ov_SC03_024_jr_8017DF84.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_024_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_024_jr_8012ACE0.o,tail2.data.o,ov_SC03_024_jr_801380E0.o,tail3.data.o,ov_SC03_024_jr_8013F350.o,tail4.data.o,ov_SC03_024_jr_8013FFD8.o,tail5.data.o,ov_SC03_024_jr_8015444C.o,tail6.data.o,ov_SC03_024_jr_80159C84.o,tail7.data.o,ov_SC03_024_jr_8015A3C8.o,tail8.data.o,ov_SC03_024_jr_8015AE2C.o,tail9.data.o,ov_SC03_024_jr_8015C32C.o,tail10.data.o,ov_SC03_024_jr_8016AB6C.o,tail11.data.o,ov_SC03_024_jr_801734BC.o,tail12.data.o,ov_SC03_024_jr_80178D40.o,tail13.data.o,ov_SC03_024_jr_8017A4AC.o,tail14.data.o,ov_SC03_024_jr_8017DF84.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_024/ov_SC03_024_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_024/ov_SC03_024_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_024/ov_SC03_024_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1171,7 +1171,7 @@ ov_SC03_028_ELF := $(ov_SC03_028_OUT).elf ov_SC03_028_MAPFILE := $(ov_SC03_028_OUT).map ov_SC03_028_LD_SCRIPT := $(ov_SC03_028_OUT).ld ov_SC03_028_SPLAT_YAML := config/splat.ov_SC03_028.yaml -ov_SC03_028_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_028_jr_8012ACE0.o,tail2.data.o,ov_SC03_028_jr_801380E0.o,tail3.data.o,ov_SC03_028_jr_8013F350.o,tail4.data.o,ov_SC03_028_jr_8013FFD8.o,tail5.data.o,ov_SC03_028_jr_8015444C.o,tail6.data.o,ov_SC03_028_jr_80159C84.o,tail7.data.o,ov_SC03_028_jr_8015A3C8.o,tail8.data.o,ov_SC03_028_jr_8015AE2C.o,tail9.data.o,ov_SC03_028_jr_8016AB6C.o,tail10.data.o,ov_SC03_028_jr_801734BC.o,tail11.data.o,ov_SC03_028_jr_80178D40.o,tail12.data.o,ov_SC03_028_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_028_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_028_jr_8012ACE0.o,tail2.data.o,ov_SC03_028_jr_801380E0.o,tail3.data.o,ov_SC03_028_jr_8013F350.o,tail4.data.o,ov_SC03_028_jr_8013FFD8.o,tail5.data.o,ov_SC03_028_jr_8015444C.o,tail6.data.o,ov_SC03_028_jr_80159C84.o,tail7.data.o,ov_SC03_028_jr_8015A3C8.o,tail8.data.o,ov_SC03_028_jr_8015AE2C.o,tail9.data.o,ov_SC03_028_jr_8015C32C.o,tail10.data.o,ov_SC03_028_jr_8016AB6C.o,tail11.data.o,ov_SC03_028_jr_801734BC.o,tail12.data.o,ov_SC03_028_jr_80178D40.o,tail13.data.o,ov_SC03_028_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_028/ov_SC03_028_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_028/ov_SC03_028_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_028/ov_SC03_028_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1196,7 +1196,7 @@ ov_SC03_029_ELF := $(ov_SC03_029_OUT).elf ov_SC03_029_MAPFILE := $(ov_SC03_029_OUT).map ov_SC03_029_LD_SCRIPT := $(ov_SC03_029_OUT).ld ov_SC03_029_SPLAT_YAML := config/splat.ov_SC03_029.yaml -ov_SC03_029_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_029_jr_8012ACE0.o,tail2.data.o,ov_SC03_029_jr_801380E0.o,tail3.data.o,ov_SC03_029_jr_8013F350.o,tail4.data.o,ov_SC03_029_jr_8013FFD8.o,tail5.data.o,ov_SC03_029_jr_8015444C.o,tail6.data.o,ov_SC03_029_jr_80159C84.o,tail7.data.o,ov_SC03_029_jr_8015A3C8.o,tail8.data.o,ov_SC03_029_jr_8015AE2C.o,tail9.data.o,ov_SC03_029_jr_8016AB6C.o,tail10.data.o,ov_SC03_029_jr_801734BC.o,tail11.data.o,ov_SC03_029_jr_80178D40.o,tail12.data.o,ov_SC03_029_jr_8017A4AC.o,tail13.data.o,ov_SC03_029_jr_8017DC70.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_029_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_029_jr_8012ACE0.o,tail2.data.o,ov_SC03_029_jr_801380E0.o,tail3.data.o,ov_SC03_029_jr_8013F350.o,tail4.data.o,ov_SC03_029_jr_8013FFD8.o,tail5.data.o,ov_SC03_029_jr_8015444C.o,tail6.data.o,ov_SC03_029_jr_80159C84.o,tail7.data.o,ov_SC03_029_jr_8015A3C8.o,tail8.data.o,ov_SC03_029_jr_8015AE2C.o,tail9.data.o,ov_SC03_029_jr_8015C32C.o,tail10.data.o,ov_SC03_029_jr_8016AB6C.o,tail11.data.o,ov_SC03_029_jr_801734BC.o,tail12.data.o,ov_SC03_029_jr_80178D40.o,tail13.data.o,ov_SC03_029_jr_8017A4AC.o,tail14.data.o,ov_SC03_029_jr_8017DC70.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_029/ov_SC03_029_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_029/ov_SC03_029_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_029/ov_SC03_029_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1221,7 +1221,7 @@ ov_SC03_030_ELF := $(ov_SC03_030_OUT).elf ov_SC03_030_MAPFILE := $(ov_SC03_030_OUT).map ov_SC03_030_LD_SCRIPT := $(ov_SC03_030_OUT).ld ov_SC03_030_SPLAT_YAML := config/splat.ov_SC03_030.yaml -ov_SC03_030_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_030_jr_8012ACE0.o,tail2.data.o,ov_SC03_030_jr_801380E0.o,tail3.data.o,ov_SC03_030_jr_8013F350.o,tail4.data.o,ov_SC03_030_jr_8015444C.o,tail5.data.o,ov_SC03_030_jr_80159C84.o,tail6.data.o,ov_SC03_030_jr_8015A3C8.o,tail7.data.o,ov_SC03_030_jr_8015AE2C.o,tail8.data.o,ov_SC03_030_jr_8016AB6C.o,tail9.data.o,ov_SC03_030_jr_801734BC.o,tail10.data.o,ov_SC03_030_jr_80178D40.o,tail11.data.o,ov_SC03_030_jr_8017A4AC.o,tail12.data.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_030_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_030_jr_8012ACE0.o,tail2.data.o,ov_SC03_030_jr_801380E0.o,tail3.data.o,ov_SC03_030_jr_8013F350.o,tail4.data.o,ov_SC03_030_jr_8015444C.o,tail5.data.o,ov_SC03_030_jr_80159C84.o,tail6.data.o,ov_SC03_030_jr_8015A3C8.o,tail7.data.o,ov_SC03_030_jr_8015AE2C.o,tail8.data.o,ov_SC03_030_jr_8015C32C.o,tail9.data.o,ov_SC03_030_jr_8016AB6C.o,tail10.data.o,ov_SC03_030_jr_801734BC.o,tail11.data.o,ov_SC03_030_jr_80178D40.o,tail12.data.o,ov_SC03_030_jr_8017A4AC.o,tail13.data.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_030/ov_SC03_030_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_030/ov_SC03_030_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_030/ov_SC03_030_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1246,7 +1246,7 @@ ov_SC03_031_ELF := $(ov_SC03_031_OUT).elf ov_SC03_031_MAPFILE := $(ov_SC03_031_OUT).map ov_SC03_031_LD_SCRIPT := $(ov_SC03_031_OUT).ld ov_SC03_031_SPLAT_YAML := config/splat.ov_SC03_031.yaml -ov_SC03_031_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_031_jr_8012ACE0.o,tail2.data.o,ov_SC03_031_jr_801380E0.o,tail3.data.o,ov_SC03_031_jr_8013F350.o,tail4.data.o,ov_SC03_031_jr_8013FFD8.o,tail5.data.o,ov_SC03_031_jr_8015444C.o,tail6.data.o,ov_SC03_031_jr_80159C84.o,tail7.data.o,ov_SC03_031_jr_8015A3C8.o,tail8.data.o,ov_SC03_031_jr_8015AE2C.o,tail9.data.o,ov_SC03_031_jr_8016AB6C.o,tail10.data.o,ov_SC03_031_jr_801734BC.o,tail11.data.o,ov_SC03_031_jr_80178D40.o,tail12.data.o,ov_SC03_031_jr_8017A4AC.o,tail13.data.o,ov_SC03_031_jr_8017DB5C.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_031_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_031_jr_8012ACE0.o,tail2.data.o,ov_SC03_031_jr_801380E0.o,tail3.data.o,ov_SC03_031_jr_8013F350.o,tail4.data.o,ov_SC03_031_jr_8013FFD8.o,tail5.data.o,ov_SC03_031_jr_8015444C.o,tail6.data.o,ov_SC03_031_jr_80159C84.o,tail7.data.o,ov_SC03_031_jr_8015A3C8.o,tail8.data.o,ov_SC03_031_jr_8015AE2C.o,tail9.data.o,ov_SC03_031_jr_8015C32C.o,tail10.data.o,ov_SC03_031_jr_8016AB6C.o,tail11.data.o,ov_SC03_031_jr_801734BC.o,tail12.data.o,ov_SC03_031_jr_80178D40.o,tail13.data.o,ov_SC03_031_jr_8017A4AC.o,tail14.data.o,ov_SC03_031_jr_8017DB5C.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_031/ov_SC03_031_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_031/ov_SC03_031_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_031/ov_SC03_031_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1271,7 +1271,7 @@ ov_SC03_089_ELF := $(ov_SC03_089_OUT).elf ov_SC03_089_MAPFILE := $(ov_SC03_089_OUT).map ov_SC03_089_LD_SCRIPT := $(ov_SC03_089_OUT).ld ov_SC03_089_SPLAT_YAML := config/splat.ov_SC03_089.yaml -ov_SC03_089_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_089_jr_8012ACE0.o,tail2.data.o,ov_SC03_089_jr_801380E0.o,tail3.data.o,ov_SC03_089_jr_8013F350.o,tail4.data.o,ov_SC03_089_jr_8013FFD8.o,tail5.data.o,ov_SC03_089_jr_8015444C.o,tail6.data.o,ov_SC03_089_jr_80159C84.o,tail7.data.o,ov_SC03_089_jr_8015A3C8.o,tail8.data.o,ov_SC03_089_jr_8015AE2C.o,tail9.data.o,ov_SC03_089_jr_8016AB6C.o,tail10.data.o,ov_SC03_089_jr_801734BC.o,tail11.data.o,ov_SC03_089_jr_80178D40.o,tail12.data.o,ov_SC03_089_jr_8017A4AC.o,tail13.data.o,ov_SC03_089_jr_8017CA80.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_089_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_089_jr_8012ACE0.o,tail2.data.o,ov_SC03_089_jr_801380E0.o,tail3.data.o,ov_SC03_089_jr_8013F350.o,tail4.data.o,ov_SC03_089_jr_8013FFD8.o,tail5.data.o,ov_SC03_089_jr_8015444C.o,tail6.data.o,ov_SC03_089_jr_80159C84.o,tail7.data.o,ov_SC03_089_jr_8015A3C8.o,tail8.data.o,ov_SC03_089_jr_8015AE2C.o,tail9.data.o,ov_SC03_089_jr_8015C32C.o,tail10.data.o,ov_SC03_089_jr_8016AB6C.o,tail11.data.o,ov_SC03_089_jr_801734BC.o,tail12.data.o,ov_SC03_089_jr_80178D40.o,tail13.data.o,ov_SC03_089_jr_8017A4AC.o,tail14.data.o,ov_SC03_089_jr_8017CA80.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_089/ov_SC03_089_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_089/ov_SC03_089_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_089/ov_SC03_089_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1296,7 +1296,7 @@ ov_SC03_090_ELF := $(ov_SC03_090_OUT).elf ov_SC03_090_MAPFILE := $(ov_SC03_090_OUT).map ov_SC03_090_LD_SCRIPT := $(ov_SC03_090_OUT).ld ov_SC03_090_SPLAT_YAML := config/splat.ov_SC03_090.yaml -ov_SC03_090_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_090_jr_8012ACE0.o,tail2.data.o,ov_SC03_090_jr_801380E0.o,tail3.data.o,ov_SC03_090_jr_8013F350.o,tail4.data.o,ov_SC03_090_jr_8013FFD8.o,tail5.data.o,ov_SC03_090_jr_8015444C.o,tail6.data.o,ov_SC03_090_jr_80159C84.o,tail7.data.o,ov_SC03_090_jr_8015A3C8.o,tail8.data.o,ov_SC03_090_jr_8015AE2C.o,tail9.data.o,ov_SC03_090_jr_8016AB6C.o,tail10.data.o,ov_SC03_090_jr_801734BC.o,tail11.data.o,ov_SC03_090_jr_80178D40.o,tail12.data.o,ov_SC03_090_jr_8017A4AC.o,tail13.data.o,ov_SC03_090_jr_8017CA80.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_090_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_090_jr_8012ACE0.o,tail2.data.o,ov_SC03_090_jr_801380E0.o,tail3.data.o,ov_SC03_090_jr_8013F350.o,tail4.data.o,ov_SC03_090_jr_8013FFD8.o,tail5.data.o,ov_SC03_090_jr_8015444C.o,tail6.data.o,ov_SC03_090_jr_80159C84.o,tail7.data.o,ov_SC03_090_jr_8015A3C8.o,tail8.data.o,ov_SC03_090_jr_8015AE2C.o,tail9.data.o,ov_SC03_090_jr_8015C32C.o,tail10.data.o,ov_SC03_090_jr_8016AB6C.o,tail11.data.o,ov_SC03_090_jr_801734BC.o,tail12.data.o,ov_SC03_090_jr_80178D40.o,tail13.data.o,ov_SC03_090_jr_8017A4AC.o,tail14.data.o,ov_SC03_090_jr_8017CA80.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_090/ov_SC03_090_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_090/ov_SC03_090_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_090/ov_SC03_090_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1321,7 +1321,7 @@ ov_SC03_091_ELF := $(ov_SC03_091_OUT).elf ov_SC03_091_MAPFILE := $(ov_SC03_091_OUT).map ov_SC03_091_LD_SCRIPT := $(ov_SC03_091_OUT).ld ov_SC03_091_SPLAT_YAML := config/splat.ov_SC03_091.yaml -ov_SC03_091_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_091_jr_8012ACE0.o,tail2.data.o,ov_SC03_091_jr_801380E0.o,tail3.data.o,ov_SC03_091_jr_8013F350.o,tail4.data.o,ov_SC03_091_jr_8013FFD8.o,tail5.data.o,ov_SC03_091_jr_8015444C.o,tail6.data.o,ov_SC03_091_jr_80159C84.o,tail7.data.o,ov_SC03_091_jr_8015A3C8.o,tail8.data.o,ov_SC03_091_jr_8015AE2C.o,tail9.data.o,ov_SC03_091_jr_8016AB6C.o,tail10.data.o,ov_SC03_091_jr_801734BC.o,tail11.data.o,ov_SC03_091_jr_80178D40.o,tail12.data.o,ov_SC03_091_jr_8017A4AC.o,tail13.data.o,ov_SC03_091_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_091_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_091_jr_8012ACE0.o,tail2.data.o,ov_SC03_091_jr_801380E0.o,tail3.data.o,ov_SC03_091_jr_8013F350.o,tail4.data.o,ov_SC03_091_jr_8013FFD8.o,tail5.data.o,ov_SC03_091_jr_8015444C.o,tail6.data.o,ov_SC03_091_jr_80159C84.o,tail7.data.o,ov_SC03_091_jr_8015A3C8.o,tail8.data.o,ov_SC03_091_jr_8015AE2C.o,tail9.data.o,ov_SC03_091_jr_8015C32C.o,tail10.data.o,ov_SC03_091_jr_8016AB6C.o,tail11.data.o,ov_SC03_091_jr_801734BC.o,tail12.data.o,ov_SC03_091_jr_80178D40.o,tail13.data.o,ov_SC03_091_jr_8017A4AC.o,tail14.data.o,ov_SC03_091_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_091/ov_SC03_091_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_091/ov_SC03_091_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_091/ov_SC03_091_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1346,7 +1346,7 @@ ov_SC03_092_ELF := $(ov_SC03_092_OUT).elf ov_SC03_092_MAPFILE := $(ov_SC03_092_OUT).map ov_SC03_092_LD_SCRIPT := $(ov_SC03_092_OUT).ld ov_SC03_092_SPLAT_YAML := config/splat.ov_SC03_092.yaml -ov_SC03_092_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_092_jr_8012ACE0.o,tail2.data.o,ov_SC03_092_jr_801380E0.o,tail3.data.o,ov_SC03_092_jr_8013F350.o,tail4.data.o,ov_SC03_092_jr_8013FFD8.o,tail5.data.o,ov_SC03_092_jr_8015444C.o,tail6.data.o,ov_SC03_092_jr_80159C84.o,tail7.data.o,ov_SC03_092_jr_8015A3C8.o,tail8.data.o,ov_SC03_092_jr_8015AE2C.o,tail9.data.o,ov_SC03_092_jr_8016AB6C.o,tail10.data.o,ov_SC03_092_jr_801734BC.o,tail11.data.o,ov_SC03_092_jr_80178D40.o,tail12.data.o,ov_SC03_092_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_092_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_092_jr_8012ACE0.o,tail2.data.o,ov_SC03_092_jr_801380E0.o,tail3.data.o,ov_SC03_092_jr_8013F350.o,tail4.data.o,ov_SC03_092_jr_8013FFD8.o,tail5.data.o,ov_SC03_092_jr_8015444C.o,tail6.data.o,ov_SC03_092_jr_80159C84.o,tail7.data.o,ov_SC03_092_jr_8015A3C8.o,tail8.data.o,ov_SC03_092_jr_8015AE2C.o,tail9.data.o,ov_SC03_092_jr_8015C32C.o,tail10.data.o,ov_SC03_092_jr_8016AB6C.o,tail11.data.o,ov_SC03_092_jr_801734BC.o,tail12.data.o,ov_SC03_092_jr_80178D40.o,tail13.data.o,ov_SC03_092_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_092/ov_SC03_092_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_092/ov_SC03_092_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_092/ov_SC03_092_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1371,7 +1371,7 @@ ov_SC03_093_ELF := $(ov_SC03_093_OUT).elf ov_SC03_093_MAPFILE := $(ov_SC03_093_OUT).map ov_SC03_093_LD_SCRIPT := $(ov_SC03_093_OUT).ld ov_SC03_093_SPLAT_YAML := config/splat.ov_SC03_093.yaml -ov_SC03_093_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_093_jr_8012ACE0.o,tail2.data.o,ov_SC03_093_jr_801380E0.o,tail3.data.o,ov_SC03_093_jr_8013F350.o,tail4.data.o,ov_SC03_093_jr_8013FFD8.o,tail5.data.o,ov_SC03_093_jr_8015444C.o,tail6.data.o,ov_SC03_093_jr_80159C84.o,tail7.data.o,ov_SC03_093_jr_8015A3C8.o,tail8.data.o,ov_SC03_093_jr_8015AE2C.o,tail9.data.o,ov_SC03_093_jr_8016AB6C.o,tail10.data.o,ov_SC03_093_jr_801734BC.o,tail11.data.o,ov_SC03_093_jr_80178D40.o,tail12.data.o,ov_SC03_093_jr_8017A4AC.o,tail13.data.o,ov_SC03_093_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_093_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_093_jr_8012ACE0.o,tail2.data.o,ov_SC03_093_jr_801380E0.o,tail3.data.o,ov_SC03_093_jr_8013F350.o,tail4.data.o,ov_SC03_093_jr_8013FFD8.o,tail5.data.o,ov_SC03_093_jr_8015444C.o,tail6.data.o,ov_SC03_093_jr_80159C84.o,tail7.data.o,ov_SC03_093_jr_8015A3C8.o,tail8.data.o,ov_SC03_093_jr_8015AE2C.o,tail9.data.o,ov_SC03_093_jr_8015C32C.o,tail10.data.o,ov_SC03_093_jr_8016AB6C.o,tail11.data.o,ov_SC03_093_jr_801734BC.o,tail12.data.o,ov_SC03_093_jr_80178D40.o,tail13.data.o,ov_SC03_093_jr_8017A4AC.o,tail14.data.o,ov_SC03_093_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_093/ov_SC03_093_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_093/ov_SC03_093_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_093/ov_SC03_093_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1396,7 +1396,7 @@ ov_SC03_094_ELF := $(ov_SC03_094_OUT).elf ov_SC03_094_MAPFILE := $(ov_SC03_094_OUT).map ov_SC03_094_LD_SCRIPT := $(ov_SC03_094_OUT).ld ov_SC03_094_SPLAT_YAML := config/splat.ov_SC03_094.yaml -ov_SC03_094_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_094_jr_8012ACE0.o,tail2.data.o,ov_SC03_094_jr_801380E0.o,tail3.data.o,ov_SC03_094_jr_8013F350.o,tail4.data.o,ov_SC03_094_jr_8013FFD8.o,tail5.data.o,ov_SC03_094_jr_8015444C.o,tail6.data.o,ov_SC03_094_jr_80159C84.o,tail7.data.o,ov_SC03_094_jr_8015A3C8.o,tail8.data.o,ov_SC03_094_jr_8015AE2C.o,tail9.data.o,ov_SC03_094_jr_8016AB6C.o,tail10.data.o,ov_SC03_094_jr_801734BC.o,tail11.data.o,ov_SC03_094_jr_80178D40.o,tail12.data.o,ov_SC03_094_jr_8017A4AC.o,tail13.data.o,ov_SC03_094_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_094_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_094_jr_8012ACE0.o,tail2.data.o,ov_SC03_094_jr_801380E0.o,tail3.data.o,ov_SC03_094_jr_8013F350.o,tail4.data.o,ov_SC03_094_jr_8013FFD8.o,tail5.data.o,ov_SC03_094_jr_8015444C.o,tail6.data.o,ov_SC03_094_jr_80159C84.o,tail7.data.o,ov_SC03_094_jr_8015A3C8.o,tail8.data.o,ov_SC03_094_jr_8015AE2C.o,tail9.data.o,ov_SC03_094_jr_8015C32C.o,tail10.data.o,ov_SC03_094_jr_8016AB6C.o,tail11.data.o,ov_SC03_094_jr_801734BC.o,tail12.data.o,ov_SC03_094_jr_80178D40.o,tail13.data.o,ov_SC03_094_jr_8017A4AC.o,tail14.data.o,ov_SC03_094_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_094/ov_SC03_094_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_094/ov_SC03_094_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_094/ov_SC03_094_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1421,7 +1421,7 @@ ov_SC03_095_ELF := $(ov_SC03_095_OUT).elf ov_SC03_095_MAPFILE := $(ov_SC03_095_OUT).map ov_SC03_095_LD_SCRIPT := $(ov_SC03_095_OUT).ld ov_SC03_095_SPLAT_YAML := config/splat.ov_SC03_095.yaml -ov_SC03_095_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_095_jr_8012ACE0.o,tail2.data.o,ov_SC03_095_jr_801380E0.o,tail3.data.o,ov_SC03_095_jr_8013F350.o,tail4.data.o,ov_SC03_095_jr_8013FFD8.o,tail5.data.o,ov_SC03_095_jr_8015444C.o,tail6.data.o,ov_SC03_095_jr_80159C84.o,tail7.data.o,ov_SC03_095_jr_8015A3C8.o,tail8.data.o,ov_SC03_095_jr_8015AE2C.o,tail9.data.o,ov_SC03_095_jr_8016AB6C.o,tail10.data.o,ov_SC03_095_jr_801734BC.o,tail11.data.o,ov_SC03_095_jr_80178D40.o,tail12.data.o,ov_SC03_095_jr_8017A4AC.o,tail13.data.o,ov_SC03_095_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_095_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_095_jr_8012ACE0.o,tail2.data.o,ov_SC03_095_jr_801380E0.o,tail3.data.o,ov_SC03_095_jr_8013F350.o,tail4.data.o,ov_SC03_095_jr_8013FFD8.o,tail5.data.o,ov_SC03_095_jr_8015444C.o,tail6.data.o,ov_SC03_095_jr_80159C84.o,tail7.data.o,ov_SC03_095_jr_8015A3C8.o,tail8.data.o,ov_SC03_095_jr_8015AE2C.o,tail9.data.o,ov_SC03_095_jr_8015C32C.o,tail10.data.o,ov_SC03_095_jr_8016AB6C.o,tail11.data.o,ov_SC03_095_jr_801734BC.o,tail12.data.o,ov_SC03_095_jr_80178D40.o,tail13.data.o,ov_SC03_095_jr_8017A4AC.o,tail14.data.o,ov_SC03_095_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_095/ov_SC03_095_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_095/ov_SC03_095_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_095/ov_SC03_095_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1446,7 +1446,7 @@ ov_SC03_096_ELF := $(ov_SC03_096_OUT).elf ov_SC03_096_MAPFILE := $(ov_SC03_096_OUT).map ov_SC03_096_LD_SCRIPT := $(ov_SC03_096_OUT).ld ov_SC03_096_SPLAT_YAML := config/splat.ov_SC03_096.yaml -ov_SC03_096_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_096_jr_8012ACE0.o,tail2.data.o,ov_SC03_096_jr_801380E0.o,tail3.data.o,ov_SC03_096_jr_8013F350.o,tail4.data.o,ov_SC03_096_jr_8013FFD8.o,tail5.data.o,ov_SC03_096_jr_8015444C.o,tail6.data.o,ov_SC03_096_jr_80159C84.o,tail7.data.o,ov_SC03_096_jr_8015A3C8.o,tail8.data.o,ov_SC03_096_jr_8015AE2C.o,tail9.data.o,ov_SC03_096_jr_8016AB6C.o,tail10.data.o,ov_SC03_096_jr_801734BC.o,tail11.data.o,ov_SC03_096_jr_80178D40.o,tail12.data.o,ov_SC03_096_jr_8017A4AC.o,tail13.data.o,ov_SC03_096_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_096_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_096_jr_8012ACE0.o,tail2.data.o,ov_SC03_096_jr_801380E0.o,tail3.data.o,ov_SC03_096_jr_8013F350.o,tail4.data.o,ov_SC03_096_jr_8013FFD8.o,tail5.data.o,ov_SC03_096_jr_8015444C.o,tail6.data.o,ov_SC03_096_jr_80159C84.o,tail7.data.o,ov_SC03_096_jr_8015A3C8.o,tail8.data.o,ov_SC03_096_jr_8015AE2C.o,tail9.data.o,ov_SC03_096_jr_8015C32C.o,tail10.data.o,ov_SC03_096_jr_8016AB6C.o,tail11.data.o,ov_SC03_096_jr_801734BC.o,tail12.data.o,ov_SC03_096_jr_80178D40.o,tail13.data.o,ov_SC03_096_jr_8017A4AC.o,tail14.data.o,ov_SC03_096_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_096/ov_SC03_096_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_096/ov_SC03_096_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_096/ov_SC03_096_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1471,7 +1471,7 @@ ov_SC03_097_ELF := $(ov_SC03_097_OUT).elf ov_SC03_097_MAPFILE := $(ov_SC03_097_OUT).map ov_SC03_097_LD_SCRIPT := $(ov_SC03_097_OUT).ld ov_SC03_097_SPLAT_YAML := config/splat.ov_SC03_097.yaml -ov_SC03_097_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_097_jr_8012ACE0.o,tail2.data.o,ov_SC03_097_jr_801380E0.o,tail3.data.o,ov_SC03_097_jr_8013F350.o,tail4.data.o,ov_SC03_097_jr_8013FFD8.o,tail5.data.o,ov_SC03_097_jr_8015444C.o,tail6.data.o,ov_SC03_097_jr_80159C84.o,tail7.data.o,ov_SC03_097_jr_8015A3C8.o,tail8.data.o,ov_SC03_097_jr_8015AE2C.o,tail9.data.o,ov_SC03_097_jr_8016AB6C.o,tail10.data.o,ov_SC03_097_jr_801734BC.o,tail11.data.o,ov_SC03_097_jr_80178D40.o,tail12.data.o,ov_SC03_097_jr_8017A4AC.o,tail13.data.o,ov_SC03_097_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_097_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_097_jr_8012ACE0.o,tail2.data.o,ov_SC03_097_jr_801380E0.o,tail3.data.o,ov_SC03_097_jr_8013F350.o,tail4.data.o,ov_SC03_097_jr_8013FFD8.o,tail5.data.o,ov_SC03_097_jr_8015444C.o,tail6.data.o,ov_SC03_097_jr_80159C84.o,tail7.data.o,ov_SC03_097_jr_8015A3C8.o,tail8.data.o,ov_SC03_097_jr_8015AE2C.o,tail9.data.o,ov_SC03_097_jr_8015C32C.o,tail10.data.o,ov_SC03_097_jr_8016AB6C.o,tail11.data.o,ov_SC03_097_jr_801734BC.o,tail12.data.o,ov_SC03_097_jr_80178D40.o,tail13.data.o,ov_SC03_097_jr_8017A4AC.o,tail14.data.o,ov_SC03_097_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_097/ov_SC03_097_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_097/ov_SC03_097_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_097/ov_SC03_097_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1496,7 +1496,7 @@ ov_SC03_098_ELF := $(ov_SC03_098_OUT).elf ov_SC03_098_MAPFILE := $(ov_SC03_098_OUT).map ov_SC03_098_LD_SCRIPT := $(ov_SC03_098_OUT).ld ov_SC03_098_SPLAT_YAML := config/splat.ov_SC03_098.yaml -ov_SC03_098_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_098_jr_8012ACE0.o,tail2.data.o,ov_SC03_098_jr_801380E0.o,tail3.data.o,ov_SC03_098_jr_8013F350.o,tail4.data.o,ov_SC03_098_jr_8013FFD8.o,tail5.data.o,ov_SC03_098_jr_8015444C.o,tail6.data.o,ov_SC03_098_jr_80159C84.o,tail7.data.o,ov_SC03_098_jr_8015A3C8.o,tail8.data.o,ov_SC03_098_jr_8015AE2C.o,tail9.data.o,ov_SC03_098_jr_8016AB6C.o,tail10.data.o,ov_SC03_098_jr_801734BC.o,tail11.data.o,ov_SC03_098_jr_80178D40.o,tail12.data.o,ov_SC03_098_jr_8017A4AC.o,tail13.data.o,ov_SC03_098_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_098_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_098_jr_8012ACE0.o,tail2.data.o,ov_SC03_098_jr_801380E0.o,tail3.data.o,ov_SC03_098_jr_8013F350.o,tail4.data.o,ov_SC03_098_jr_8013FFD8.o,tail5.data.o,ov_SC03_098_jr_8015444C.o,tail6.data.o,ov_SC03_098_jr_80159C84.o,tail7.data.o,ov_SC03_098_jr_8015A3C8.o,tail8.data.o,ov_SC03_098_jr_8015AE2C.o,tail9.data.o,ov_SC03_098_jr_8015C32C.o,tail10.data.o,ov_SC03_098_jr_8016AB6C.o,tail11.data.o,ov_SC03_098_jr_801734BC.o,tail12.data.o,ov_SC03_098_jr_80178D40.o,tail13.data.o,ov_SC03_098_jr_8017A4AC.o,tail14.data.o,ov_SC03_098_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_098/ov_SC03_098_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_098/ov_SC03_098_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_098/ov_SC03_098_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1521,7 +1521,7 @@ ov_SC03_099_ELF := $(ov_SC03_099_OUT).elf ov_SC03_099_MAPFILE := $(ov_SC03_099_OUT).map ov_SC03_099_LD_SCRIPT := $(ov_SC03_099_OUT).ld ov_SC03_099_SPLAT_YAML := config/splat.ov_SC03_099.yaml -ov_SC03_099_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_099_jr_8012ACE0.o,tail2.data.o,ov_SC03_099_jr_801380E0.o,tail3.data.o,ov_SC03_099_jr_8013F350.o,tail4.data.o,ov_SC03_099_jr_8013FFD8.o,tail5.data.o,ov_SC03_099_jr_8015444C.o,tail6.data.o,ov_SC03_099_jr_80159C84.o,tail7.data.o,ov_SC03_099_jr_8015A3C8.o,tail8.data.o,ov_SC03_099_jr_8015AE2C.o,tail9.data.o,ov_SC03_099_jr_8016AB6C.o,tail10.data.o,ov_SC03_099_jr_801734BC.o,tail11.data.o,ov_SC03_099_jr_80178D40.o,tail12.data.o,ov_SC03_099_jr_8017A4AC.o,tail13.data.o,ov_SC03_099_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_099_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_099_jr_8012ACE0.o,tail2.data.o,ov_SC03_099_jr_801380E0.o,tail3.data.o,ov_SC03_099_jr_8013F350.o,tail4.data.o,ov_SC03_099_jr_8013FFD8.o,tail5.data.o,ov_SC03_099_jr_8015444C.o,tail6.data.o,ov_SC03_099_jr_80159C84.o,tail7.data.o,ov_SC03_099_jr_8015A3C8.o,tail8.data.o,ov_SC03_099_jr_8015AE2C.o,tail9.data.o,ov_SC03_099_jr_8015C32C.o,tail10.data.o,ov_SC03_099_jr_8016AB6C.o,tail11.data.o,ov_SC03_099_jr_801734BC.o,tail12.data.o,ov_SC03_099_jr_80178D40.o,tail13.data.o,ov_SC03_099_jr_8017A4AC.o,tail14.data.o,ov_SC03_099_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_099/ov_SC03_099_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_099/ov_SC03_099_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_099/ov_SC03_099_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1546,7 +1546,7 @@ ov_SC03_100_ELF := $(ov_SC03_100_OUT).elf ov_SC03_100_MAPFILE := $(ov_SC03_100_OUT).map ov_SC03_100_LD_SCRIPT := $(ov_SC03_100_OUT).ld ov_SC03_100_SPLAT_YAML := config/splat.ov_SC03_100.yaml -ov_SC03_100_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_100_jr_8012ACE0.o,tail2.data.o,ov_SC03_100_jr_801380E0.o,tail3.data.o,ov_SC03_100_jr_8013F350.o,tail4.data.o,ov_SC03_100_jr_8013FFD8.o,tail5.data.o,ov_SC03_100_jr_8015444C.o,tail6.data.o,ov_SC03_100_jr_80159C84.o,tail7.data.o,ov_SC03_100_jr_8015A3C8.o,tail8.data.o,ov_SC03_100_jr_8015AE2C.o,tail9.data.o,ov_SC03_100_jr_8016AB6C.o,tail10.data.o,ov_SC03_100_jr_801734BC.o,tail11.data.o,ov_SC03_100_jr_80178D40.o,tail12.data.o,ov_SC03_100_jr_8017A4AC.o,tail13.data.o,ov_SC03_100_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_100_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_100_jr_8012ACE0.o,tail2.data.o,ov_SC03_100_jr_801380E0.o,tail3.data.o,ov_SC03_100_jr_8013F350.o,tail4.data.o,ov_SC03_100_jr_8013FFD8.o,tail5.data.o,ov_SC03_100_jr_8015444C.o,tail6.data.o,ov_SC03_100_jr_80159C84.o,tail7.data.o,ov_SC03_100_jr_8015A3C8.o,tail8.data.o,ov_SC03_100_jr_8015AE2C.o,tail9.data.o,ov_SC03_100_jr_8015C32C.o,tail10.data.o,ov_SC03_100_jr_8016AB6C.o,tail11.data.o,ov_SC03_100_jr_801734BC.o,tail12.data.o,ov_SC03_100_jr_80178D40.o,tail13.data.o,ov_SC03_100_jr_8017A4AC.o,tail14.data.o,ov_SC03_100_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_100/ov_SC03_100_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_100/ov_SC03_100_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_100/ov_SC03_100_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1571,7 +1571,7 @@ ov_SC03_101_ELF := $(ov_SC03_101_OUT).elf ov_SC03_101_MAPFILE := $(ov_SC03_101_OUT).map ov_SC03_101_LD_SCRIPT := $(ov_SC03_101_OUT).ld ov_SC03_101_SPLAT_YAML := config/splat.ov_SC03_101.yaml -ov_SC03_101_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_101_jr_8012ACE0.o,tail2.data.o,ov_SC03_101_jr_801380E0.o,tail3.data.o,ov_SC03_101_jr_8013F350.o,tail4.data.o,ov_SC03_101_jr_8013FFD8.o,tail5.data.o,ov_SC03_101_jr_8015444C.o,tail6.data.o,ov_SC03_101_jr_80159C84.o,tail7.data.o,ov_SC03_101_jr_8015A3C8.o,tail8.data.o,ov_SC03_101_jr_8015AE2C.o,tail9.data.o,ov_SC03_101_jr_8016AB6C.o,tail10.data.o,ov_SC03_101_jr_801734BC.o,tail11.data.o,ov_SC03_101_jr_80178D40.o,tail12.data.o,ov_SC03_101_jr_8017A4AC.o,tail13.data.o,ov_SC03_101_jr_8017CA80.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_101_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_101_jr_8012ACE0.o,tail2.data.o,ov_SC03_101_jr_801380E0.o,tail3.data.o,ov_SC03_101_jr_8013F350.o,tail4.data.o,ov_SC03_101_jr_8013FFD8.o,tail5.data.o,ov_SC03_101_jr_8015444C.o,tail6.data.o,ov_SC03_101_jr_80159C84.o,tail7.data.o,ov_SC03_101_jr_8015A3C8.o,tail8.data.o,ov_SC03_101_jr_8015AE2C.o,tail9.data.o,ov_SC03_101_jr_8015C32C.o,tail10.data.o,ov_SC03_101_jr_8016AB6C.o,tail11.data.o,ov_SC03_101_jr_801734BC.o,tail12.data.o,ov_SC03_101_jr_80178D40.o,tail13.data.o,ov_SC03_101_jr_8017A4AC.o,tail14.data.o,ov_SC03_101_jr_8017CA80.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_101/ov_SC03_101_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_101/ov_SC03_101_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_101/ov_SC03_101_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1596,7 +1596,7 @@ ov_SC03_102_ELF := $(ov_SC03_102_OUT).elf ov_SC03_102_MAPFILE := $(ov_SC03_102_OUT).map ov_SC03_102_LD_SCRIPT := $(ov_SC03_102_OUT).ld ov_SC03_102_SPLAT_YAML := config/splat.ov_SC03_102.yaml -ov_SC03_102_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_102_jr_8012ACE0.o,tail2.data.o,ov_SC03_102_jr_801380E0.o,tail3.data.o,ov_SC03_102_jr_8013F350.o,tail4.data.o,ov_SC03_102_jr_8013FFD8.o,tail5.data.o,ov_SC03_102_jr_8015444C.o,tail6.data.o,ov_SC03_102_jr_80159C84.o,tail7.data.o,ov_SC03_102_jr_8015A3C8.o,tail8.data.o,ov_SC03_102_jr_8015AE2C.o,tail9.data.o,ov_SC03_102_jr_8016AB6C.o,tail10.data.o,ov_SC03_102_jr_801734BC.o,tail11.data.o,ov_SC03_102_jr_80178D40.o,tail12.data.o,ov_SC03_102_jr_8017A4AC.o,tail13.data.o,ov_SC03_102_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_102_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_102_jr_8012ACE0.o,tail2.data.o,ov_SC03_102_jr_801380E0.o,tail3.data.o,ov_SC03_102_jr_8013F350.o,tail4.data.o,ov_SC03_102_jr_8013FFD8.o,tail5.data.o,ov_SC03_102_jr_8015444C.o,tail6.data.o,ov_SC03_102_jr_80159C84.o,tail7.data.o,ov_SC03_102_jr_8015A3C8.o,tail8.data.o,ov_SC03_102_jr_8015AE2C.o,tail9.data.o,ov_SC03_102_jr_8015C32C.o,tail10.data.o,ov_SC03_102_jr_8016AB6C.o,tail11.data.o,ov_SC03_102_jr_801734BC.o,tail12.data.o,ov_SC03_102_jr_80178D40.o,tail13.data.o,ov_SC03_102_jr_8017A4AC.o,tail14.data.o,ov_SC03_102_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_102/ov_SC03_102_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_102/ov_SC03_102_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_102/ov_SC03_102_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1621,7 +1621,7 @@ ov_SC03_103_ELF := $(ov_SC03_103_OUT).elf ov_SC03_103_MAPFILE := $(ov_SC03_103_OUT).map ov_SC03_103_LD_SCRIPT := $(ov_SC03_103_OUT).ld ov_SC03_103_SPLAT_YAML := config/splat.ov_SC03_103.yaml -ov_SC03_103_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_103_jr_8012ACE0.o,tail2.data.o,ov_SC03_103_jr_801380E0.o,tail3.data.o,ov_SC03_103_jr_8013F350.o,tail4.data.o,ov_SC03_103_jr_8015444C.o,tail5.data.o,ov_SC03_103_jr_80159C84.o,tail6.data.o,ov_SC03_103_jr_8015A3C8.o,tail7.data.o,ov_SC03_103_jr_8015AE2C.o,tail8.data.o,ov_SC03_103_jr_8016AB6C.o,tail9.data.o,ov_SC03_103_jr_801734BC.o,tail10.data.o,ov_SC03_103_jr_80178D40.o,tail11.data.o,ov_SC03_103_jr_8017A4AC.o,tail12.data.o,ov_SC03_103_jr_8017C294.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_103_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_103_jr_8012ACE0.o,tail2.data.o,ov_SC03_103_jr_801380E0.o,tail3.data.o,ov_SC03_103_jr_8013F350.o,tail4.data.o,ov_SC03_103_jr_8015444C.o,tail5.data.o,ov_SC03_103_jr_80159C84.o,tail6.data.o,ov_SC03_103_jr_8015A3C8.o,tail7.data.o,ov_SC03_103_jr_8015AE2C.o,tail8.data.o,ov_SC03_103_jr_8015C32C.o,tail9.data.o,ov_SC03_103_jr_8016AB6C.o,tail10.data.o,ov_SC03_103_jr_801734BC.o,tail11.data.o,ov_SC03_103_jr_80178D40.o,tail12.data.o,ov_SC03_103_jr_8017A4AC.o,tail13.data.o,ov_SC03_103_jr_8017C294.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_103/ov_SC03_103_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_103/ov_SC03_103_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_103/ov_SC03_103_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1646,7 +1646,7 @@ ov_SC03_104_ELF := $(ov_SC03_104_OUT).elf ov_SC03_104_MAPFILE := $(ov_SC03_104_OUT).map ov_SC03_104_LD_SCRIPT := $(ov_SC03_104_OUT).ld ov_SC03_104_SPLAT_YAML := config/splat.ov_SC03_104.yaml -ov_SC03_104_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_104_jr_8012ACE0.o,tail2.data.o,ov_SC03_104_jr_801380E0.o,tail3.data.o,ov_SC03_104_jr_8013F350.o,tail4.data.o,ov_SC03_104_jr_8013FFD8.o,tail5.data.o,ov_SC03_104_jr_8015444C.o,tail6.data.o,ov_SC03_104_jr_80159C84.o,tail7.data.o,ov_SC03_104_jr_8015A3C8.o,tail8.data.o,ov_SC03_104_jr_8015AE2C.o,tail9.data.o,ov_SC03_104_jr_8016AB6C.o,tail10.data.o,ov_SC03_104_jr_801734BC.o,tail11.data.o,ov_SC03_104_jr_80178D40.o,tail12.data.o,ov_SC03_104_jr_8017A4AC.o,tail13.data.o,ov_SC03_104_jr_8017CA80.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_104_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_104_jr_8012ACE0.o,tail2.data.o,ov_SC03_104_jr_801380E0.o,tail3.data.o,ov_SC03_104_jr_8013F350.o,tail4.data.o,ov_SC03_104_jr_8013FFD8.o,tail5.data.o,ov_SC03_104_jr_8015444C.o,tail6.data.o,ov_SC03_104_jr_80159C84.o,tail7.data.o,ov_SC03_104_jr_8015A3C8.o,tail8.data.o,ov_SC03_104_jr_8015AE2C.o,tail9.data.o,ov_SC03_104_jr_8015C32C.o,tail10.data.o,ov_SC03_104_jr_8016AB6C.o,tail11.data.o,ov_SC03_104_jr_801734BC.o,tail12.data.o,ov_SC03_104_jr_80178D40.o,tail13.data.o,ov_SC03_104_jr_8017A4AC.o,tail14.data.o,ov_SC03_104_jr_8017CA80.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_104/ov_SC03_104_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_104/ov_SC03_104_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_104/ov_SC03_104_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1671,7 +1671,7 @@ ov_SC03_105_ELF := $(ov_SC03_105_OUT).elf ov_SC03_105_MAPFILE := $(ov_SC03_105_OUT).map ov_SC03_105_LD_SCRIPT := $(ov_SC03_105_OUT).ld ov_SC03_105_SPLAT_YAML := config/splat.ov_SC03_105.yaml -ov_SC03_105_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_105_jr_8012ACE0.o,tail2.data.o,ov_SC03_105_jr_801380E0.o,tail3.data.o,ov_SC03_105_jr_8013F350.o,tail4.data.o,ov_SC03_105_jr_8013FFD8.o,tail5.data.o,ov_SC03_105_jr_8015444C.o,tail6.data.o,ov_SC03_105_jr_80159C84.o,tail7.data.o,ov_SC03_105_jr_8015A3C8.o,tail8.data.o,ov_SC03_105_jr_8015AE2C.o,tail9.data.o,ov_SC03_105_jr_8016AB6C.o,tail10.data.o,ov_SC03_105_jr_801734BC.o,tail11.data.o,ov_SC03_105_jr_80178D40.o,tail12.data.o,ov_SC03_105_jr_8017A4AC.o,tail13.data.o,ov_SC03_105_jr_8017C8D0.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_105_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_105_jr_8012ACE0.o,tail2.data.o,ov_SC03_105_jr_801380E0.o,tail3.data.o,ov_SC03_105_jr_8013F350.o,tail4.data.o,ov_SC03_105_jr_8013FFD8.o,tail5.data.o,ov_SC03_105_jr_8015444C.o,tail6.data.o,ov_SC03_105_jr_80159C84.o,tail7.data.o,ov_SC03_105_jr_8015A3C8.o,tail8.data.o,ov_SC03_105_jr_8015AE2C.o,tail9.data.o,ov_SC03_105_jr_8015C32C.o,tail10.data.o,ov_SC03_105_jr_8016AB6C.o,tail11.data.o,ov_SC03_105_jr_801734BC.o,tail12.data.o,ov_SC03_105_jr_80178D40.o,tail13.data.o,ov_SC03_105_jr_8017A4AC.o,tail14.data.o,ov_SC03_105_jr_8017C8D0.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_105/ov_SC03_105_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_105/ov_SC03_105_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_105/ov_SC03_105_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1696,7 +1696,7 @@ ov_SC03_108_ELF := $(ov_SC03_108_OUT).elf ov_SC03_108_MAPFILE := $(ov_SC03_108_OUT).map ov_SC03_108_LD_SCRIPT := $(ov_SC03_108_OUT).ld ov_SC03_108_SPLAT_YAML := config/splat.ov_SC03_108.yaml -ov_SC03_108_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_108_jr_8012ACE0.o,tail2.data.o,ov_SC03_108_jr_801380E0.o,tail3.data.o,ov_SC03_108_jr_8013F350.o,tail4.data.o,ov_SC03_108_jr_8013FFD8.o,tail5.data.o,ov_SC03_108_jr_8015444C.o,tail6.data.o,ov_SC03_108_jr_80159C84.o,tail7.data.o,ov_SC03_108_jr_8015A3C8.o,tail8.data.o,ov_SC03_108_jr_8015AE2C.o,tail9.data.o,ov_SC03_108_jr_8016AB6C.o,tail10.data.o,ov_SC03_108_jr_801734BC.o,tail11.data.o,ov_SC03_108_jr_80178D40.o,tail12.data.o,ov_SC03_108_jr_8017A4AC.o,tail13.data.o,ov_SC03_108_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_108_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_108_jr_8012ACE0.o,tail2.data.o,ov_SC03_108_jr_801380E0.o,tail3.data.o,ov_SC03_108_jr_8013F350.o,tail4.data.o,ov_SC03_108_jr_8013FFD8.o,tail5.data.o,ov_SC03_108_jr_8015444C.o,tail6.data.o,ov_SC03_108_jr_80159C84.o,tail7.data.o,ov_SC03_108_jr_8015A3C8.o,tail8.data.o,ov_SC03_108_jr_8015AE2C.o,tail9.data.o,ov_SC03_108_jr_8015C32C.o,tail10.data.o,ov_SC03_108_jr_8016AB6C.o,tail11.data.o,ov_SC03_108_jr_801734BC.o,tail12.data.o,ov_SC03_108_jr_80178D40.o,tail13.data.o,ov_SC03_108_jr_8017A4AC.o,tail14.data.o,ov_SC03_108_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_108/ov_SC03_108_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_108/ov_SC03_108_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_108/ov_SC03_108_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1721,7 +1721,7 @@ ov_SC03_109_ELF := $(ov_SC03_109_OUT).elf ov_SC03_109_MAPFILE := $(ov_SC03_109_OUT).map ov_SC03_109_LD_SCRIPT := $(ov_SC03_109_OUT).ld ov_SC03_109_SPLAT_YAML := config/splat.ov_SC03_109.yaml -ov_SC03_109_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_109_jr_8012ACE0.o,tail2.data.o,ov_SC03_109_jr_801380E0.o,tail3.data.o,ov_SC03_109_jr_8013F350.o,tail4.data.o,ov_SC03_109_jr_8013FFD8.o,tail5.data.o,ov_SC03_109_jr_8015444C.o,tail6.data.o,ov_SC03_109_jr_80159C84.o,tail7.data.o,ov_SC03_109_jr_8015A3C8.o,tail8.data.o,ov_SC03_109_jr_8015AE2C.o,tail9.data.o,ov_SC03_109_jr_8016AB6C.o,tail10.data.o,ov_SC03_109_jr_801734BC.o,tail11.data.o,ov_SC03_109_jr_80178D40.o,tail12.data.o,ov_SC03_109_jr_8017A4AC.o,tail13.data.o,ov_SC03_109_jr_8017C180.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_109_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_109_jr_8012ACE0.o,tail2.data.o,ov_SC03_109_jr_801380E0.o,tail3.data.o,ov_SC03_109_jr_8013F350.o,tail4.data.o,ov_SC03_109_jr_8013FFD8.o,tail5.data.o,ov_SC03_109_jr_8015444C.o,tail6.data.o,ov_SC03_109_jr_80159C84.o,tail7.data.o,ov_SC03_109_jr_8015A3C8.o,tail8.data.o,ov_SC03_109_jr_8015AE2C.o,tail9.data.o,ov_SC03_109_jr_8015C32C.o,tail10.data.o,ov_SC03_109_jr_8016AB6C.o,tail11.data.o,ov_SC03_109_jr_801734BC.o,tail12.data.o,ov_SC03_109_jr_80178D40.o,tail13.data.o,ov_SC03_109_jr_8017A4AC.o,tail14.data.o,ov_SC03_109_jr_8017C180.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_109/ov_SC03_109_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_109/ov_SC03_109_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_109/ov_SC03_109_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1746,7 +1746,7 @@ ov_SC03_110_ELF := $(ov_SC03_110_OUT).elf ov_SC03_110_MAPFILE := $(ov_SC03_110_OUT).map ov_SC03_110_LD_SCRIPT := $(ov_SC03_110_OUT).ld ov_SC03_110_SPLAT_YAML := config/splat.ov_SC03_110.yaml -ov_SC03_110_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_110_jr_8012ACE0.o,tail2.data.o,ov_SC03_110_jr_801380E0.o,tail3.data.o,ov_SC03_110_jr_8013F350.o,tail4.data.o,ov_SC03_110_jr_8013FFD8.o,tail5.data.o,ov_SC03_110_jr_8015444C.o,tail6.data.o,ov_SC03_110_jr_80159C84.o,tail7.data.o,ov_SC03_110_jr_8015A3C8.o,tail8.data.o,ov_SC03_110_jr_8015AE2C.o,tail9.data.o,ov_SC03_110_jr_8016AB6C.o,tail10.data.o,ov_SC03_110_jr_801734BC.o,tail11.data.o,ov_SC03_110_jr_80178D40.o,tail12.data.o,ov_SC03_110_jr_8017A4AC.o,tail13.data.o,ov_SC03_110_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_110_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_110_jr_8012ACE0.o,tail2.data.o,ov_SC03_110_jr_801380E0.o,tail3.data.o,ov_SC03_110_jr_8013F350.o,tail4.data.o,ov_SC03_110_jr_8013FFD8.o,tail5.data.o,ov_SC03_110_jr_8015444C.o,tail6.data.o,ov_SC03_110_jr_80159C84.o,tail7.data.o,ov_SC03_110_jr_8015A3C8.o,tail8.data.o,ov_SC03_110_jr_8015AE2C.o,tail9.data.o,ov_SC03_110_jr_8015C32C.o,tail10.data.o,ov_SC03_110_jr_8016AB6C.o,tail11.data.o,ov_SC03_110_jr_801734BC.o,tail12.data.o,ov_SC03_110_jr_80178D40.o,tail13.data.o,ov_SC03_110_jr_8017A4AC.o,tail14.data.o,ov_SC03_110_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_110/ov_SC03_110_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_110/ov_SC03_110_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_110/ov_SC03_110_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1771,7 +1771,7 @@ ov_SC03_111_ELF := $(ov_SC03_111_OUT).elf ov_SC03_111_MAPFILE := $(ov_SC03_111_OUT).map ov_SC03_111_LD_SCRIPT := $(ov_SC03_111_OUT).ld ov_SC03_111_SPLAT_YAML := config/splat.ov_SC03_111.yaml -ov_SC03_111_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_111_jr_8012ACE0.o,tail2.data.o,ov_SC03_111_jr_801380E0.o,tail3.data.o,ov_SC03_111_jr_8013F350.o,tail4.data.o,ov_SC03_111_jr_8013FFD8.o,tail5.data.o,ov_SC03_111_jr_8015444C.o,tail6.data.o,ov_SC03_111_jr_80159C84.o,tail7.data.o,ov_SC03_111_jr_8015A3C8.o,tail8.data.o,ov_SC03_111_jr_8015AE2C.o,tail9.data.o,ov_SC03_111_jr_8016AB6C.o,tail10.data.o,ov_SC03_111_jr_801734BC.o,tail11.data.o,ov_SC03_111_jr_80178D40.o,tail12.data.o,ov_SC03_111_jr_8017A4AC.o,tail13.data.o,ov_SC03_111_jr_8017EC58.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_111_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_111_jr_8012ACE0.o,tail2.data.o,ov_SC03_111_jr_801380E0.o,tail3.data.o,ov_SC03_111_jr_8013F350.o,tail4.data.o,ov_SC03_111_jr_8013FFD8.o,tail5.data.o,ov_SC03_111_jr_8015444C.o,tail6.data.o,ov_SC03_111_jr_80159C84.o,tail7.data.o,ov_SC03_111_jr_8015A3C8.o,tail8.data.o,ov_SC03_111_jr_8015AE2C.o,tail9.data.o,ov_SC03_111_jr_8015C32C.o,tail10.data.o,ov_SC03_111_jr_8016AB6C.o,tail11.data.o,ov_SC03_111_jr_801734BC.o,tail12.data.o,ov_SC03_111_jr_80178D40.o,tail13.data.o,ov_SC03_111_jr_8017A4AC.o,tail14.data.o,ov_SC03_111_jr_8017EC58.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_111/ov_SC03_111_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_111/ov_SC03_111_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_111/ov_SC03_111_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1796,7 +1796,7 @@ ov_SC03_112_ELF := $(ov_SC03_112_OUT).elf ov_SC03_112_MAPFILE := $(ov_SC03_112_OUT).map ov_SC03_112_LD_SCRIPT := $(ov_SC03_112_OUT).ld ov_SC03_112_SPLAT_YAML := config/splat.ov_SC03_112.yaml -ov_SC03_112_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_112_jr_8012ACE0.o,tail2.data.o,ov_SC03_112_jr_801380E0.o,tail3.data.o,ov_SC03_112_jr_8013F350.o,tail4.data.o,ov_SC03_112_jr_8013FFD8.o,tail5.data.o,ov_SC03_112_jr_8015444C.o,tail6.data.o,ov_SC03_112_jr_80159C84.o,tail7.data.o,ov_SC03_112_jr_8015A3C8.o,tail8.data.o,ov_SC03_112_jr_8015AE2C.o,tail9.data.o,ov_SC03_112_jr_8016AB6C.o,tail10.data.o,ov_SC03_112_jr_801734BC.o,tail11.data.o,ov_SC03_112_jr_80178D40.o,tail12.data.o,ov_SC03_112_jr_8017A4AC.o,tail13.data.o,ov_SC03_112_jr_8017C294.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_112_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_112_jr_8012ACE0.o,tail2.data.o,ov_SC03_112_jr_801380E0.o,tail3.data.o,ov_SC03_112_jr_8013F350.o,tail4.data.o,ov_SC03_112_jr_8013FFD8.o,tail5.data.o,ov_SC03_112_jr_8015444C.o,tail6.data.o,ov_SC03_112_jr_80159C84.o,tail7.data.o,ov_SC03_112_jr_8015A3C8.o,tail8.data.o,ov_SC03_112_jr_8015AE2C.o,tail9.data.o,ov_SC03_112_jr_8015C32C.o,tail10.data.o,ov_SC03_112_jr_8016AB6C.o,tail11.data.o,ov_SC03_112_jr_801734BC.o,tail12.data.o,ov_SC03_112_jr_80178D40.o,tail13.data.o,ov_SC03_112_jr_8017A4AC.o,tail14.data.o,ov_SC03_112_jr_8017C294.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_112/ov_SC03_112_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_112/ov_SC03_112_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_112/ov_SC03_112_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1821,7 +1821,7 @@ ov_SC03_113_ELF := $(ov_SC03_113_OUT).elf ov_SC03_113_MAPFILE := $(ov_SC03_113_OUT).map ov_SC03_113_LD_SCRIPT := $(ov_SC03_113_OUT).ld ov_SC03_113_SPLAT_YAML := config/splat.ov_SC03_113.yaml -ov_SC03_113_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_113_jr_8012ACE0.o,tail2.data.o,ov_SC03_113_jr_801380E0.o,tail3.data.o,ov_SC03_113_jr_8013F350.o,tail4.data.o,ov_SC03_113_jr_8013FFD8.o,tail5.data.o,ov_SC03_113_jr_8015444C.o,tail6.data.o,ov_SC03_113_jr_80159C84.o,tail7.data.o,ov_SC03_113_jr_8015A3C8.o,tail8.data.o,ov_SC03_113_jr_8015AE2C.o,tail9.data.o,ov_SC03_113_jr_8016AB6C.o,tail10.data.o,ov_SC03_113_jr_801734BC.o,tail11.data.o,ov_SC03_113_jr_80178D40.o,tail12.data.o,ov_SC03_113_jr_8017A4AC.o,tail13.data.o,ov_SC03_113_jr_8017C294.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_113_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_113_jr_8012ACE0.o,tail2.data.o,ov_SC03_113_jr_801380E0.o,tail3.data.o,ov_SC03_113_jr_8013F350.o,tail4.data.o,ov_SC03_113_jr_8013FFD8.o,tail5.data.o,ov_SC03_113_jr_8015444C.o,tail6.data.o,ov_SC03_113_jr_80159C84.o,tail7.data.o,ov_SC03_113_jr_8015A3C8.o,tail8.data.o,ov_SC03_113_jr_8015AE2C.o,tail9.data.o,ov_SC03_113_jr_8015C32C.o,tail10.data.o,ov_SC03_113_jr_8016AB6C.o,tail11.data.o,ov_SC03_113_jr_801734BC.o,tail12.data.o,ov_SC03_113_jr_80178D40.o,tail13.data.o,ov_SC03_113_jr_8017A4AC.o,tail14.data.o,ov_SC03_113_jr_8017C294.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_113/ov_SC03_113_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_113/ov_SC03_113_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_113/ov_SC03_113_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1846,7 +1846,7 @@ ov_SC03_114_ELF := $(ov_SC03_114_OUT).elf ov_SC03_114_MAPFILE := $(ov_SC03_114_OUT).map ov_SC03_114_LD_SCRIPT := $(ov_SC03_114_OUT).ld ov_SC03_114_SPLAT_YAML := config/splat.ov_SC03_114.yaml -ov_SC03_114_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_114_jr_8012ACE0.o,tail2.data.o,ov_SC03_114_jr_801380E0.o,tail3.data.o,ov_SC03_114_jr_8013F350.o,tail4.data.o,ov_SC03_114_jr_8013FFD8.o,tail5.data.o,ov_SC03_114_jr_8015444C.o,tail6.data.o,ov_SC03_114_jr_80159C84.o,tail7.data.o,ov_SC03_114_jr_8015A3C8.o,tail8.data.o,ov_SC03_114_jr_8015AE2C.o,tail9.data.o,ov_SC03_114_jr_8016AB6C.o,tail10.data.o,ov_SC03_114_jr_801734BC.o,tail11.data.o,ov_SC03_114_jr_80178D40.o,tail12.data.o,ov_SC03_114_jr_8017A4AC.o,tail13.data.o,ov_SC03_114_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_114_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_114_jr_8012ACE0.o,tail2.data.o,ov_SC03_114_jr_801380E0.o,tail3.data.o,ov_SC03_114_jr_8013F350.o,tail4.data.o,ov_SC03_114_jr_8013FFD8.o,tail5.data.o,ov_SC03_114_jr_8015444C.o,tail6.data.o,ov_SC03_114_jr_80159C84.o,tail7.data.o,ov_SC03_114_jr_8015A3C8.o,tail8.data.o,ov_SC03_114_jr_8015AE2C.o,tail9.data.o,ov_SC03_114_jr_8015C32C.o,tail10.data.o,ov_SC03_114_jr_8016AB6C.o,tail11.data.o,ov_SC03_114_jr_801734BC.o,tail12.data.o,ov_SC03_114_jr_80178D40.o,tail13.data.o,ov_SC03_114_jr_8017A4AC.o,tail14.data.o,ov_SC03_114_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_114/ov_SC03_114_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_114/ov_SC03_114_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_114/ov_SC03_114_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1871,7 +1871,7 @@ ov_SC03_115_ELF := $(ov_SC03_115_OUT).elf ov_SC03_115_MAPFILE := $(ov_SC03_115_OUT).map ov_SC03_115_LD_SCRIPT := $(ov_SC03_115_OUT).ld ov_SC03_115_SPLAT_YAML := config/splat.ov_SC03_115.yaml -ov_SC03_115_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_115_jr_8012ACE0.o,tail2.data.o,ov_SC03_115_jr_801380E0.o,tail3.data.o,ov_SC03_115_jr_8013F350.o,tail4.data.o,ov_SC03_115_jr_8013FFD8.o,tail5.data.o,ov_SC03_115_jr_8015444C.o,tail6.data.o,ov_SC03_115_jr_80159C84.o,tail7.data.o,ov_SC03_115_jr_8015A3C8.o,tail8.data.o,ov_SC03_115_jr_8015AE2C.o,tail9.data.o,ov_SC03_115_jr_8016AB6C.o,tail10.data.o,ov_SC03_115_jr_801734BC.o,tail11.data.o,ov_SC03_115_jr_80178D40.o,tail12.data.o,ov_SC03_115_jr_8017A4AC.o,tail13.data.o,ov_SC03_115_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_115_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_115_jr_8012ACE0.o,tail2.data.o,ov_SC03_115_jr_801380E0.o,tail3.data.o,ov_SC03_115_jr_8013F350.o,tail4.data.o,ov_SC03_115_jr_8013FFD8.o,tail5.data.o,ov_SC03_115_jr_8015444C.o,tail6.data.o,ov_SC03_115_jr_80159C84.o,tail7.data.o,ov_SC03_115_jr_8015A3C8.o,tail8.data.o,ov_SC03_115_jr_8015AE2C.o,tail9.data.o,ov_SC03_115_jr_8015C32C.o,tail10.data.o,ov_SC03_115_jr_8016AB6C.o,tail11.data.o,ov_SC03_115_jr_801734BC.o,tail12.data.o,ov_SC03_115_jr_80178D40.o,tail13.data.o,ov_SC03_115_jr_8017A4AC.o,tail14.data.o,ov_SC03_115_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_115/ov_SC03_115_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_115/ov_SC03_115_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_115/ov_SC03_115_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1896,7 +1896,7 @@ ov_SC03_116_ELF := $(ov_SC03_116_OUT).elf ov_SC03_116_MAPFILE := $(ov_SC03_116_OUT).map ov_SC03_116_LD_SCRIPT := $(ov_SC03_116_OUT).ld ov_SC03_116_SPLAT_YAML := config/splat.ov_SC03_116.yaml -ov_SC03_116_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_116_jr_8012ACE0.o,tail2.data.o,ov_SC03_116_jr_801380E0.o,tail3.data.o,ov_SC03_116_jr_8013F350.o,tail4.data.o,ov_SC03_116_jr_8013FFD8.o,tail5.data.o,ov_SC03_116_jr_8015444C.o,tail6.data.o,ov_SC03_116_jr_80159C84.o,tail7.data.o,ov_SC03_116_jr_8015A3C8.o,tail8.data.o,ov_SC03_116_jr_8015AE2C.o,tail9.data.o,ov_SC03_116_jr_8016AB6C.o,tail10.data.o,ov_SC03_116_jr_801734BC.o,tail11.data.o,ov_SC03_116_jr_80178D40.o,tail12.data.o,ov_SC03_116_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_116_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_116_jr_8012ACE0.o,tail2.data.o,ov_SC03_116_jr_801380E0.o,tail3.data.o,ov_SC03_116_jr_8013F350.o,tail4.data.o,ov_SC03_116_jr_8013FFD8.o,tail5.data.o,ov_SC03_116_jr_8015444C.o,tail6.data.o,ov_SC03_116_jr_80159C84.o,tail7.data.o,ov_SC03_116_jr_8015A3C8.o,tail8.data.o,ov_SC03_116_jr_8015AE2C.o,tail9.data.o,ov_SC03_116_jr_8015C32C.o,tail10.data.o,ov_SC03_116_jr_8016AB6C.o,tail11.data.o,ov_SC03_116_jr_801734BC.o,tail12.data.o,ov_SC03_116_jr_80178D40.o,tail13.data.o,ov_SC03_116_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_116/ov_SC03_116_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_116/ov_SC03_116_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_116/ov_SC03_116_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1921,7 +1921,7 @@ ov_SC03_117_ELF := $(ov_SC03_117_OUT).elf ov_SC03_117_MAPFILE := $(ov_SC03_117_OUT).map ov_SC03_117_LD_SCRIPT := $(ov_SC03_117_OUT).ld ov_SC03_117_SPLAT_YAML := config/splat.ov_SC03_117.yaml -ov_SC03_117_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_117_jr_8012ACE0.o,tail2.data.o,ov_SC03_117_jr_801380E0.o,tail3.data.o,ov_SC03_117_jr_8013F350.o,tail4.data.o,ov_SC03_117_jr_8013FFD8.o,tail5.data.o,ov_SC03_117_jr_8015444C.o,tail6.data.o,ov_SC03_117_jr_80159C84.o,tail7.data.o,ov_SC03_117_jr_8015A3C8.o,tail8.data.o,ov_SC03_117_jr_8015AE2C.o,tail9.data.o,ov_SC03_117_jr_8016AB6C.o,tail10.data.o,ov_SC03_117_jr_801734BC.o,tail11.data.o,ov_SC03_117_jr_80178D40.o,tail12.data.o,ov_SC03_117_jr_8017A4AC.o,tail13.data.o,ov_SC03_117_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_117_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_117_jr_8012ACE0.o,tail2.data.o,ov_SC03_117_jr_801380E0.o,tail3.data.o,ov_SC03_117_jr_8013F350.o,tail4.data.o,ov_SC03_117_jr_8013FFD8.o,tail5.data.o,ov_SC03_117_jr_8015444C.o,tail6.data.o,ov_SC03_117_jr_80159C84.o,tail7.data.o,ov_SC03_117_jr_8015A3C8.o,tail8.data.o,ov_SC03_117_jr_8015AE2C.o,tail9.data.o,ov_SC03_117_jr_8015C32C.o,tail10.data.o,ov_SC03_117_jr_8016AB6C.o,tail11.data.o,ov_SC03_117_jr_801734BC.o,tail12.data.o,ov_SC03_117_jr_80178D40.o,tail13.data.o,ov_SC03_117_jr_8017A4AC.o,tail14.data.o,ov_SC03_117_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_117/ov_SC03_117_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_117/ov_SC03_117_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_117/ov_SC03_117_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1946,7 +1946,7 @@ ov_SC03_118_ELF := $(ov_SC03_118_OUT).elf ov_SC03_118_MAPFILE := $(ov_SC03_118_OUT).map ov_SC03_118_LD_SCRIPT := $(ov_SC03_118_OUT).ld ov_SC03_118_SPLAT_YAML := config/splat.ov_SC03_118.yaml -ov_SC03_118_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_118_jr_8012ACE0.o,tail2.data.o,ov_SC03_118_jr_801380E0.o,tail3.data.o,ov_SC03_118_jr_8013F350.o,tail4.data.o,ov_SC03_118_jr_8013FFD8.o,tail5.data.o,ov_SC03_118_jr_8015444C.o,tail6.data.o,ov_SC03_118_jr_80159C84.o,tail7.data.o,ov_SC03_118_jr_8015A3C8.o,tail8.data.o,ov_SC03_118_jr_8015AE2C.o,tail9.data.o,ov_SC03_118_jr_8016AB6C.o,tail10.data.o,ov_SC03_118_jr_801734BC.o,tail11.data.o,ov_SC03_118_jr_80178D40.o,tail12.data.o,ov_SC03_118_jr_8017A4AC.o,tail13.data.o,ov_SC03_118_jr_8017FB84.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_118_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_118_jr_8012ACE0.o,tail2.data.o,ov_SC03_118_jr_801380E0.o,tail3.data.o,ov_SC03_118_jr_8013F350.o,tail4.data.o,ov_SC03_118_jr_8013FFD8.o,tail5.data.o,ov_SC03_118_jr_8015444C.o,tail6.data.o,ov_SC03_118_jr_80159C84.o,tail7.data.o,ov_SC03_118_jr_8015A3C8.o,tail8.data.o,ov_SC03_118_jr_8015AE2C.o,tail9.data.o,ov_SC03_118_jr_8015C32C.o,tail10.data.o,ov_SC03_118_jr_8016AB6C.o,tail11.data.o,ov_SC03_118_jr_801734BC.o,tail12.data.o,ov_SC03_118_jr_80178D40.o,tail13.data.o,ov_SC03_118_jr_8017A4AC.o,tail14.data.o,ov_SC03_118_jr_8017FB84.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_118/ov_SC03_118_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_118/ov_SC03_118_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_118/ov_SC03_118_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1971,7 +1971,7 @@ ov_SC03_119_ELF := $(ov_SC03_119_OUT).elf ov_SC03_119_MAPFILE := $(ov_SC03_119_OUT).map ov_SC03_119_LD_SCRIPT := $(ov_SC03_119_OUT).ld ov_SC03_119_SPLAT_YAML := config/splat.ov_SC03_119.yaml -ov_SC03_119_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_119_jr_8012ACE0.o,tail2.data.o,ov_SC03_119_jr_801380E0.o,tail3.data.o,ov_SC03_119_jr_8013F350.o,tail4.data.o,ov_SC03_119_jr_8013FFD8.o,tail5.data.o,ov_SC03_119_jr_8015444C.o,tail6.data.o,ov_SC03_119_jr_80159C84.o,tail7.data.o,ov_SC03_119_jr_8015A3C8.o,tail8.data.o,ov_SC03_119_jr_8015AE2C.o,tail9.data.o,ov_SC03_119_jr_8016AB6C.o,tail10.data.o,ov_SC03_119_jr_801734BC.o,tail11.data.o,ov_SC03_119_jr_80178D40.o,tail12.data.o,ov_SC03_119_jr_8017A4AC.o,tail13.data.o,ov_SC03_119_jr_8017FB84.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_119_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_119_jr_8012ACE0.o,tail2.data.o,ov_SC03_119_jr_801380E0.o,tail3.data.o,ov_SC03_119_jr_8013F350.o,tail4.data.o,ov_SC03_119_jr_8013FFD8.o,tail5.data.o,ov_SC03_119_jr_8015444C.o,tail6.data.o,ov_SC03_119_jr_80159C84.o,tail7.data.o,ov_SC03_119_jr_8015A3C8.o,tail8.data.o,ov_SC03_119_jr_8015AE2C.o,tail9.data.o,ov_SC03_119_jr_8015C32C.o,tail10.data.o,ov_SC03_119_jr_8016AB6C.o,tail11.data.o,ov_SC03_119_jr_801734BC.o,tail12.data.o,ov_SC03_119_jr_80178D40.o,tail13.data.o,ov_SC03_119_jr_8017A4AC.o,tail14.data.o,ov_SC03_119_jr_8017FB84.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_119/ov_SC03_119_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_119/ov_SC03_119_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_119/ov_SC03_119_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -1996,7 +1996,7 @@ ov_SC03_121_ELF := $(ov_SC03_121_OUT).elf ov_SC03_121_MAPFILE := $(ov_SC03_121_OUT).map ov_SC03_121_LD_SCRIPT := $(ov_SC03_121_OUT).ld ov_SC03_121_SPLAT_YAML := config/splat.ov_SC03_121.yaml -ov_SC03_121_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_121_jr_8012ACE0.o,tail2.data.o,ov_SC03_121_jr_801380E0.o,tail3.data.o,ov_SC03_121_jr_8013F350.o,tail4.data.o,ov_SC03_121_jr_8013FFD8.o,tail5.data.o,ov_SC03_121_jr_8015444C.o,tail6.data.o,ov_SC03_121_jr_80159C84.o,tail7.data.o,ov_SC03_121_jr_8015A3C8.o,tail8.data.o,ov_SC03_121_jr_8015AE2C.o,tail9.data.o,ov_SC03_121_jr_8016AB6C.o,tail10.data.o,ov_SC03_121_jr_801734BC.o,tail11.data.o,ov_SC03_121_jr_80178D40.o,tail12.data.o,ov_SC03_121_jr_8017A4AC.o,tail13.data.o,ov_SC03_121_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_121_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_121_jr_8012ACE0.o,tail2.data.o,ov_SC03_121_jr_801380E0.o,tail3.data.o,ov_SC03_121_jr_8013F350.o,tail4.data.o,ov_SC03_121_jr_8013FFD8.o,tail5.data.o,ov_SC03_121_jr_8015444C.o,tail6.data.o,ov_SC03_121_jr_80159C84.o,tail7.data.o,ov_SC03_121_jr_8015A3C8.o,tail8.data.o,ov_SC03_121_jr_8015AE2C.o,tail9.data.o,ov_SC03_121_jr_8015C32C.o,tail10.data.o,ov_SC03_121_jr_8016AB6C.o,tail11.data.o,ov_SC03_121_jr_801734BC.o,tail12.data.o,ov_SC03_121_jr_80178D40.o,tail13.data.o,ov_SC03_121_jr_8017A4AC.o,tail14.data.o,ov_SC03_121_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_121/ov_SC03_121_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_121/ov_SC03_121_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_121/ov_SC03_121_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2021,7 +2021,7 @@ ov_SC03_124_ELF := $(ov_SC03_124_OUT).elf ov_SC03_124_MAPFILE := $(ov_SC03_124_OUT).map ov_SC03_124_LD_SCRIPT := $(ov_SC03_124_OUT).ld ov_SC03_124_SPLAT_YAML := config/splat.ov_SC03_124.yaml -ov_SC03_124_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_124_jr_8012ACE0.o,tail2.data.o,ov_SC03_124_jr_801380E0.o,tail3.data.o,ov_SC03_124_jr_8013F350.o,tail4.data.o,ov_SC03_124_jr_8013FFD8.o,tail5.data.o,ov_SC03_124_jr_8015444C.o,tail6.data.o,ov_SC03_124_jr_80159C84.o,tail7.data.o,ov_SC03_124_jr_8015A3C8.o,tail8.data.o,ov_SC03_124_jr_8015AE2C.o,tail9.data.o,ov_SC03_124_jr_8016AB6C.o,tail10.data.o,ov_SC03_124_jr_801734BC.o,tail11.data.o,ov_SC03_124_jr_80178D40.o,tail12.data.o,ov_SC03_124_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_124_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_124_jr_8012ACE0.o,tail2.data.o,ov_SC03_124_jr_801380E0.o,tail3.data.o,ov_SC03_124_jr_8013F350.o,tail4.data.o,ov_SC03_124_jr_8013FFD8.o,tail5.data.o,ov_SC03_124_jr_8015444C.o,tail6.data.o,ov_SC03_124_jr_80159C84.o,tail7.data.o,ov_SC03_124_jr_8015A3C8.o,tail8.data.o,ov_SC03_124_jr_8015AE2C.o,tail9.data.o,ov_SC03_124_jr_8015C32C.o,tail10.data.o,ov_SC03_124_jr_8016AB6C.o,tail11.data.o,ov_SC03_124_jr_801734BC.o,tail12.data.o,ov_SC03_124_jr_80178D40.o,tail13.data.o,ov_SC03_124_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_124/ov_SC03_124_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_124/ov_SC03_124_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_124/ov_SC03_124_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2046,7 +2046,7 @@ ov_SC03_125_ELF := $(ov_SC03_125_OUT).elf ov_SC03_125_MAPFILE := $(ov_SC03_125_OUT).map ov_SC03_125_LD_SCRIPT := $(ov_SC03_125_OUT).ld ov_SC03_125_SPLAT_YAML := config/splat.ov_SC03_125.yaml -ov_SC03_125_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_125_jr_8012ACE0.o,tail2.data.o,ov_SC03_125_jr_801380E0.o,tail3.data.o,ov_SC03_125_jr_8013F350.o,tail4.data.o,ov_SC03_125_jr_8013FFD8.o,tail5.data.o,ov_SC03_125_jr_8015444C.o,tail6.data.o,ov_SC03_125_jr_80159C84.o,tail7.data.o,ov_SC03_125_jr_8015A3C8.o,tail8.data.o,ov_SC03_125_jr_8015AE2C.o,tail9.data.o,ov_SC03_125_jr_8016AB6C.o,tail10.data.o,ov_SC03_125_jr_801734BC.o,tail11.data.o,ov_SC03_125_jr_80178D40.o,tail12.data.o,ov_SC03_125_jr_8017A4AC.o,tail13.data.o,ov_SC03_125_jr_8017D604.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_125_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_125_jr_8012ACE0.o,tail2.data.o,ov_SC03_125_jr_801380E0.o,tail3.data.o,ov_SC03_125_jr_8013F350.o,tail4.data.o,ov_SC03_125_jr_8013FFD8.o,tail5.data.o,ov_SC03_125_jr_8015444C.o,tail6.data.o,ov_SC03_125_jr_80159C84.o,tail7.data.o,ov_SC03_125_jr_8015A3C8.o,tail8.data.o,ov_SC03_125_jr_8015AE2C.o,tail9.data.o,ov_SC03_125_jr_8015C32C.o,tail10.data.o,ov_SC03_125_jr_8016AB6C.o,tail11.data.o,ov_SC03_125_jr_801734BC.o,tail12.data.o,ov_SC03_125_jr_80178D40.o,tail13.data.o,ov_SC03_125_jr_8017A4AC.o,tail14.data.o,ov_SC03_125_jr_8017D604.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_125/ov_SC03_125_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_125/ov_SC03_125_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_125/ov_SC03_125_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2071,7 +2071,7 @@ ov_SC03_126_ELF := $(ov_SC03_126_OUT).elf ov_SC03_126_MAPFILE := $(ov_SC03_126_OUT).map ov_SC03_126_LD_SCRIPT := $(ov_SC03_126_OUT).ld ov_SC03_126_SPLAT_YAML := config/splat.ov_SC03_126.yaml -ov_SC03_126_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_126_jr_8012ACE0.o,tail2.data.o,ov_SC03_126_jr_801380E0.o,tail3.data.o,ov_SC03_126_jr_8013F350.o,tail4.data.o,ov_SC03_126_jr_8013FFD8.o,tail5.data.o,ov_SC03_126_jr_8015444C.o,tail6.data.o,ov_SC03_126_jr_80159C84.o,tail7.data.o,ov_SC03_126_jr_8015A3C8.o,tail8.data.o,ov_SC03_126_jr_8015AE2C.o,tail9.data.o,ov_SC03_126_jr_8016AB6C.o,tail10.data.o,ov_SC03_126_jr_801734BC.o,tail11.data.o,ov_SC03_126_jr_80178D40.o,tail12.data.o,ov_SC03_126_jr_8017A4AC.o,tail13.data.o,ov_SC03_126_jr_8017D5C0.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC03_126_JTBL_INTERLEAVE := --order tail.data.o,ov_SC03_126_jr_8012ACE0.o,tail2.data.o,ov_SC03_126_jr_801380E0.o,tail3.data.o,ov_SC03_126_jr_8013F350.o,tail4.data.o,ov_SC03_126_jr_8013FFD8.o,tail5.data.o,ov_SC03_126_jr_8015444C.o,tail6.data.o,ov_SC03_126_jr_80159C84.o,tail7.data.o,ov_SC03_126_jr_8015A3C8.o,tail8.data.o,ov_SC03_126_jr_8015AE2C.o,tail9.data.o,ov_SC03_126_jr_8015C32C.o,tail10.data.o,ov_SC03_126_jr_8016AB6C.o,tail11.data.o,ov_SC03_126_jr_801734BC.o,tail12.data.o,ov_SC03_126_jr_80178D40.o,tail13.data.o,ov_SC03_126_jr_8017A4AC.o,tail14.data.o,ov_SC03_126_jr_8017D5C0.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC03_126/ov_SC03_126_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC03_126/ov_SC03_126_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC03_126/ov_SC03_126_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2096,7 +2096,7 @@ ov_SC04_002_ELF := $(ov_SC04_002_OUT).elf ov_SC04_002_MAPFILE := $(ov_SC04_002_OUT).map ov_SC04_002_LD_SCRIPT := $(ov_SC04_002_OUT).ld ov_SC04_002_SPLAT_YAML := config/splat.ov_SC04_002.yaml -ov_SC04_002_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_002_jr_8012ACE0.o,tail2.data.o,ov_SC04_002_jr_801380E0.o,tail3.data.o,ov_SC04_002_jr_8013F350.o,tail4.data.o,ov_SC04_002_jr_8013FFD8.o,tail5.data.o,ov_SC04_002_jr_8015444C.o,tail6.data.o,ov_SC04_002_jr_80159C84.o,tail7.data.o,ov_SC04_002_jr_8015A3C8.o,tail8.data.o,ov_SC04_002_jr_8015AE2C.o,tail9.data.o,ov_SC04_002_jr_8016AB6C.o,tail10.data.o,ov_SC04_002_jr_801734BC.o,tail11.data.o,ov_SC04_002_jr_80178D40.o,tail12.data.o,ov_SC04_002_jr_8017A4AC.o,tail13.data.o,ov_SC04_002_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_002_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_002_jr_8012ACE0.o,tail2.data.o,ov_SC04_002_jr_801380E0.o,tail3.data.o,ov_SC04_002_jr_8013F350.o,tail4.data.o,ov_SC04_002_jr_8013FFD8.o,tail5.data.o,ov_SC04_002_jr_8015444C.o,tail6.data.o,ov_SC04_002_jr_80159C84.o,tail7.data.o,ov_SC04_002_jr_8015A3C8.o,tail8.data.o,ov_SC04_002_jr_8015AE2C.o,tail9.data.o,ov_SC04_002_jr_8015C32C.o,tail10.data.o,ov_SC04_002_jr_8016AB6C.o,tail11.data.o,ov_SC04_002_jr_801734BC.o,tail12.data.o,ov_SC04_002_jr_80178D40.o,tail13.data.o,ov_SC04_002_jr_8017A4AC.o,tail14.data.o,ov_SC04_002_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_002/ov_SC04_002_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_002/ov_SC04_002_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_002/ov_SC04_002_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2121,7 +2121,7 @@ ov_SC04_003_ELF := $(ov_SC04_003_OUT).elf ov_SC04_003_MAPFILE := $(ov_SC04_003_OUT).map ov_SC04_003_LD_SCRIPT := $(ov_SC04_003_OUT).ld ov_SC04_003_SPLAT_YAML := config/splat.ov_SC04_003.yaml -ov_SC04_003_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_003_jr_8012ACE0.o,tail2.data.o,ov_SC04_003_jr_801380E0.o,tail3.data.o,ov_SC04_003_jr_8013F350.o,tail4.data.o,ov_SC04_003_jr_8013FFD8.o,tail5.data.o,ov_SC04_003_jr_8015444C.o,tail6.data.o,ov_SC04_003_jr_80159C84.o,tail7.data.o,ov_SC04_003_jr_8015A3C8.o,tail8.data.o,ov_SC04_003_jr_8015AE2C.o,tail9.data.o,ov_SC04_003_jr_8016AB6C.o,tail10.data.o,ov_SC04_003_jr_801734BC.o,tail11.data.o,ov_SC04_003_jr_80178D40.o,tail12.data.o,ov_SC04_003_jr_8017A4AC.o,tail13.data.o,ov_SC04_003_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_003_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_003_jr_8012ACE0.o,tail2.data.o,ov_SC04_003_jr_801380E0.o,tail3.data.o,ov_SC04_003_jr_8013F350.o,tail4.data.o,ov_SC04_003_jr_8013FFD8.o,tail5.data.o,ov_SC04_003_jr_8015444C.o,tail6.data.o,ov_SC04_003_jr_80159C84.o,tail7.data.o,ov_SC04_003_jr_8015A3C8.o,tail8.data.o,ov_SC04_003_jr_8015AE2C.o,tail9.data.o,ov_SC04_003_jr_8015C32C.o,tail10.data.o,ov_SC04_003_jr_8016AB6C.o,tail11.data.o,ov_SC04_003_jr_801734BC.o,tail12.data.o,ov_SC04_003_jr_80178D40.o,tail13.data.o,ov_SC04_003_jr_8017A4AC.o,tail14.data.o,ov_SC04_003_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_003/ov_SC04_003_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_003/ov_SC04_003_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_003/ov_SC04_003_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2146,7 +2146,7 @@ ov_SC04_004_ELF := $(ov_SC04_004_OUT).elf ov_SC04_004_MAPFILE := $(ov_SC04_004_OUT).map ov_SC04_004_LD_SCRIPT := $(ov_SC04_004_OUT).ld ov_SC04_004_SPLAT_YAML := config/splat.ov_SC04_004.yaml -ov_SC04_004_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_004_jr_8012ACE0.o,tail2.data.o,ov_SC04_004_jr_801380E0.o,tail3.data.o,ov_SC04_004_jr_8013F350.o,tail4.data.o,ov_SC04_004_jr_8013FFD8.o,tail5.data.o,ov_SC04_004_jr_8015444C.o,tail6.data.o,ov_SC04_004_jr_80159C84.o,tail7.data.o,ov_SC04_004_jr_8015A3C8.o,tail8.data.o,ov_SC04_004_jr_8015AE2C.o,tail9.data.o,ov_SC04_004_jr_8016AB6C.o,tail10.data.o,ov_SC04_004_jr_801734BC.o,tail11.data.o,ov_SC04_004_jr_80178D40.o,tail12.data.o,ov_SC04_004_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_004_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_004_jr_8012ACE0.o,tail2.data.o,ov_SC04_004_jr_801380E0.o,tail3.data.o,ov_SC04_004_jr_8013F350.o,tail4.data.o,ov_SC04_004_jr_8013FFD8.o,tail5.data.o,ov_SC04_004_jr_8015444C.o,tail6.data.o,ov_SC04_004_jr_80159C84.o,tail7.data.o,ov_SC04_004_jr_8015A3C8.o,tail8.data.o,ov_SC04_004_jr_8015AE2C.o,tail9.data.o,ov_SC04_004_jr_8015C32C.o,tail10.data.o,ov_SC04_004_jr_8016AB6C.o,tail11.data.o,ov_SC04_004_jr_801734BC.o,tail12.data.o,ov_SC04_004_jr_80178D40.o,tail13.data.o,ov_SC04_004_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_004/ov_SC04_004_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_004/ov_SC04_004_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_004/ov_SC04_004_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2171,7 +2171,7 @@ ov_SC04_005_ELF := $(ov_SC04_005_OUT).elf ov_SC04_005_MAPFILE := $(ov_SC04_005_OUT).map ov_SC04_005_LD_SCRIPT := $(ov_SC04_005_OUT).ld ov_SC04_005_SPLAT_YAML := config/splat.ov_SC04_005.yaml -ov_SC04_005_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_005_jr_8012ACE0.o,tail2.data.o,ov_SC04_005_jr_801380E0.o,tail3.data.o,ov_SC04_005_jr_8013F350.o,tail4.data.o,ov_SC04_005_jr_8013FFD8.o,tail5.data.o,ov_SC04_005_jr_8015444C.o,tail6.data.o,ov_SC04_005_jr_80159C84.o,tail7.data.o,ov_SC04_005_jr_8015A3C8.o,tail8.data.o,ov_SC04_005_jr_8015AE2C.o,tail9.data.o,ov_SC04_005_jr_8016AB6C.o,tail10.data.o,ov_SC04_005_jr_801734BC.o,tail11.data.o,ov_SC04_005_jr_80178D40.o,tail12.data.o,ov_SC04_005_jr_8017A4AC.o,tail13.data.o,ov_SC04_005_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_005_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_005_jr_8012ACE0.o,tail2.data.o,ov_SC04_005_jr_801380E0.o,tail3.data.o,ov_SC04_005_jr_8013F350.o,tail4.data.o,ov_SC04_005_jr_8013FFD8.o,tail5.data.o,ov_SC04_005_jr_8015444C.o,tail6.data.o,ov_SC04_005_jr_80159C84.o,tail7.data.o,ov_SC04_005_jr_8015A3C8.o,tail8.data.o,ov_SC04_005_jr_8015AE2C.o,tail9.data.o,ov_SC04_005_jr_8015C32C.o,tail10.data.o,ov_SC04_005_jr_8016AB6C.o,tail11.data.o,ov_SC04_005_jr_801734BC.o,tail12.data.o,ov_SC04_005_jr_80178D40.o,tail13.data.o,ov_SC04_005_jr_8017A4AC.o,tail14.data.o,ov_SC04_005_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_005/ov_SC04_005_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_005/ov_SC04_005_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_005/ov_SC04_005_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2196,7 +2196,7 @@ ov_SC04_006_ELF := $(ov_SC04_006_OUT).elf ov_SC04_006_MAPFILE := $(ov_SC04_006_OUT).map ov_SC04_006_LD_SCRIPT := $(ov_SC04_006_OUT).ld ov_SC04_006_SPLAT_YAML := config/splat.ov_SC04_006.yaml -ov_SC04_006_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_006_jr_8012ACE0.o,tail2.data.o,ov_SC04_006_jr_801380E0.o,tail3.data.o,ov_SC04_006_jr_8013F350.o,tail4.data.o,ov_SC04_006_jr_8013FFD8.o,tail5.data.o,ov_SC04_006_jr_8015444C.o,tail6.data.o,ov_SC04_006_jr_80159C84.o,tail7.data.o,ov_SC04_006_jr_8015A3C8.o,tail8.data.o,ov_SC04_006_jr_8015AE2C.o,tail9.data.o,ov_SC04_006_jr_8016AB6C.o,tail10.data.o,ov_SC04_006_jr_801734BC.o,tail11.data.o,ov_SC04_006_jr_80178D40.o,tail12.data.o,ov_SC04_006_jr_8017A4AC.o,tail13.data.o,ov_SC04_006_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_006_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_006_jr_8012ACE0.o,tail2.data.o,ov_SC04_006_jr_801380E0.o,tail3.data.o,ov_SC04_006_jr_8013F350.o,tail4.data.o,ov_SC04_006_jr_8013FFD8.o,tail5.data.o,ov_SC04_006_jr_8015444C.o,tail6.data.o,ov_SC04_006_jr_80159C84.o,tail7.data.o,ov_SC04_006_jr_8015A3C8.o,tail8.data.o,ov_SC04_006_jr_8015AE2C.o,tail9.data.o,ov_SC04_006_jr_8015C32C.o,tail10.data.o,ov_SC04_006_jr_8016AB6C.o,tail11.data.o,ov_SC04_006_jr_801734BC.o,tail12.data.o,ov_SC04_006_jr_80178D40.o,tail13.data.o,ov_SC04_006_jr_8017A4AC.o,tail14.data.o,ov_SC04_006_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_006/ov_SC04_006_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_006/ov_SC04_006_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_006/ov_SC04_006_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2221,7 +2221,7 @@ ov_SC04_007_ELF := $(ov_SC04_007_OUT).elf ov_SC04_007_MAPFILE := $(ov_SC04_007_OUT).map ov_SC04_007_LD_SCRIPT := $(ov_SC04_007_OUT).ld ov_SC04_007_SPLAT_YAML := config/splat.ov_SC04_007.yaml -ov_SC04_007_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_007_jr_8012ACE0.o,tail2.data.o,ov_SC04_007_jr_801380E0.o,tail3.data.o,ov_SC04_007_jr_8013F350.o,tail4.data.o,ov_SC04_007_jr_8013FFD8.o,tail5.data.o,ov_SC04_007_jr_8015444C.o,tail6.data.o,ov_SC04_007_jr_80159C84.o,tail7.data.o,ov_SC04_007_jr_8015A3C8.o,tail8.data.o,ov_SC04_007_jr_8015AE2C.o,tail9.data.o,ov_SC04_007_jr_8016AB6C.o,tail10.data.o,ov_SC04_007_jr_801734BC.o,tail11.data.o,ov_SC04_007_jr_80178D40.o,tail12.data.o,ov_SC04_007_jr_8017A4AC.o,tail13.data.o,ov_SC04_007_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_007_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_007_jr_8012ACE0.o,tail2.data.o,ov_SC04_007_jr_801380E0.o,tail3.data.o,ov_SC04_007_jr_8013F350.o,tail4.data.o,ov_SC04_007_jr_8013FFD8.o,tail5.data.o,ov_SC04_007_jr_8015444C.o,tail6.data.o,ov_SC04_007_jr_80159C84.o,tail7.data.o,ov_SC04_007_jr_8015A3C8.o,tail8.data.o,ov_SC04_007_jr_8015AE2C.o,tail9.data.o,ov_SC04_007_jr_8015C32C.o,tail10.data.o,ov_SC04_007_jr_8016AB6C.o,tail11.data.o,ov_SC04_007_jr_801734BC.o,tail12.data.o,ov_SC04_007_jr_80178D40.o,tail13.data.o,ov_SC04_007_jr_8017A4AC.o,tail14.data.o,ov_SC04_007_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_007/ov_SC04_007_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_007/ov_SC04_007_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_007/ov_SC04_007_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2246,7 +2246,7 @@ ov_SC04_008_ELF := $(ov_SC04_008_OUT).elf ov_SC04_008_MAPFILE := $(ov_SC04_008_OUT).map ov_SC04_008_LD_SCRIPT := $(ov_SC04_008_OUT).ld ov_SC04_008_SPLAT_YAML := config/splat.ov_SC04_008.yaml -ov_SC04_008_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_008_jr_8012ACE0.o,tail2.data.o,ov_SC04_008_jr_801380E0.o,tail3.data.o,ov_SC04_008_jr_8013F350.o,tail4.data.o,ov_SC04_008_jr_8013FFD8.o,tail5.data.o,ov_SC04_008_jr_8015444C.o,tail6.data.o,ov_SC04_008_jr_80159C84.o,tail7.data.o,ov_SC04_008_jr_8015AE2C.o,tail8.data.o,ov_SC04_008_jr_8016AB6C.o,tail9.data.o,ov_SC04_008_jr_801734BC.o,tail10.data.o,ov_SC04_008_jr_80178D40.o,tail11.data.o,ov_SC04_008_jr_8017A4AC.o,tail12.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_008_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_008_jr_8012ACE0.o,tail2.data.o,ov_SC04_008_jr_801380E0.o,tail3.data.o,ov_SC04_008_jr_8013F350.o,tail4.data.o,ov_SC04_008_jr_8013FFD8.o,tail5.data.o,ov_SC04_008_jr_8015444C.o,tail6.data.o,ov_SC04_008_jr_80159C84.o,tail7.data.o,ov_SC04_008_jr_8015AE2C.o,tail8.data.o,ov_SC04_008_jr_8015C32C.o,tail9.data.o,ov_SC04_008_jr_8016AB6C.o,tail10.data.o,ov_SC04_008_jr_801734BC.o,tail11.data.o,ov_SC04_008_jr_80178D40.o,tail12.data.o,ov_SC04_008_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_008/ov_SC04_008_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_008/ov_SC04_008_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_008/ov_SC04_008_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2271,7 +2271,7 @@ ov_SC04_009_ELF := $(ov_SC04_009_OUT).elf ov_SC04_009_MAPFILE := $(ov_SC04_009_OUT).map ov_SC04_009_LD_SCRIPT := $(ov_SC04_009_OUT).ld ov_SC04_009_SPLAT_YAML := config/splat.ov_SC04_009.yaml -ov_SC04_009_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_009_jr_8012ACE0.o,tail2.data.o,ov_SC04_009_jr_801380E0.o,tail3.data.o,ov_SC04_009_jr_8013F350.o,tail4.data.o,ov_SC04_009_jr_8013FFD8.o,tail5.data.o,ov_SC04_009_jr_8015444C.o,tail6.data.o,ov_SC04_009_jr_80159C84.o,tail7.data.o,ov_SC04_009_jr_8015A3C8.o,tail8.data.o,ov_SC04_009_jr_8015AE2C.o,tail9.data.o,ov_SC04_009_jr_8016AB6C.o,tail10.data.o,ov_SC04_009_jr_801734BC.o,tail11.data.o,ov_SC04_009_jr_80178D40.o,tail12.data.o,ov_SC04_009_jr_8017A4AC.o,tail13.data.o,ov_SC04_009_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_009_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_009_jr_8012ACE0.o,tail2.data.o,ov_SC04_009_jr_801380E0.o,tail3.data.o,ov_SC04_009_jr_8013F350.o,tail4.data.o,ov_SC04_009_jr_8013FFD8.o,tail5.data.o,ov_SC04_009_jr_8015444C.o,tail6.data.o,ov_SC04_009_jr_80159C84.o,tail7.data.o,ov_SC04_009_jr_8015A3C8.o,tail8.data.o,ov_SC04_009_jr_8015AE2C.o,tail9.data.o,ov_SC04_009_jr_8015C32C.o,tail10.data.o,ov_SC04_009_jr_8016AB6C.o,tail11.data.o,ov_SC04_009_jr_801734BC.o,tail12.data.o,ov_SC04_009_jr_80178D40.o,tail13.data.o,ov_SC04_009_jr_8017A4AC.o,tail14.data.o,ov_SC04_009_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_009/ov_SC04_009_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_009/ov_SC04_009_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_009/ov_SC04_009_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2296,7 +2296,7 @@ ov_SC04_010_ELF := $(ov_SC04_010_OUT).elf ov_SC04_010_MAPFILE := $(ov_SC04_010_OUT).map ov_SC04_010_LD_SCRIPT := $(ov_SC04_010_OUT).ld ov_SC04_010_SPLAT_YAML := config/splat.ov_SC04_010.yaml -ov_SC04_010_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_010_jr_8012ACE0.o,tail2.data.o,ov_SC04_010_jr_801380E0.o,tail3.data.o,ov_SC04_010_jr_8013F350.o,tail4.data.o,ov_SC04_010_jr_8013FFD8.o,tail5.data.o,ov_SC04_010_jr_8015444C.o,tail6.data.o,ov_SC04_010_jr_80159C84.o,tail7.data.o,ov_SC04_010_jr_8015A3C8.o,tail8.data.o,ov_SC04_010_jr_8015AE2C.o,tail9.data.o,ov_SC04_010_jr_8016AB6C.o,tail10.data.o,ov_SC04_010_jr_801734BC.o,tail11.data.o,ov_SC04_010_jr_80178D40.o,tail12.data.o,ov_SC04_010_jr_8017A4AC.o,tail13.data.o,ov_SC04_010_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_010_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_010_jr_8012ACE0.o,tail2.data.o,ov_SC04_010_jr_801380E0.o,tail3.data.o,ov_SC04_010_jr_8013F350.o,tail4.data.o,ov_SC04_010_jr_8013FFD8.o,tail5.data.o,ov_SC04_010_jr_8015444C.o,tail6.data.o,ov_SC04_010_jr_80159C84.o,tail7.data.o,ov_SC04_010_jr_8015A3C8.o,tail8.data.o,ov_SC04_010_jr_8015AE2C.o,tail9.data.o,ov_SC04_010_jr_8015C32C.o,tail10.data.o,ov_SC04_010_jr_8016AB6C.o,tail11.data.o,ov_SC04_010_jr_801734BC.o,tail12.data.o,ov_SC04_010_jr_80178D40.o,tail13.data.o,ov_SC04_010_jr_8017A4AC.o,tail14.data.o,ov_SC04_010_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_010/ov_SC04_010_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_010/ov_SC04_010_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_010/ov_SC04_010_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2321,7 +2321,7 @@ ov_SC04_011_ELF := $(ov_SC04_011_OUT).elf ov_SC04_011_MAPFILE := $(ov_SC04_011_OUT).map ov_SC04_011_LD_SCRIPT := $(ov_SC04_011_OUT).ld ov_SC04_011_SPLAT_YAML := config/splat.ov_SC04_011.yaml -ov_SC04_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_011_jr_8012ACE0.o,tail2.data.o,ov_SC04_011_jr_801380E0.o,tail3.data.o,ov_SC04_011_jr_8013F350.o,tail4.data.o,ov_SC04_011_jr_8013FFD8.o,tail5.data.o,ov_SC04_011_jr_8015444C.o,tail6.data.o,ov_SC04_011_jr_80159C84.o,tail7.data.o,ov_SC04_011_jr_8015A3C8.o,tail8.data.o,ov_SC04_011_jr_8015AE2C.o,tail9.data.o,ov_SC04_011_jr_8016AB6C.o,tail10.data.o,ov_SC04_011_jr_801734BC.o,tail11.data.o,ov_SC04_011_jr_80178D40.o,tail12.data.o,ov_SC04_011_jr_8017A4AC.o,tail13.data.o,ov_SC04_011_jr_8017D494.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_011_jr_8012ACE0.o,tail2.data.o,ov_SC04_011_jr_801380E0.o,tail3.data.o,ov_SC04_011_jr_8013F350.o,tail4.data.o,ov_SC04_011_jr_8013FFD8.o,tail5.data.o,ov_SC04_011_jr_8015444C.o,tail6.data.o,ov_SC04_011_jr_80159C84.o,tail7.data.o,ov_SC04_011_jr_8015A3C8.o,tail8.data.o,ov_SC04_011_jr_8015AE2C.o,tail9.data.o,ov_SC04_011_jr_8015C32C.o,tail10.data.o,ov_SC04_011_jr_8016AB6C.o,tail11.data.o,ov_SC04_011_jr_801734BC.o,tail12.data.o,ov_SC04_011_jr_80178D40.o,tail13.data.o,ov_SC04_011_jr_8017A4AC.o,tail14.data.o,ov_SC04_011_jr_8017D494.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_011/ov_SC04_011_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_011/ov_SC04_011_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_011/ov_SC04_011_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2346,7 +2346,7 @@ ov_SC04_012_ELF := $(ov_SC04_012_OUT).elf ov_SC04_012_MAPFILE := $(ov_SC04_012_OUT).map ov_SC04_012_LD_SCRIPT := $(ov_SC04_012_OUT).ld ov_SC04_012_SPLAT_YAML := config/splat.ov_SC04_012.yaml -ov_SC04_012_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_012_jr_8012ACE0.o,tail2.data.o,ov_SC04_012_jr_801380E0.o,tail3.data.o,ov_SC04_012_jr_8013F350.o,tail4.data.o,ov_SC04_012_jr_8013FFD8.o,tail5.data.o,ov_SC04_012_jr_8015444C.o,tail6.data.o,ov_SC04_012_jr_80159C84.o,tail7.data.o,ov_SC04_012_jr_8015A3C8.o,tail8.data.o,ov_SC04_012_jr_8015AE2C.o,tail9.data.o,ov_SC04_012_jr_8016AB6C.o,tail10.data.o,ov_SC04_012_jr_801734BC.o,tail11.data.o,ov_SC04_012_jr_80178D40.o,tail12.data.o,ov_SC04_012_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_012_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_012_jr_8012ACE0.o,tail2.data.o,ov_SC04_012_jr_801380E0.o,tail3.data.o,ov_SC04_012_jr_8013F350.o,tail4.data.o,ov_SC04_012_jr_8013FFD8.o,tail5.data.o,ov_SC04_012_jr_8015444C.o,tail6.data.o,ov_SC04_012_jr_80159C84.o,tail7.data.o,ov_SC04_012_jr_8015A3C8.o,tail8.data.o,ov_SC04_012_jr_8015AE2C.o,tail9.data.o,ov_SC04_012_jr_8015C32C.o,tail10.data.o,ov_SC04_012_jr_8016AB6C.o,tail11.data.o,ov_SC04_012_jr_801734BC.o,tail12.data.o,ov_SC04_012_jr_80178D40.o,tail13.data.o,ov_SC04_012_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_012/ov_SC04_012_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_012/ov_SC04_012_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_012/ov_SC04_012_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2371,7 +2371,7 @@ ov_SC04_015_ELF := $(ov_SC04_015_OUT).elf ov_SC04_015_MAPFILE := $(ov_SC04_015_OUT).map ov_SC04_015_LD_SCRIPT := $(ov_SC04_015_OUT).ld ov_SC04_015_SPLAT_YAML := config/splat.ov_SC04_015.yaml -ov_SC04_015_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_015_jr_8012ACE0.o,tail2.data.o,ov_SC04_015_jr_801380E0.o,tail3.data.o,ov_SC04_015_jr_8013F350.o,tail4.data.o,ov_SC04_015_jr_8013FFD8.o,tail5.data.o,ov_SC04_015_jr_8015444C.o,tail6.data.o,ov_SC04_015_jr_80159C84.o,tail7.data.o,ov_SC04_015_jr_8015A3C8.o,tail8.data.o,ov_SC04_015_jr_8015AE2C.o,tail9.data.o,ov_SC04_015_jr_8016AB6C.o,tail10.data.o,ov_SC04_015_jr_801734BC.o,tail11.data.o,ov_SC04_015_jr_80178D40.o,tail12.data.o,ov_SC04_015_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_015_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_015_jr_8012ACE0.o,tail2.data.o,ov_SC04_015_jr_801380E0.o,tail3.data.o,ov_SC04_015_jr_8013F350.o,tail4.data.o,ov_SC04_015_jr_8013FFD8.o,tail5.data.o,ov_SC04_015_jr_8015444C.o,tail6.data.o,ov_SC04_015_jr_80159C84.o,tail7.data.o,ov_SC04_015_jr_8015A3C8.o,tail8.data.o,ov_SC04_015_jr_8015AE2C.o,tail9.data.o,ov_SC04_015_jr_8015C32C.o,tail10.data.o,ov_SC04_015_jr_8016AB6C.o,tail11.data.o,ov_SC04_015_jr_801734BC.o,tail12.data.o,ov_SC04_015_jr_80178D40.o,tail13.data.o,ov_SC04_015_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_015/ov_SC04_015_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_015/ov_SC04_015_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_015/ov_SC04_015_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2396,7 +2396,7 @@ ov_SC04_016_ELF := $(ov_SC04_016_OUT).elf ov_SC04_016_MAPFILE := $(ov_SC04_016_OUT).map ov_SC04_016_LD_SCRIPT := $(ov_SC04_016_OUT).ld ov_SC04_016_SPLAT_YAML := config/splat.ov_SC04_016.yaml -ov_SC04_016_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_016_jr_8012ACE0.o,tail2.data.o,ov_SC04_016_jr_801380E0.o,tail3.data.o,ov_SC04_016_jr_8013F350.o,tail4.data.o,ov_SC04_016_jr_8013FFD8.o,tail5.data.o,ov_SC04_016_jr_8015444C.o,tail6.data.o,ov_SC04_016_jr_80159C84.o,tail7.data.o,ov_SC04_016_jr_8015A3C8.o,tail8.data.o,ov_SC04_016_jr_8015AE2C.o,tail9.data.o,ov_SC04_016_jr_8016AB6C.o,tail10.data.o,ov_SC04_016_jr_801734BC.o,tail11.data.o,ov_SC04_016_jr_80178D40.o,tail12.data.o,ov_SC04_016_jr_8017A4AC.o,tail13.data.o,ov_SC04_016_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_016_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_016_jr_8012ACE0.o,tail2.data.o,ov_SC04_016_jr_801380E0.o,tail3.data.o,ov_SC04_016_jr_8013F350.o,tail4.data.o,ov_SC04_016_jr_8013FFD8.o,tail5.data.o,ov_SC04_016_jr_8015444C.o,tail6.data.o,ov_SC04_016_jr_80159C84.o,tail7.data.o,ov_SC04_016_jr_8015A3C8.o,tail8.data.o,ov_SC04_016_jr_8015AE2C.o,tail9.data.o,ov_SC04_016_jr_8015C32C.o,tail10.data.o,ov_SC04_016_jr_8016AB6C.o,tail11.data.o,ov_SC04_016_jr_801734BC.o,tail12.data.o,ov_SC04_016_jr_80178D40.o,tail13.data.o,ov_SC04_016_jr_8017A4AC.o,tail14.data.o,ov_SC04_016_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_016/ov_SC04_016_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_016/ov_SC04_016_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_016/ov_SC04_016_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2421,7 +2421,7 @@ ov_SC04_020_ELF := $(ov_SC04_020_OUT).elf ov_SC04_020_MAPFILE := $(ov_SC04_020_OUT).map ov_SC04_020_LD_SCRIPT := $(ov_SC04_020_OUT).ld ov_SC04_020_SPLAT_YAML := config/splat.ov_SC04_020.yaml -ov_SC04_020_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_020_jr_8012ACE0.o,tail2.data.o,ov_SC04_020_jr_801380E0.o,tail3.data.o,ov_SC04_020_jr_8013F350.o,tail4.data.o,ov_SC04_020_jr_8013FFD8.o,tail5.data.o,ov_SC04_020_jr_8015444C.o,tail6.data.o,ov_SC04_020_jr_80159C84.o,tail7.data.o,ov_SC04_020_jr_8015A3C8.o,tail8.data.o,ov_SC04_020_jr_8015AE2C.o,tail9.data.o,ov_SC04_020_jr_8016AB6C.o,tail10.data.o,ov_SC04_020_jr_801734BC.o,tail11.data.o,ov_SC04_020_jr_80178D40.o,tail12.data.o,ov_SC04_020_jr_8017A4AC.o,tail13.data.o,ov_SC04_020_jr_8017D604.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_020_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_020_jr_8012ACE0.o,tail2.data.o,ov_SC04_020_jr_801380E0.o,tail3.data.o,ov_SC04_020_jr_8013F350.o,tail4.data.o,ov_SC04_020_jr_8013FFD8.o,tail5.data.o,ov_SC04_020_jr_8015444C.o,tail6.data.o,ov_SC04_020_jr_80159C84.o,tail7.data.o,ov_SC04_020_jr_8015A3C8.o,tail8.data.o,ov_SC04_020_jr_8015AE2C.o,tail9.data.o,ov_SC04_020_jr_8015C32C.o,tail10.data.o,ov_SC04_020_jr_8016AB6C.o,tail11.data.o,ov_SC04_020_jr_801734BC.o,tail12.data.o,ov_SC04_020_jr_80178D40.o,tail13.data.o,ov_SC04_020_jr_8017A4AC.o,tail14.data.o,ov_SC04_020_jr_8017D604.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_020/ov_SC04_020_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_020/ov_SC04_020_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_020/ov_SC04_020_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2446,7 +2446,7 @@ ov_SC04_021_ELF := $(ov_SC04_021_OUT).elf ov_SC04_021_MAPFILE := $(ov_SC04_021_OUT).map ov_SC04_021_LD_SCRIPT := $(ov_SC04_021_OUT).ld ov_SC04_021_SPLAT_YAML := config/splat.ov_SC04_021.yaml -ov_SC04_021_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_021_jr_8012ACE0.o,tail2.data.o,ov_SC04_021_jr_801380E0.o,tail3.data.o,ov_SC04_021_jr_8013F350.o,tail4.data.o,ov_SC04_021_jr_8013FFD8.o,tail5.data.o,ov_SC04_021_jr_8015444C.o,tail6.data.o,ov_SC04_021_jr_80159C84.o,tail7.data.o,ov_SC04_021_jr_8015A3C8.o,tail8.data.o,ov_SC04_021_jr_8015AE2C.o,tail9.data.o,ov_SC04_021_jr_8016AB6C.o,tail10.data.o,ov_SC04_021_jr_801734BC.o,tail11.data.o,ov_SC04_021_jr_80178D40.o,tail12.data.o,ov_SC04_021_jr_8017A4AC.o,tail13.data.o,ov_SC04_021_jr_8017D5C0.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC04_021_JTBL_INTERLEAVE := --order tail.data.o,ov_SC04_021_jr_8012ACE0.o,tail2.data.o,ov_SC04_021_jr_801380E0.o,tail3.data.o,ov_SC04_021_jr_8013F350.o,tail4.data.o,ov_SC04_021_jr_8013FFD8.o,tail5.data.o,ov_SC04_021_jr_8015444C.o,tail6.data.o,ov_SC04_021_jr_80159C84.o,tail7.data.o,ov_SC04_021_jr_8015A3C8.o,tail8.data.o,ov_SC04_021_jr_8015AE2C.o,tail9.data.o,ov_SC04_021_jr_8015C32C.o,tail10.data.o,ov_SC04_021_jr_8016AB6C.o,tail11.data.o,ov_SC04_021_jr_801734BC.o,tail12.data.o,ov_SC04_021_jr_80178D40.o,tail13.data.o,ov_SC04_021_jr_8017A4AC.o,tail14.data.o,ov_SC04_021_jr_8017D5C0.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC04_021/ov_SC04_021_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC04_021/ov_SC04_021_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC04_021/ov_SC04_021_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2471,7 +2471,7 @@ ov_SC05_001_ELF := $(ov_SC05_001_OUT).elf ov_SC05_001_MAPFILE := $(ov_SC05_001_OUT).map ov_SC05_001_LD_SCRIPT := $(ov_SC05_001_OUT).ld ov_SC05_001_SPLAT_YAML := config/splat.ov_SC05_001.yaml -ov_SC05_001_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_001_jr_8012ACE0.o,tail2.data.o,ov_SC05_001_jr_801380E0.o,tail3.data.o,ov_SC05_001_jr_8013F350.o,tail4.data.o,ov_SC05_001_jr_8013FFD8.o,tail5.data.o,ov_SC05_001_jr_8015444C.o,tail6.data.o,ov_SC05_001_jr_80159C84.o,tail7.data.o,ov_SC05_001_jr_8015A3C8.o,tail8.data.o,ov_SC05_001_jr_8015AE2C.o,tail9.data.o,ov_SC05_001_jr_8016AB6C.o,tail10.data.o,ov_SC05_001_jr_801734BC.o,tail11.data.o,ov_SC05_001_jr_80178D40.o,tail12.data.o,ov_SC05_001_jr_8017A4AC.o,tail13.data.o,ov_SC05_001_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_001_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_001_jr_8012ACE0.o,tail2.data.o,ov_SC05_001_jr_801380E0.o,tail3.data.o,ov_SC05_001_jr_8013F350.o,tail4.data.o,ov_SC05_001_jr_8013FFD8.o,tail5.data.o,ov_SC05_001_jr_8015444C.o,tail6.data.o,ov_SC05_001_jr_80159C84.o,tail7.data.o,ov_SC05_001_jr_8015A3C8.o,tail8.data.o,ov_SC05_001_jr_8015AE2C.o,tail9.data.o,ov_SC05_001_jr_8015C32C.o,tail10.data.o,ov_SC05_001_jr_8016AB6C.o,tail11.data.o,ov_SC05_001_jr_801734BC.o,tail12.data.o,ov_SC05_001_jr_80178D40.o,tail13.data.o,ov_SC05_001_jr_8017A4AC.o,tail14.data.o,ov_SC05_001_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_001/ov_SC05_001_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_001/ov_SC05_001_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_001/ov_SC05_001_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2496,7 +2496,7 @@ ov_SC05_002_ELF := $(ov_SC05_002_OUT).elf ov_SC05_002_MAPFILE := $(ov_SC05_002_OUT).map ov_SC05_002_LD_SCRIPT := $(ov_SC05_002_OUT).ld ov_SC05_002_SPLAT_YAML := config/splat.ov_SC05_002.yaml -ov_SC05_002_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_002_jr_8012ACE0.o,tail2.data.o,ov_SC05_002_jr_801380E0.o,tail3.data.o,ov_SC05_002_jr_8013F350.o,tail4.data.o,ov_SC05_002_jr_8013FFD8.o,tail5.data.o,ov_SC05_002_jr_8015444C.o,tail6.data.o,ov_SC05_002_jr_80159C84.o,tail7.data.o,ov_SC05_002_jr_8015A3C8.o,tail8.data.o,ov_SC05_002_jr_8015AE2C.o,tail9.data.o,ov_SC05_002_jr_8016AB6C.o,tail10.data.o,ov_SC05_002_jr_801734BC.o,tail11.data.o,ov_SC05_002_jr_80178D40.o,tail12.data.o,ov_SC05_002_jr_8017A4AC.o,tail13.data.o,ov_SC05_002_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_002_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_002_jr_8012ACE0.o,tail2.data.o,ov_SC05_002_jr_801380E0.o,tail3.data.o,ov_SC05_002_jr_8013F350.o,tail4.data.o,ov_SC05_002_jr_8013FFD8.o,tail5.data.o,ov_SC05_002_jr_8015444C.o,tail6.data.o,ov_SC05_002_jr_80159C84.o,tail7.data.o,ov_SC05_002_jr_8015A3C8.o,tail8.data.o,ov_SC05_002_jr_8015AE2C.o,tail9.data.o,ov_SC05_002_jr_8015C32C.o,tail10.data.o,ov_SC05_002_jr_8016AB6C.o,tail11.data.o,ov_SC05_002_jr_801734BC.o,tail12.data.o,ov_SC05_002_jr_80178D40.o,tail13.data.o,ov_SC05_002_jr_8017A4AC.o,tail14.data.o,ov_SC05_002_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_002/ov_SC05_002_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_002/ov_SC05_002_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_002/ov_SC05_002_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2521,7 +2521,7 @@ ov_SC05_003_ELF := $(ov_SC05_003_OUT).elf ov_SC05_003_MAPFILE := $(ov_SC05_003_OUT).map ov_SC05_003_LD_SCRIPT := $(ov_SC05_003_OUT).ld ov_SC05_003_SPLAT_YAML := config/splat.ov_SC05_003.yaml -ov_SC05_003_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_003_jr_8012ACE0.o,tail2.data.o,ov_SC05_003_jr_801380E0.o,tail3.data.o,ov_SC05_003_jr_8013F350.o,tail4.data.o,ov_SC05_003_jr_8013FFD8.o,tail5.data.o,ov_SC05_003_jr_8015444C.o,tail6.data.o,ov_SC05_003_jr_80159C84.o,tail7.data.o,ov_SC05_003_jr_8015A3C8.o,tail8.data.o,ov_SC05_003_jr_8015AE2C.o,tail9.data.o,ov_SC05_003_jr_8016AB6C.o,tail10.data.o,ov_SC05_003_jr_801734BC.o,tail11.data.o,ov_SC05_003_jr_80178D40.o,tail12.data.o,ov_SC05_003_jr_8017A4AC.o,tail13.data.o,ov_SC05_003_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_003_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_003_jr_8012ACE0.o,tail2.data.o,ov_SC05_003_jr_801380E0.o,tail3.data.o,ov_SC05_003_jr_8013F350.o,tail4.data.o,ov_SC05_003_jr_8013FFD8.o,tail5.data.o,ov_SC05_003_jr_8015444C.o,tail6.data.o,ov_SC05_003_jr_80159C84.o,tail7.data.o,ov_SC05_003_jr_8015A3C8.o,tail8.data.o,ov_SC05_003_jr_8015AE2C.o,tail9.data.o,ov_SC05_003_jr_8015C32C.o,tail10.data.o,ov_SC05_003_jr_8016AB6C.o,tail11.data.o,ov_SC05_003_jr_801734BC.o,tail12.data.o,ov_SC05_003_jr_80178D40.o,tail13.data.o,ov_SC05_003_jr_8017A4AC.o,tail14.data.o,ov_SC05_003_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_003/ov_SC05_003_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_003/ov_SC05_003_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_003/ov_SC05_003_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2546,7 +2546,7 @@ ov_SC05_004_ELF := $(ov_SC05_004_OUT).elf ov_SC05_004_MAPFILE := $(ov_SC05_004_OUT).map ov_SC05_004_LD_SCRIPT := $(ov_SC05_004_OUT).ld ov_SC05_004_SPLAT_YAML := config/splat.ov_SC05_004.yaml -ov_SC05_004_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_004_jr_8012ACE0.o,tail2.data.o,ov_SC05_004_jr_801380E0.o,tail3.data.o,ov_SC05_004_jr_8013F350.o,tail4.data.o,ov_SC05_004_jr_8015444C.o,tail5.data.o,ov_SC05_004_jr_80159C84.o,tail6.data.o,ov_SC05_004_jr_8015A3C8.o,tail7.data.o,ov_SC05_004_jr_8015AE2C.o,tail8.data.o,ov_SC05_004_jr_8016AB6C.o,tail9.data.o,ov_SC05_004_jr_801734BC.o,tail10.data.o,ov_SC05_004_jr_80178D40.o,tail11.data.o,ov_SC05_004_jr_8017A4AC.o,tail12.data.o,ov_SC05_004_jr_8017BEBC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_004_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_004_jr_8012ACE0.o,tail2.data.o,ov_SC05_004_jr_801380E0.o,tail3.data.o,ov_SC05_004_jr_8013F350.o,tail4.data.o,ov_SC05_004_jr_8015444C.o,tail5.data.o,ov_SC05_004_jr_80159C84.o,tail6.data.o,ov_SC05_004_jr_8015A3C8.o,tail7.data.o,ov_SC05_004_jr_8015AE2C.o,tail8.data.o,ov_SC05_004_jr_8015C32C.o,tail9.data.o,ov_SC05_004_jr_8016AB6C.o,tail10.data.o,ov_SC05_004_jr_801734BC.o,tail11.data.o,ov_SC05_004_jr_80178D40.o,tail12.data.o,ov_SC05_004_jr_8017A4AC.o,tail13.data.o,ov_SC05_004_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_004/ov_SC05_004_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_004/ov_SC05_004_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_004/ov_SC05_004_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2571,7 +2571,7 @@ ov_SC05_005_ELF := $(ov_SC05_005_OUT).elf ov_SC05_005_MAPFILE := $(ov_SC05_005_OUT).map ov_SC05_005_LD_SCRIPT := $(ov_SC05_005_OUT).ld ov_SC05_005_SPLAT_YAML := config/splat.ov_SC05_005.yaml -ov_SC05_005_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_005_jr_8012ACE0.o,tail2.data.o,ov_SC05_005_jr_801380E0.o,tail3.data.o,ov_SC05_005_jr_8013F350.o,tail4.data.o,ov_SC05_005_jr_8013FFD8.o,tail5.data.o,ov_SC05_005_jr_8015444C.o,tail6.data.o,ov_SC05_005_jr_80159C84.o,tail7.data.o,ov_SC05_005_jr_8015A3C8.o,tail8.data.o,ov_SC05_005_jr_8015AE2C.o,tail9.data.o,ov_SC05_005_jr_8016AB6C.o,tail10.data.o,ov_SC05_005_jr_801734BC.o,tail11.data.o,ov_SC05_005_jr_80178D40.o,tail12.data.o,ov_SC05_005_jr_8017A4AC.o,tail13.data.o,ov_SC05_005_jr_8017D898.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_005_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_005_jr_8012ACE0.o,tail2.data.o,ov_SC05_005_jr_801380E0.o,tail3.data.o,ov_SC05_005_jr_8013F350.o,tail4.data.o,ov_SC05_005_jr_8013FFD8.o,tail5.data.o,ov_SC05_005_jr_8015444C.o,tail6.data.o,ov_SC05_005_jr_80159C84.o,tail7.data.o,ov_SC05_005_jr_8015A3C8.o,tail8.data.o,ov_SC05_005_jr_8015AE2C.o,tail9.data.o,ov_SC05_005_jr_8015C32C.o,tail10.data.o,ov_SC05_005_jr_8016AB6C.o,tail11.data.o,ov_SC05_005_jr_801734BC.o,tail12.data.o,ov_SC05_005_jr_80178D40.o,tail13.data.o,ov_SC05_005_jr_8017A4AC.o,tail14.data.o,ov_SC05_005_jr_8017D898.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_005/ov_SC05_005_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_005/ov_SC05_005_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_005/ov_SC05_005_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2596,7 +2596,7 @@ ov_SC05_006_ELF := $(ov_SC05_006_OUT).elf ov_SC05_006_MAPFILE := $(ov_SC05_006_OUT).map ov_SC05_006_LD_SCRIPT := $(ov_SC05_006_OUT).ld ov_SC05_006_SPLAT_YAML := config/splat.ov_SC05_006.yaml -ov_SC05_006_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_006_jr_8012ACE0.o,tail2.data.o,ov_SC05_006_jr_801380E0.o,tail3.data.o,ov_SC05_006_jr_8013F350.o,tail4.data.o,ov_SC05_006_jr_8013FFD8.o,tail5.data.o,ov_SC05_006_jr_8015444C.o,tail6.data.o,ov_SC05_006_jr_80159C84.o,tail7.data.o,ov_SC05_006_jr_8015A3C8.o,tail8.data.o,ov_SC05_006_jr_8015AE2C.o,tail9.data.o,ov_SC05_006_jr_8016AB6C.o,tail10.data.o,ov_SC05_006_jr_801734BC.o,tail11.data.o,ov_SC05_006_jr_80178D40.o,tail12.data.o,ov_SC05_006_jr_8017A4AC.o,tail13.data.o,ov_SC05_006_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_006_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_006_jr_8012ACE0.o,tail2.data.o,ov_SC05_006_jr_801380E0.o,tail3.data.o,ov_SC05_006_jr_8013F350.o,tail4.data.o,ov_SC05_006_jr_8013FFD8.o,tail5.data.o,ov_SC05_006_jr_8015444C.o,tail6.data.o,ov_SC05_006_jr_80159C84.o,tail7.data.o,ov_SC05_006_jr_8015A3C8.o,tail8.data.o,ov_SC05_006_jr_8015AE2C.o,tail9.data.o,ov_SC05_006_jr_8015C32C.o,tail10.data.o,ov_SC05_006_jr_8016AB6C.o,tail11.data.o,ov_SC05_006_jr_801734BC.o,tail12.data.o,ov_SC05_006_jr_80178D40.o,tail13.data.o,ov_SC05_006_jr_8017A4AC.o,tail14.data.o,ov_SC05_006_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_006/ov_SC05_006_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_006/ov_SC05_006_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_006/ov_SC05_006_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2621,7 +2621,7 @@ ov_SC05_007_ELF := $(ov_SC05_007_OUT).elf ov_SC05_007_MAPFILE := $(ov_SC05_007_OUT).map ov_SC05_007_LD_SCRIPT := $(ov_SC05_007_OUT).ld ov_SC05_007_SPLAT_YAML := config/splat.ov_SC05_007.yaml -ov_SC05_007_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_007_jr_8012ACE0.o,tail2.data.o,ov_SC05_007_jr_801380E0.o,tail3.data.o,ov_SC05_007_jr_8013F350.o,tail4.data.o,ov_SC05_007_jr_8013FFD8.o,tail5.data.o,ov_SC05_007_jr_8015444C.o,tail6.data.o,ov_SC05_007_jr_80159C84.o,tail7.data.o,ov_SC05_007_jr_8015A3C8.o,tail8.data.o,ov_SC05_007_jr_8015AE2C.o,tail9.data.o,ov_SC05_007_jr_8016AB6C.o,tail10.data.o,ov_SC05_007_jr_801734BC.o,tail11.data.o,ov_SC05_007_jr_80178D40.o,tail12.data.o,ov_SC05_007_jr_8017A4AC.o,tail13.data.o,ov_SC05_007_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_007_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_007_jr_8012ACE0.o,tail2.data.o,ov_SC05_007_jr_801380E0.o,tail3.data.o,ov_SC05_007_jr_8013F350.o,tail4.data.o,ov_SC05_007_jr_8013FFD8.o,tail5.data.o,ov_SC05_007_jr_8015444C.o,tail6.data.o,ov_SC05_007_jr_80159C84.o,tail7.data.o,ov_SC05_007_jr_8015A3C8.o,tail8.data.o,ov_SC05_007_jr_8015AE2C.o,tail9.data.o,ov_SC05_007_jr_8015C32C.o,tail10.data.o,ov_SC05_007_jr_8016AB6C.o,tail11.data.o,ov_SC05_007_jr_801734BC.o,tail12.data.o,ov_SC05_007_jr_80178D40.o,tail13.data.o,ov_SC05_007_jr_8017A4AC.o,tail14.data.o,ov_SC05_007_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_007/ov_SC05_007_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_007/ov_SC05_007_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_007/ov_SC05_007_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2646,7 +2646,7 @@ ov_SC05_008_ELF := $(ov_SC05_008_OUT).elf ov_SC05_008_MAPFILE := $(ov_SC05_008_OUT).map ov_SC05_008_LD_SCRIPT := $(ov_SC05_008_OUT).ld ov_SC05_008_SPLAT_YAML := config/splat.ov_SC05_008.yaml -ov_SC05_008_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_008_jr_8012ACE0.o,tail2.data.o,ov_SC05_008_jr_801380E0.o,tail3.data.o,ov_SC05_008_jr_8013F350.o,tail4.data.o,ov_SC05_008_jr_8013FFD8.o,tail5.data.o,ov_SC05_008_jr_8015444C.o,tail6.data.o,ov_SC05_008_jr_80159C84.o,tail7.data.o,ov_SC05_008_jr_8015A3C8.o,tail8.data.o,ov_SC05_008_jr_8015AE2C.o,tail9.data.o,ov_SC05_008_jr_8016AB6C.o,tail10.data.o,ov_SC05_008_jr_801734BC.o,tail11.data.o,ov_SC05_008_jr_80178D40.o,tail12.data.o,ov_SC05_008_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_008_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_008_jr_8012ACE0.o,tail2.data.o,ov_SC05_008_jr_801380E0.o,tail3.data.o,ov_SC05_008_jr_8013F350.o,tail4.data.o,ov_SC05_008_jr_8013FFD8.o,tail5.data.o,ov_SC05_008_jr_8015444C.o,tail6.data.o,ov_SC05_008_jr_80159C84.o,tail7.data.o,ov_SC05_008_jr_8015A3C8.o,tail8.data.o,ov_SC05_008_jr_8015AE2C.o,tail9.data.o,ov_SC05_008_jr_8015C32C.o,tail10.data.o,ov_SC05_008_jr_8016AB6C.o,tail11.data.o,ov_SC05_008_jr_801734BC.o,tail12.data.o,ov_SC05_008_jr_80178D40.o,tail13.data.o,ov_SC05_008_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_008/ov_SC05_008_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_008/ov_SC05_008_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_008/ov_SC05_008_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2671,7 +2671,7 @@ ov_SC05_009_ELF := $(ov_SC05_009_OUT).elf ov_SC05_009_MAPFILE := $(ov_SC05_009_OUT).map ov_SC05_009_LD_SCRIPT := $(ov_SC05_009_OUT).ld ov_SC05_009_SPLAT_YAML := config/splat.ov_SC05_009.yaml -ov_SC05_009_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_009_jr_8012ACE0.o,tail2.data.o,ov_SC05_009_jr_801380E0.o,tail3.data.o,ov_SC05_009_jr_8013F350.o,tail4.data.o,ov_SC05_009_jr_8013FFD8.o,tail5.data.o,ov_SC05_009_jr_8015444C.o,tail6.data.o,ov_SC05_009_jr_80159C84.o,tail7.data.o,ov_SC05_009_jr_8015AE2C.o,tail8.data.o,ov_SC05_009_jr_8016AB6C.o,tail9.data.o,ov_SC05_009_jr_801734BC.o,tail10.data.o,ov_SC05_009_jr_80178D40.o,tail11.data.o,ov_SC05_009_jr_8017A4AC.o,tail12.data.o,ov_SC05_009_jr_8017BEBC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_009_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_009_jr_8012ACE0.o,tail2.data.o,ov_SC05_009_jr_801380E0.o,tail3.data.o,ov_SC05_009_jr_8013F350.o,tail4.data.o,ov_SC05_009_jr_8013FFD8.o,tail5.data.o,ov_SC05_009_jr_8015444C.o,tail6.data.o,ov_SC05_009_jr_80159C84.o,tail7.data.o,ov_SC05_009_jr_8015AE2C.o,tail8.data.o,ov_SC05_009_jr_8015C32C.o,tail9.data.o,ov_SC05_009_jr_8016AB6C.o,tail10.data.o,ov_SC05_009_jr_801734BC.o,tail11.data.o,ov_SC05_009_jr_80178D40.o,tail12.data.o,ov_SC05_009_jr_8017A4AC.o,tail13.data.o,ov_SC05_009_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_009/ov_SC05_009_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_009/ov_SC05_009_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_009/ov_SC05_009_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2696,7 +2696,7 @@ ov_SC05_010_ELF := $(ov_SC05_010_OUT).elf ov_SC05_010_MAPFILE := $(ov_SC05_010_OUT).map ov_SC05_010_LD_SCRIPT := $(ov_SC05_010_OUT).ld ov_SC05_010_SPLAT_YAML := config/splat.ov_SC05_010.yaml -ov_SC05_010_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_010_jr_8012ACE0.o,tail2.data.o,ov_SC05_010_jr_801380E0.o,tail3.data.o,ov_SC05_010_jr_8013F350.o,tail4.data.o,ov_SC05_010_jr_8013FFD8.o,tail5.data.o,ov_SC05_010_jr_8015444C.o,tail6.data.o,ov_SC05_010_jr_80159C84.o,tail7.data.o,ov_SC05_010_jr_8015A3C8.o,tail8.data.o,ov_SC05_010_jr_8015AE2C.o,tail9.data.o,ov_SC05_010_jr_8016AB6C.o,tail10.data.o,ov_SC05_010_jr_801734BC.o,tail11.data.o,ov_SC05_010_jr_80178D40.o,tail12.data.o,ov_SC05_010_jr_8017A4AC.o,tail13.data.o,ov_SC05_010_jr_8017C8D0.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_010_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_010_jr_8012ACE0.o,tail2.data.o,ov_SC05_010_jr_801380E0.o,tail3.data.o,ov_SC05_010_jr_8013F350.o,tail4.data.o,ov_SC05_010_jr_8013FFD8.o,tail5.data.o,ov_SC05_010_jr_8015444C.o,tail6.data.o,ov_SC05_010_jr_80159C84.o,tail7.data.o,ov_SC05_010_jr_8015A3C8.o,tail8.data.o,ov_SC05_010_jr_8015AE2C.o,tail9.data.o,ov_SC05_010_jr_8015C32C.o,tail10.data.o,ov_SC05_010_jr_8016AB6C.o,tail11.data.o,ov_SC05_010_jr_801734BC.o,tail12.data.o,ov_SC05_010_jr_80178D40.o,tail13.data.o,ov_SC05_010_jr_8017A4AC.o,tail14.data.o,ov_SC05_010_jr_8017C8D0.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_010/ov_SC05_010_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_010/ov_SC05_010_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_010/ov_SC05_010_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2721,7 +2721,7 @@ ov_SC05_011_ELF := $(ov_SC05_011_OUT).elf ov_SC05_011_MAPFILE := $(ov_SC05_011_OUT).map ov_SC05_011_LD_SCRIPT := $(ov_SC05_011_OUT).ld ov_SC05_011_SPLAT_YAML := config/splat.ov_SC05_011.yaml -ov_SC05_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_011_jr_8012ACE0.o,tail2.data.o,ov_SC05_011_jr_801380E0.o,tail3.data.o,ov_SC05_011_jr_8013F350.o,tail4.data.o,ov_SC05_011_jr_8013FFD8.o,tail5.data.o,ov_SC05_011_jr_8015444C.o,tail6.data.o,ov_SC05_011_jr_80159C84.o,tail7.data.o,ov_SC05_011_jr_8015A3C8.o,tail8.data.o,ov_SC05_011_jr_8015AE2C.o,tail9.data.o,ov_SC05_011_jr_8016AB6C.o,tail10.data.o,ov_SC05_011_jr_801734BC.o,tail11.data.o,ov_SC05_011_jr_80178D40.o,tail12.data.o,ov_SC05_011_jr_8017A4AC.o,tail13.data.o,ov_SC05_011_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_011_jr_8012ACE0.o,tail2.data.o,ov_SC05_011_jr_801380E0.o,tail3.data.o,ov_SC05_011_jr_8013F350.o,tail4.data.o,ov_SC05_011_jr_8013FFD8.o,tail5.data.o,ov_SC05_011_jr_8015444C.o,tail6.data.o,ov_SC05_011_jr_80159C84.o,tail7.data.o,ov_SC05_011_jr_8015A3C8.o,tail8.data.o,ov_SC05_011_jr_8015AE2C.o,tail9.data.o,ov_SC05_011_jr_8015C32C.o,tail10.data.o,ov_SC05_011_jr_8016AB6C.o,tail11.data.o,ov_SC05_011_jr_801734BC.o,tail12.data.o,ov_SC05_011_jr_80178D40.o,tail13.data.o,ov_SC05_011_jr_8017A4AC.o,tail14.data.o,ov_SC05_011_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_011/ov_SC05_011_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_011/ov_SC05_011_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_011/ov_SC05_011_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2746,7 +2746,7 @@ ov_SC05_017_ELF := $(ov_SC05_017_OUT).elf ov_SC05_017_MAPFILE := $(ov_SC05_017_OUT).map ov_SC05_017_LD_SCRIPT := $(ov_SC05_017_OUT).ld ov_SC05_017_SPLAT_YAML := config/splat.ov_SC05_017.yaml -ov_SC05_017_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_017_jr_8012ACE0.o,tail2.data.o,ov_SC05_017_jr_801380E0.o,tail3.data.o,ov_SC05_017_jr_8013F350.o,tail4.data.o,ov_SC05_017_jr_8013FFD8.o,tail5.data.o,ov_SC05_017_jr_8015444C.o,tail6.data.o,ov_SC05_017_jr_80159C84.o,tail7.data.o,ov_SC05_017_jr_8015A3C8.o,tail8.data.o,ov_SC05_017_jr_8015AE2C.o,tail9.data.o,ov_SC05_017_jr_8016AB6C.o,tail10.data.o,ov_SC05_017_jr_801734BC.o,tail11.data.o,ov_SC05_017_jr_80178D40.o,tail12.data.o,ov_SC05_017_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_017_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_017_jr_8012ACE0.o,tail2.data.o,ov_SC05_017_jr_801380E0.o,tail3.data.o,ov_SC05_017_jr_8013F350.o,tail4.data.o,ov_SC05_017_jr_8013FFD8.o,tail5.data.o,ov_SC05_017_jr_8015444C.o,tail6.data.o,ov_SC05_017_jr_80159C84.o,tail7.data.o,ov_SC05_017_jr_8015A3C8.o,tail8.data.o,ov_SC05_017_jr_8015AE2C.o,tail9.data.o,ov_SC05_017_jr_8015C32C.o,tail10.data.o,ov_SC05_017_jr_8016AB6C.o,tail11.data.o,ov_SC05_017_jr_801734BC.o,tail12.data.o,ov_SC05_017_jr_80178D40.o,tail13.data.o,ov_SC05_017_jr_8017A4AC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_017/ov_SC05_017_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_017/ov_SC05_017_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_017/ov_SC05_017_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2771,7 +2771,7 @@ ov_SC05_018_ELF := $(ov_SC05_018_OUT).elf ov_SC05_018_MAPFILE := $(ov_SC05_018_OUT).map ov_SC05_018_LD_SCRIPT := $(ov_SC05_018_OUT).ld ov_SC05_018_SPLAT_YAML := config/splat.ov_SC05_018.yaml -ov_SC05_018_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_018_jr_8012ACE0.o,tail2.data.o,ov_SC05_018_jr_801380E0.o,tail3.data.o,ov_SC05_018_jr_8013F350.o,tail4.data.o,ov_SC05_018_jr_8013FFD8.o,tail5.data.o,ov_SC05_018_jr_8015444C.o,tail6.data.o,ov_SC05_018_jr_80159C84.o,tail7.data.o,ov_SC05_018_jr_8015A3C8.o,tail8.data.o,ov_SC05_018_jr_8015AE2C.o,tail9.data.o,ov_SC05_018_jr_8016AB6C.o,tail10.data.o,ov_SC05_018_jr_801734BC.o,tail11.data.o,ov_SC05_018_jr_80178D40.o,tail12.data.o,ov_SC05_018_jr_8017A4AC.o,tail13.data.o,ov_SC05_018_jr_8017D604.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_018_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_018_jr_8012ACE0.o,tail2.data.o,ov_SC05_018_jr_801380E0.o,tail3.data.o,ov_SC05_018_jr_8013F350.o,tail4.data.o,ov_SC05_018_jr_8013FFD8.o,tail5.data.o,ov_SC05_018_jr_8015444C.o,tail6.data.o,ov_SC05_018_jr_80159C84.o,tail7.data.o,ov_SC05_018_jr_8015A3C8.o,tail8.data.o,ov_SC05_018_jr_8015AE2C.o,tail9.data.o,ov_SC05_018_jr_8015C32C.o,tail10.data.o,ov_SC05_018_jr_8016AB6C.o,tail11.data.o,ov_SC05_018_jr_801734BC.o,tail12.data.o,ov_SC05_018_jr_80178D40.o,tail13.data.o,ov_SC05_018_jr_8017A4AC.o,tail14.data.o,ov_SC05_018_jr_8017D604.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_018/ov_SC05_018_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_018/ov_SC05_018_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_018/ov_SC05_018_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2796,7 +2796,7 @@ ov_SC05_019_ELF := $(ov_SC05_019_OUT).elf ov_SC05_019_MAPFILE := $(ov_SC05_019_OUT).map ov_SC05_019_LD_SCRIPT := $(ov_SC05_019_OUT).ld ov_SC05_019_SPLAT_YAML := config/splat.ov_SC05_019.yaml -ov_SC05_019_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_019_jr_8012ACE0.o,tail2.data.o,ov_SC05_019_jr_801380E0.o,tail3.data.o,ov_SC05_019_jr_8013F350.o,tail4.data.o,ov_SC05_019_jr_8013FFD8.o,tail5.data.o,ov_SC05_019_jr_8015444C.o,tail6.data.o,ov_SC05_019_jr_80159C84.o,tail7.data.o,ov_SC05_019_jr_8015A3C8.o,tail8.data.o,ov_SC05_019_jr_8015AE2C.o,tail9.data.o,ov_SC05_019_jr_8016AB6C.o,tail10.data.o,ov_SC05_019_jr_801734BC.o,tail11.data.o,ov_SC05_019_jr_80178D40.o,tail12.data.o,ov_SC05_019_jr_8017A4AC.o,tail13.data.o,ov_SC05_019_jr_8017D5C0.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC05_019_JTBL_INTERLEAVE := --order tail.data.o,ov_SC05_019_jr_8012ACE0.o,tail2.data.o,ov_SC05_019_jr_801380E0.o,tail3.data.o,ov_SC05_019_jr_8013F350.o,tail4.data.o,ov_SC05_019_jr_8013FFD8.o,tail5.data.o,ov_SC05_019_jr_8015444C.o,tail6.data.o,ov_SC05_019_jr_80159C84.o,tail7.data.o,ov_SC05_019_jr_8015A3C8.o,tail8.data.o,ov_SC05_019_jr_8015AE2C.o,tail9.data.o,ov_SC05_019_jr_8015C32C.o,tail10.data.o,ov_SC05_019_jr_8016AB6C.o,tail11.data.o,ov_SC05_019_jr_801734BC.o,tail12.data.o,ov_SC05_019_jr_80178D40.o,tail13.data.o,ov_SC05_019_jr_8017A4AC.o,tail14.data.o,ov_SC05_019_jr_8017D5C0.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC05_019/ov_SC05_019_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC05_019/ov_SC05_019_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC05_019/ov_SC05_019_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2821,7 +2821,7 @@ ov_SC06_006_ELF := $(ov_SC06_006_OUT).elf ov_SC06_006_MAPFILE := $(ov_SC06_006_OUT).map ov_SC06_006_LD_SCRIPT := $(ov_SC06_006_OUT).ld ov_SC06_006_SPLAT_YAML := config/splat.ov_SC06_006.yaml -ov_SC06_006_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_006_jr_8012ACE0.o,tail2.data.o,ov_SC06_006_jr_801380E0.o,tail3.data.o,ov_SC06_006_jr_8013F350.o,tail4.data.o,ov_SC06_006_jr_8013FFD8.o,tail5.data.o,ov_SC06_006_jr_8015444C.o,tail6.data.o,ov_SC06_006_jr_80159C84.o,tail7.data.o,ov_SC06_006_jr_8015A3C8.o,tail8.data.o,ov_SC06_006_jr_8015AE2C.o,tail9.data.o,ov_SC06_006_jr_8016AB6C.o,tail10.data.o,ov_SC06_006_jr_801734BC.o,tail11.data.o,ov_SC06_006_jr_80178D40.o,tail12.data.o,ov_SC06_006_jr_8017A4AC.o,tail13.data.o,ov_SC06_006_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_006_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_006_jr_8012ACE0.o,tail2.data.o,ov_SC06_006_jr_801380E0.o,tail3.data.o,ov_SC06_006_jr_8013F350.o,tail4.data.o,ov_SC06_006_jr_8013FFD8.o,tail5.data.o,ov_SC06_006_jr_8015444C.o,tail6.data.o,ov_SC06_006_jr_80159C84.o,tail7.data.o,ov_SC06_006_jr_8015A3C8.o,tail8.data.o,ov_SC06_006_jr_8015AE2C.o,tail9.data.o,ov_SC06_006_jr_8015C32C.o,tail10.data.o,ov_SC06_006_jr_8016AB6C.o,tail11.data.o,ov_SC06_006_jr_801734BC.o,tail12.data.o,ov_SC06_006_jr_80178D40.o,tail13.data.o,ov_SC06_006_jr_8017A4AC.o,tail14.data.o,ov_SC06_006_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_006/ov_SC06_006_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_006/ov_SC06_006_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_006/ov_SC06_006_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2846,7 +2846,7 @@ ov_SC06_008_ELF := $(ov_SC06_008_OUT).elf ov_SC06_008_MAPFILE := $(ov_SC06_008_OUT).map ov_SC06_008_LD_SCRIPT := $(ov_SC06_008_OUT).ld ov_SC06_008_SPLAT_YAML := config/splat.ov_SC06_008.yaml -ov_SC06_008_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_008_jr_8012ACE0.o,tail2.data.o,ov_SC06_008_jr_801380E0.o,tail3.data.o,ov_SC06_008_jr_8013F350.o,tail4.data.o,ov_SC06_008_jr_8013FFD8.o,tail5.data.o,ov_SC06_008_jr_8015444C.o,tail6.data.o,ov_SC06_008_jr_80159C84.o,tail7.data.o,ov_SC06_008_jr_8015A3C8.o,tail8.data.o,ov_SC06_008_jr_8015AE2C.o,tail9.data.o,ov_SC06_008_jr_8016AB6C.o,tail10.data.o,ov_SC06_008_jr_801734BC.o,tail11.data.o,ov_SC06_008_jr_80178D40.o,tail12.data.o,ov_SC06_008_jr_8017A4AC.o,tail13.data.o,ov_SC06_008_jr_8017C294.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_008_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_008_jr_8012ACE0.o,tail2.data.o,ov_SC06_008_jr_801380E0.o,tail3.data.o,ov_SC06_008_jr_8013F350.o,tail4.data.o,ov_SC06_008_jr_8013FFD8.o,tail5.data.o,ov_SC06_008_jr_8015444C.o,tail6.data.o,ov_SC06_008_jr_80159C84.o,tail7.data.o,ov_SC06_008_jr_8015A3C8.o,tail8.data.o,ov_SC06_008_jr_8015AE2C.o,tail9.data.o,ov_SC06_008_jr_8015C32C.o,tail10.data.o,ov_SC06_008_jr_8016AB6C.o,tail11.data.o,ov_SC06_008_jr_801734BC.o,tail12.data.o,ov_SC06_008_jr_80178D40.o,tail13.data.o,ov_SC06_008_jr_8017A4AC.o,tail14.data.o,ov_SC06_008_jr_8017C294.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_008/ov_SC06_008_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_008/ov_SC06_008_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_008/ov_SC06_008_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2871,7 +2871,7 @@ ov_SC06_010_ELF := $(ov_SC06_010_OUT).elf ov_SC06_010_MAPFILE := $(ov_SC06_010_OUT).map ov_SC06_010_LD_SCRIPT := $(ov_SC06_010_OUT).ld ov_SC06_010_SPLAT_YAML := config/splat.ov_SC06_010.yaml -ov_SC06_010_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_010_jr_8012ACE0.o,tail2.data.o,ov_SC06_010_jr_801380E0.o,tail3.data.o,ov_SC06_010_jr_8013F350.o,tail4.data.o,ov_SC06_010_jr_8015444C.o,tail5.data.o,ov_SC06_010_jr_80159C84.o,tail6.data.o,ov_SC06_010_jr_8015A3C8.o,tail7.data.o,ov_SC06_010_jr_8015AE2C.o,tail8.data.o,ov_SC06_010_jr_8016AB6C.o,tail9.data.o,ov_SC06_010_jr_801734BC.o,tail10.data.o,ov_SC06_010_jr_80178D40.o,tail11.data.o,ov_SC06_010_jr_8017A4AC.o,tail12.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_010_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_010_jr_8012ACE0.o,tail2.data.o,ov_SC06_010_jr_801380E0.o,tail3.data.o,ov_SC06_010_jr_8013F350.o,tail4.data.o,ov_SC06_010_jr_8015444C.o,tail5.data.o,ov_SC06_010_jr_80159C84.o,tail6.data.o,ov_SC06_010_jr_8015A3C8.o,tail7.data.o,ov_SC06_010_jr_8015AE2C.o,tail8.data.o,ov_SC06_010_jr_8015C32C.o,tail9.data.o,ov_SC06_010_jr_8016AB6C.o,tail10.data.o,ov_SC06_010_jr_801734BC.o,tail11.data.o,ov_SC06_010_jr_80178D40.o,tail12.data.o,ov_SC06_010_jr_8017A4AC.o,tail13.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_010/ov_SC06_010_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_010/ov_SC06_010_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_010/ov_SC06_010_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2896,7 +2896,7 @@ ov_SC06_011_ELF := $(ov_SC06_011_OUT).elf ov_SC06_011_MAPFILE := $(ov_SC06_011_OUT).map ov_SC06_011_LD_SCRIPT := $(ov_SC06_011_OUT).ld ov_SC06_011_SPLAT_YAML := config/splat.ov_SC06_011.yaml -ov_SC06_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_011_jr_8012ACE0.o,tail2.data.o,ov_SC06_011_jr_801380E0.o,tail3.data.o,ov_SC06_011_jr_8013F350.o,tail4.data.o,ov_SC06_011_jr_8013FFD8.o,tail5.data.o,ov_SC06_011_jr_8015444C.o,tail6.data.o,ov_SC06_011_jr_80159C84.o,tail7.data.o,ov_SC06_011_jr_8015A3C8.o,tail8.data.o,ov_SC06_011_jr_8015AE2C.o,tail9.data.o,ov_SC06_011_jr_8016AB6C.o,tail10.data.o,ov_SC06_011_jr_801734BC.o,tail11.data.o,ov_SC06_011_jr_80178D40.o,tail12.data.o,ov_SC06_011_jr_8017A4AC.o,tail13.data.o,ov_SC06_011_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_011_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_011_jr_8012ACE0.o,tail2.data.o,ov_SC06_011_jr_801380E0.o,tail3.data.o,ov_SC06_011_jr_8013F350.o,tail4.data.o,ov_SC06_011_jr_8013FFD8.o,tail5.data.o,ov_SC06_011_jr_8015444C.o,tail6.data.o,ov_SC06_011_jr_80159C84.o,tail7.data.o,ov_SC06_011_jr_8015A3C8.o,tail8.data.o,ov_SC06_011_jr_8015AE2C.o,tail9.data.o,ov_SC06_011_jr_8015C32C.o,tail10.data.o,ov_SC06_011_jr_8016AB6C.o,tail11.data.o,ov_SC06_011_jr_801734BC.o,tail12.data.o,ov_SC06_011_jr_80178D40.o,tail13.data.o,ov_SC06_011_jr_8017A4AC.o,tail14.data.o,ov_SC06_011_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_011/ov_SC06_011_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_011/ov_SC06_011_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_011/ov_SC06_011_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2921,7 +2921,7 @@ ov_SC06_013_ELF := $(ov_SC06_013_OUT).elf ov_SC06_013_MAPFILE := $(ov_SC06_013_OUT).map ov_SC06_013_LD_SCRIPT := $(ov_SC06_013_OUT).ld ov_SC06_013_SPLAT_YAML := config/splat.ov_SC06_013.yaml -ov_SC06_013_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_013_jr_8012ACE0.o,tail2.data.o,ov_SC06_013_jr_801380E0.o,tail3.data.o,ov_SC06_013_jr_8013F350.o,tail4.data.o,ov_SC06_013_jr_8013FFD8.o,tail5.data.o,ov_SC06_013_jr_8015444C.o,tail6.data.o,ov_SC06_013_jr_80159C84.o,tail7.data.o,ov_SC06_013_jr_8015A3C8.o,tail8.data.o,ov_SC06_013_jr_8015AE2C.o,tail9.data.o,ov_SC06_013_jr_8016AB6C.o,tail10.data.o,ov_SC06_013_jr_801734BC.o,tail11.data.o,ov_SC06_013_jr_80178D40.o,tail12.data.o,ov_SC06_013_jr_8017A4AC.o,tail13.data.o,ov_SC06_013_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_013_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_013_jr_8012ACE0.o,tail2.data.o,ov_SC06_013_jr_801380E0.o,tail3.data.o,ov_SC06_013_jr_8013F350.o,tail4.data.o,ov_SC06_013_jr_8013FFD8.o,tail5.data.o,ov_SC06_013_jr_8015444C.o,tail6.data.o,ov_SC06_013_jr_80159C84.o,tail7.data.o,ov_SC06_013_jr_8015A3C8.o,tail8.data.o,ov_SC06_013_jr_8015AE2C.o,tail9.data.o,ov_SC06_013_jr_8015C32C.o,tail10.data.o,ov_SC06_013_jr_8016AB6C.o,tail11.data.o,ov_SC06_013_jr_801734BC.o,tail12.data.o,ov_SC06_013_jr_80178D40.o,tail13.data.o,ov_SC06_013_jr_8017A4AC.o,tail14.data.o,ov_SC06_013_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_013/ov_SC06_013_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_013/ov_SC06_013_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_013/ov_SC06_013_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2946,7 +2946,7 @@ ov_SC06_014_ELF := $(ov_SC06_014_OUT).elf ov_SC06_014_MAPFILE := $(ov_SC06_014_OUT).map ov_SC06_014_LD_SCRIPT := $(ov_SC06_014_OUT).ld ov_SC06_014_SPLAT_YAML := config/splat.ov_SC06_014.yaml -ov_SC06_014_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_014_jr_8012ACE0.o,tail2.data.o,ov_SC06_014_jr_801380E0.o,tail3.data.o,ov_SC06_014_jr_8013F350.o,tail4.data.o,ov_SC06_014_jr_8013FFD8.o,tail5.data.o,ov_SC06_014_jr_8015444C.o,tail6.data.o,ov_SC06_014_jr_80159C84.o,tail7.data.o,ov_SC06_014_jr_8015A3C8.o,tail8.data.o,ov_SC06_014_jr_8015AE2C.o,tail9.data.o,ov_SC06_014_jr_8016AB6C.o,tail10.data.o,ov_SC06_014_jr_801734BC.o,tail11.data.o,ov_SC06_014_jr_80178D40.o,tail12.data.o,ov_SC06_014_jr_8017A4AC.o,tail13.data.o,ov_SC06_014_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_014_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_014_jr_8012ACE0.o,tail2.data.o,ov_SC06_014_jr_801380E0.o,tail3.data.o,ov_SC06_014_jr_8013F350.o,tail4.data.o,ov_SC06_014_jr_8013FFD8.o,tail5.data.o,ov_SC06_014_jr_8015444C.o,tail6.data.o,ov_SC06_014_jr_80159C84.o,tail7.data.o,ov_SC06_014_jr_8015A3C8.o,tail8.data.o,ov_SC06_014_jr_8015AE2C.o,tail9.data.o,ov_SC06_014_jr_8015C32C.o,tail10.data.o,ov_SC06_014_jr_8016AB6C.o,tail11.data.o,ov_SC06_014_jr_801734BC.o,tail12.data.o,ov_SC06_014_jr_80178D40.o,tail13.data.o,ov_SC06_014_jr_8017A4AC.o,tail14.data.o,ov_SC06_014_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_014/ov_SC06_014_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_014/ov_SC06_014_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_014/ov_SC06_014_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2971,7 +2971,7 @@ ov_SC06_015_ELF := $(ov_SC06_015_OUT).elf ov_SC06_015_MAPFILE := $(ov_SC06_015_OUT).map ov_SC06_015_LD_SCRIPT := $(ov_SC06_015_OUT).ld ov_SC06_015_SPLAT_YAML := config/splat.ov_SC06_015.yaml -ov_SC06_015_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_015_jr_8012ACE0.o,tail2.data.o,ov_SC06_015_jr_801380E0.o,tail3.data.o,ov_SC06_015_jr_8013F350.o,tail4.data.o,ov_SC06_015_jr_8013FFD8.o,tail5.data.o,ov_SC06_015_jr_8015444C.o,tail6.data.o,ov_SC06_015_jr_80159C84.o,tail7.data.o,ov_SC06_015_jr_8015A3C8.o,tail8.data.o,ov_SC06_015_jr_8015AE2C.o,tail9.data.o,ov_SC06_015_jr_8016AB6C.o,tail10.data.o,ov_SC06_015_jr_801734BC.o,tail11.data.o,ov_SC06_015_jr_80178D40.o,tail12.data.o,ov_SC06_015_jr_8017A4AC.o,tail13.data.o,ov_SC06_015_jr_8017BEBC.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_015_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_015_jr_8012ACE0.o,tail2.data.o,ov_SC06_015_jr_801380E0.o,tail3.data.o,ov_SC06_015_jr_8013F350.o,tail4.data.o,ov_SC06_015_jr_8013FFD8.o,tail5.data.o,ov_SC06_015_jr_8015444C.o,tail6.data.o,ov_SC06_015_jr_80159C84.o,tail7.data.o,ov_SC06_015_jr_8015A3C8.o,tail8.data.o,ov_SC06_015_jr_8015AE2C.o,tail9.data.o,ov_SC06_015_jr_8015C32C.o,tail10.data.o,ov_SC06_015_jr_8016AB6C.o,tail11.data.o,ov_SC06_015_jr_801734BC.o,tail12.data.o,ov_SC06_015_jr_80178D40.o,tail13.data.o,ov_SC06_015_jr_8017A4AC.o,tail14.data.o,ov_SC06_015_jr_8017BEBC.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_015/ov_SC06_015_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_015/ov_SC06_015_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_015/ov_SC06_015_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 @@ -2996,7 +2996,7 @@ ov_SC06_016_ELF := $(ov_SC06_016_OUT).elf ov_SC06_016_MAPFILE := $(ov_SC06_016_OUT).map ov_SC06_016_LD_SCRIPT := $(ov_SC06_016_OUT).ld ov_SC06_016_SPLAT_YAML := config/splat.ov_SC06_016.yaml -ov_SC06_016_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_016_jr_8012ACE0.o,tail2.data.o,ov_SC06_016_jr_801380E0.o,tail3.data.o,ov_SC06_016_jr_8013F350.o,tail4.data.o,ov_SC06_016_jr_8013FFD8.o,tail5.data.o,ov_SC06_016_jr_8015444C.o,tail6.data.o,ov_SC06_016_jr_80159C84.o,tail7.data.o,ov_SC06_016_jr_8015A3C8.o,tail8.data.o,ov_SC06_016_jr_8015AE2C.o,tail9.data.o,ov_SC06_016_jr_8016AB6C.o,tail10.data.o,ov_SC06_016_jr_801734BC.o,tail11.data.o,ov_SC06_016_jr_80178D40.o,tail12.data.o,ov_SC06_016_jr_8017A4AC.o,tail13.data.o,ov_SC06_016_jr_8017C8D0.o,tail14.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve +ov_SC06_016_JTBL_INTERLEAVE := --order tail.data.o,ov_SC06_016_jr_8012ACE0.o,tail2.data.o,ov_SC06_016_jr_801380E0.o,tail3.data.o,ov_SC06_016_jr_8013F350.o,tail4.data.o,ov_SC06_016_jr_8013FFD8.o,tail5.data.o,ov_SC06_016_jr_8015444C.o,tail6.data.o,ov_SC06_016_jr_80159C84.o,tail7.data.o,ov_SC06_016_jr_8015A3C8.o,tail8.data.o,ov_SC06_016_jr_8015AE2C.o,tail9.data.o,ov_SC06_016_jr_8015C32C.o,tail10.data.o,ov_SC06_016_jr_8016AB6C.o,tail11.data.o,ov_SC06_016_jr_801734BC.o,tail12.data.o,ov_SC06_016_jr_80178D40.o,tail13.data.o,ov_SC06_016_jr_8017A4AC.o,tail14.data.o,ov_SC06_016_jr_8017C8D0.o,tail15.data.o,trailing.o # Phase-26 §8 jtbl-rodata carve build/src/ov_SC06_016/ov_SC06_016_jr_8012ACE0.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) build/src/ov_SC06_016/ov_SC06_016_jr_8013F350.o: JTBL_PADS := 0,0 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 build/src/ov_SC06_016/ov_SC06_016_jr_80159C84.o: JTBL_PADS := 0,4 # §8e pads (jtbl_carve.py) tables=+0x0,+0x20 diff --git a/config/splat.ov_SC01_080.yaml b/config/splat.ov_SC01_080.yaml index cffef40dc..90b66179d 100644 --- a/config/splat.ov_SC01_080.yaml +++ b/config/splat.ov_SC01_080.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC01_080_jr_80159C84] - [0x32270, c, ov_SC01_080_jr_8015A3C8] - [0x32cd4, c, ov_SC01_080_jr_8015AE2C] + - [0x341d4, c, ov_SC01_080_jr_8015C32C] - [0x42a14, c, ov_SC01_080_jr_8016AB6C] - [0x4b364, c, ov_SC01_080_jr_801734BC] - [0x50be8, c, ov_SC01_080_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x9bfd8, data, tail8] - [0x9bfdc, .rodata, ov_SC01_080_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9bff8, data, tail9] + - [0x9c01c, .rodata, ov_SC01_080_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9c038, data, tail10] - [0x9c050, .rodata, ov_SC01_080_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9c070, data, tail10] + - [0x9c070, data, tail11] - [0x9c0f0, .rodata, ov_SC01_080_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9c104, data, tail11] + - [0x9c104, data, tail12] - [0x9c2ac, .rodata, ov_SC01_080_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9c424, data, tail12] + - [0x9c424, data, tail13] - [0x9c4b4, .rodata, ov_SC01_080_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9c540, data, tail13] + - [0x9c540, data, tail14] - [0x9FDF4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9FDF7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC01_084.yaml b/config/splat.ov_SC01_084.yaml index f40c1c8e8..7483e1ff4 100644 --- a/config/splat.ov_SC01_084.yaml +++ b/config/splat.ov_SC01_084.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC01_084_jr_80159C84] - [0x32270, c, ov_SC01_084_jr_8015A3C8] - [0x32cd4, c, ov_SC01_084_jr_8015AE2C] + - [0x341d4, c, ov_SC01_084_jr_8015C32C] - [0x42a14, c, ov_SC01_084_jr_8016AB6C] - [0x4b364, c, ov_SC01_084_jr_801734BC] - [0x50be8, c, ov_SC01_084_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9d9a8, data, tail8] - [0x9d9ac, .rodata, ov_SC01_084_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9d9c8, data, tail9] + - [0x9d9ec, .rodata, ov_SC01_084_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9da08, data, tail10] - [0x9da20, .rodata, ov_SC01_084_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9da40, data, tail10] + - [0x9da40, data, tail11] - [0x9dac0, .rodata, ov_SC01_084_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9dad4, data, tail11] + - [0x9dad4, data, tail12] - [0x9dc7c, .rodata, ov_SC01_084_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9ddf4, data, tail12] + - [0x9ddf4, data, tail13] - [0x9de84, .rodata, ov_SC01_084_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9df10, data, tail13] + - [0x9df10, data, tail14] - [0x9df28, .rodata, ov_SC01_084_jr_8017CA80] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9df48, data, tail14] + - [0x9df48, data, tail15] - [0x9FA9C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9FA9F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_000.yaml b/config/splat.ov_SC02_000.yaml index 24b1259b0..545b4bfec 100644 --- a/config/splat.ov_SC02_000.yaml +++ b/config/splat.ov_SC02_000.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_000_jr_80159C84] - [0x32270, c, ov_SC02_000_jr_8015A3C8] - [0x32cd4, c, ov_SC02_000_jr_8015AE2C] + - [0x341d4, c, ov_SC02_000_jr_8015C32C] - [0x42a14, c, ov_SC02_000_jr_8016AB6C] - [0x4b364, c, ov_SC02_000_jr_801734BC] - [0x50be8, c, ov_SC02_000_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xbe1fc, data, tail8] - [0xbe200, .rodata, ov_SC02_000_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xbe21c, data, tail9] + - [0xbe240, .rodata, ov_SC02_000_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xbe25c, data, tail10] - [0xbe274, .rodata, ov_SC02_000_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe294, data, tail10] + - [0xbe294, data, tail11] - [0xbe314, .rodata, ov_SC02_000_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe328, data, tail11] + - [0xbe328, data, tail12] - [0xbe4d0, .rodata, ov_SC02_000_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe648, data, tail12] + - [0xbe648, data, tail13] - [0xbe6d8, .rodata, ov_SC02_000_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe764, data, tail13] + - [0xbe764, data, tail14] - [0xbe944, .rodata, ov_SC02_000_jr_8017FCB0] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe964, data, tail14] + - [0xbe964, data, tail15] - [0xC070C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC070F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_003.yaml b/config/splat.ov_SC02_003.yaml index 782ee32bf..e0ca046ec 100644 --- a/config/splat.ov_SC02_003.yaml +++ b/config/splat.ov_SC02_003.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_003_jr_80159C84] - [0x32270, c, ov_SC02_003_jr_8015A3C8] - [0x32cd4, c, ov_SC02_003_jr_8015AE2C] + - [0x341d4, c, ov_SC02_003_jr_8015C32C] - [0x42a14, c, ov_SC02_003_jr_8016AB6C] - [0x4b364, c, ov_SC02_003_jr_801734BC] - [0x50be8, c, ov_SC02_003_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xbe1fc, data, tail8] - [0xbe200, .rodata, ov_SC02_003_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xbe21c, data, tail9] + - [0xbe240, .rodata, ov_SC02_003_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xbe25c, data, tail10] - [0xbe274, .rodata, ov_SC02_003_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe294, data, tail10] + - [0xbe294, data, tail11] - [0xbe314, .rodata, ov_SC02_003_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe328, data, tail11] + - [0xbe328, data, tail12] - [0xbe4d0, .rodata, ov_SC02_003_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe648, data, tail12] + - [0xbe648, data, tail13] - [0xbe6d8, .rodata, ov_SC02_003_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe764, data, tail13] + - [0xbe764, data, tail14] - [0xbe944, .rodata, ov_SC02_003_jr_8017FCB0] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbe964, data, tail14] + - [0xbe964, data, tail15] - [0xC070C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC070F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_004.yaml b/config/splat.ov_SC02_004.yaml index bd75b9d4d..d96b595a0 100644 --- a/config/splat.ov_SC02_004.yaml +++ b/config/splat.ov_SC02_004.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_004_jr_80159C84] - [0x32270, c, ov_SC02_004_jr_8015A3C8] - [0x32cd4, c, ov_SC02_004_jr_8015AE2C] + - [0x341d4, c, ov_SC02_004_jr_8015C32C] - [0x42a14, c, ov_SC02_004_jr_8016AB6C] - [0x4b364, c, ov_SC02_004_jr_801734BC] - [0x50be8, c, ov_SC02_004_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x6c80c, data, tail8] - [0x6c810, .rodata, ov_SC02_004_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x6c82c, data, tail9] + - [0x6c850, .rodata, ov_SC02_004_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6c86c, data, tail10] - [0x6c884, .rodata, ov_SC02_004_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6c8a4, data, tail10] + - [0x6c8a4, data, tail11] - [0x6c924, .rodata, ov_SC02_004_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6c938, data, tail11] + - [0x6c938, data, tail12] - [0x6cae0, .rodata, ov_SC02_004_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6cc58, data, tail12] + - [0x6cc58, data, tail13] - [0x6cce8, .rodata, ov_SC02_004_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6cd74, data, tail13] + - [0x6cd74, data, tail14] - [0x6E26C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6E26F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_005.yaml b/config/splat.ov_SC02_005.yaml index 62de43bb2..28d7f8286 100644 --- a/config/splat.ov_SC02_005.yaml +++ b/config/splat.ov_SC02_005.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_005_jr_80159C84] - [0x32270, c, ov_SC02_005_jr_8015A3C8] - [0x32cd4, c, ov_SC02_005_jr_8015AE2C] + - [0x341d4, c, ov_SC02_005_jr_8015C32C] - [0x42a14, c, ov_SC02_005_jr_8016AB6C] - [0x4b364, c, ov_SC02_005_jr_801734BC] - [0x50be8, c, ov_SC02_005_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xba540, data, tail8] - [0xba544, .rodata, ov_SC02_005_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xba560, data, tail9] + - [0xba584, .rodata, ov_SC02_005_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xba5a0, data, tail10] - [0xba5b8, .rodata, ov_SC02_005_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xba5d8, data, tail10] + - [0xba5d8, data, tail11] - [0xba658, .rodata, ov_SC02_005_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xba66c, data, tail11] + - [0xba66c, data, tail12] - [0xba814, .rodata, ov_SC02_005_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xba98c, data, tail12] + - [0xba98c, data, tail13] - [0xbaa1c, .rodata, ov_SC02_005_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbaaa8, data, tail13] + - [0xbaaa8, data, tail14] - [0xBCB00, bin, trailing] # final 1 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xBCB01] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_011.yaml b/config/splat.ov_SC02_011.yaml index 18357806c..49c89bb60 100644 --- a/config/splat.ov_SC02_011.yaml +++ b/config/splat.ov_SC02_011.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_011_jr_80159C84] - [0x32270, c, ov_SC02_011_jr_8015A3C8] - [0x32cd4, c, ov_SC02_011_jr_8015AE2C] + - [0x341d4, c, ov_SC02_011_jr_8015C32C] - [0x42a14, c, ov_SC02_011_jr_8016AB6C] - [0x4b364, c, ov_SC02_011_jr_801734BC] - [0x50be8, c, ov_SC02_011_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xc169c, data, tail8] - [0xc16a0, .rodata, ov_SC02_011_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc16bc, data, tail9] + - [0xc16e0, .rodata, ov_SC02_011_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc16fc, data, tail10] - [0xc1714, .rodata, ov_SC02_011_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1734, data, tail10] + - [0xc1734, data, tail11] - [0xc17b4, .rodata, ov_SC02_011_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc17c8, data, tail11] + - [0xc17c8, data, tail12] - [0xc1970, .rodata, ov_SC02_011_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1ae8, data, tail12] + - [0xc1ae8, data, tail13] - [0xc1b78, .rodata, ov_SC02_011_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1c04, data, tail13] + - [0xc1c04, data, tail14] - [0xC3924, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC3927] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_015.yaml b/config/splat.ov_SC02_015.yaml index 7f65f2982..01b6db4ab 100644 --- a/config/splat.ov_SC02_015.yaml +++ b/config/splat.ov_SC02_015.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_015_jr_80159C84] - [0x32270, c, ov_SC02_015_jr_8015A3C8] - [0x32cd4, c, ov_SC02_015_jr_8015AE2C] + - [0x341d4, c, ov_SC02_015_jr_8015C32C] - [0x42a14, c, ov_SC02_015_jr_8016AB6C] - [0x4b364, c, ov_SC02_015_jr_801734BC] - [0x50be8, c, ov_SC02_015_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x668f4, data, tail8] - [0x668f8, .rodata, ov_SC02_015_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x66914, data, tail9] + - [0x66938, .rodata, ov_SC02_015_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x66954, data, tail10] - [0x6696c, .rodata, ov_SC02_015_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6698c, data, tail10] + - [0x6698c, data, tail11] - [0x66a0c, .rodata, ov_SC02_015_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66a20, data, tail11] + - [0x66a20, data, tail12] - [0x66bc8, .rodata, ov_SC02_015_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66d40, data, tail12] + - [0x66d40, data, tail13] - [0x66dd0, .rodata, ov_SC02_015_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66e5c, data, tail13] + - [0x66e5c, data, tail14] - [0x68544, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x68547] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_016.yaml b/config/splat.ov_SC02_016.yaml index 8c9bb545d..2e63c73c6 100644 --- a/config/splat.ov_SC02_016.yaml +++ b/config/splat.ov_SC02_016.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_016_jr_80159C84] - [0x32270, c, ov_SC02_016_jr_8015A3C8] - [0x32cd4, c, ov_SC02_016_jr_8015AE2C] + - [0x341d4, c, ov_SC02_016_jr_8015C32C] - [0x42a14, c, ov_SC02_016_jr_8016AB6C] - [0x4b364, c, ov_SC02_016_jr_801734BC] - [0x50be8, c, ov_SC02_016_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8a4d4, data, tail8] - [0x8a4d8, .rodata, ov_SC02_016_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8a4f4, data, tail9] + - [0x8a518, .rodata, ov_SC02_016_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8a534, data, tail10] - [0x8a54c, .rodata, ov_SC02_016_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8a56c, data, tail10] + - [0x8a56c, data, tail11] - [0x8a5ec, .rodata, ov_SC02_016_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8a600, data, tail11] + - [0x8a600, data, tail12] - [0x8a7a8, .rodata, ov_SC02_016_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8a920, data, tail12] + - [0x8a920, data, tail13] - [0x8a9b0, .rodata, ov_SC02_016_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8aa3c, data, tail13] + - [0x8aa3c, data, tail14] - [0x8aa54, .rodata, ov_SC02_016_jr_8017DC70] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8aa74, data, tail14] + - [0x8aa74, data, tail15] - [0x8C97C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8C97F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_017.yaml b/config/splat.ov_SC02_017.yaml index e27cc46a1..c64eaec06 100644 --- a/config/splat.ov_SC02_017.yaml +++ b/config/splat.ov_SC02_017.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_017_jr_80159C84] - [0x32270, c, ov_SC02_017_jr_8015A3C8] - [0x32cd4, c, ov_SC02_017_jr_8015AE2C] + - [0x341d4, c, ov_SC02_017_jr_8015C32C] - [0x42a14, c, ov_SC02_017_jr_8016AB6C] - [0x4b364, c, ov_SC02_017_jr_801734BC] - [0x50be8, c, ov_SC02_017_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xc5cf4, data, tail8] - [0xc5cf8, .rodata, ov_SC02_017_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc5d14, data, tail9] + - [0xc5d38, .rodata, ov_SC02_017_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc5d54, data, tail10] - [0xc5d6c, .rodata, ov_SC02_017_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc5d8c, data, tail10] + - [0xc5d8c, data, tail11] - [0xc5e0c, .rodata, ov_SC02_017_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc5e20, data, tail11] + - [0xc5e20, data, tail12] - [0xc5fc8, .rodata, ov_SC02_017_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc6140, data, tail12] + - [0xc6140, data, tail13] - [0xc61d0, .rodata, ov_SC02_017_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc625c, data, tail13] + - [0xc625c, data, tail14] - [0xc6274, .rodata, ov_SC02_017_jr_8017DF34] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc6294, data, tail14] + - [0xc6294, data, tail15] - [0xC7BDC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC7BDF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_021.yaml b/config/splat.ov_SC02_021.yaml index d71dc6700..e9fbdaf60 100644 --- a/config/splat.ov_SC02_021.yaml +++ b/config/splat.ov_SC02_021.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_021_jr_80159C84] - [0x32270, c, ov_SC02_021_jr_8015A3C8] - [0x32cd4, c, ov_SC02_021_jr_8015AE2C] + - [0x341d4, c, ov_SC02_021_jr_8015C32C] - [0x42a14, c, ov_SC02_021_jr_8016AB6C] - [0x4b364, c, ov_SC02_021_jr_801734BC] - [0x50be8, c, ov_SC02_021_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x69270, data, tail8] - [0x69274, .rodata, ov_SC02_021_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x69290, data, tail9] + - [0x692b4, .rodata, ov_SC02_021_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x692d0, data, tail10] - [0x692e8, .rodata, ov_SC02_021_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x69308, data, tail10] + - [0x69308, data, tail11] - [0x69388, .rodata, ov_SC02_021_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6939c, data, tail11] + - [0x6939c, data, tail12] - [0x69544, .rodata, ov_SC02_021_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x696bc, data, tail12] + - [0x696bc, data, tail13] - [0x6974c, .rodata, ov_SC02_021_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x697d8, data, tail13] + - [0x697d8, data, tail14] - [0x697f0, .rodata, ov_SC02_021_jr_8017C294] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x69810, data, tail14] + - [0x69810, data, tail15] - [0x6B744, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6B747] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_026.yaml b/config/splat.ov_SC02_026.yaml index 85fceac87..b5c7ae53d 100644 --- a/config/splat.ov_SC02_026.yaml +++ b/config/splat.ov_SC02_026.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_026_jr_80159C84] - [0x32270, c, ov_SC02_026_jr_8015A3C8] - [0x32cd4, c, ov_SC02_026_jr_8015AE2C] + - [0x341d4, c, ov_SC02_026_jr_8015C32C] - [0x42a14, c, ov_SC02_026_jr_8016AB6C] - [0x4b364, c, ov_SC02_026_jr_801734BC] - [0x50be8, c, ov_SC02_026_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xa66a4, data, tail8] - [0xa66a8, .rodata, ov_SC02_026_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xa66c4, data, tail9] + - [0xa66e8, .rodata, ov_SC02_026_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xa6704, data, tail10] - [0xa671c, .rodata, ov_SC02_026_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa673c, data, tail10] + - [0xa673c, data, tail11] - [0xa67bc, .rodata, ov_SC02_026_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa67d0, data, tail11] + - [0xa67d0, data, tail12] - [0xa6978, .rodata, ov_SC02_026_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa6af0, data, tail12] + - [0xa6af0, data, tail13] - [0xa6b80, .rodata, ov_SC02_026_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa6c0c, data, tail13] + - [0xa6c0c, data, tail14] - [0xa6c24, .rodata, ov_SC02_026_jr_8017C180] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa6c44, data, tail14] + - [0xa6c44, data, tail15] - [0xA8164, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xA8167] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_027.yaml b/config/splat.ov_SC02_027.yaml index 7adb3b581..aa9d001be 100644 --- a/config/splat.ov_SC02_027.yaml +++ b/config/splat.ov_SC02_027.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_027_jr_80159C84] - [0x32270, c, ov_SC02_027_jr_8015A3C8] - [0x32cd4, c, ov_SC02_027_jr_8015AE2C] + - [0x341d4, c, ov_SC02_027_jr_8015C32C] - [0x42a14, c, ov_SC02_027_jr_8016AB6C] - [0x4b364, c, ov_SC02_027_jr_801734BC] - [0x50be8, c, ov_SC02_027_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xb0410, data, tail8] - [0xb0414, .rodata, ov_SC02_027_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xb0430, data, tail9] + - [0xb0454, .rodata, ov_SC02_027_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xb0470, data, tail10] - [0xb0488, .rodata, ov_SC02_027_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb04a8, data, tail10] + - [0xb04a8, data, tail11] - [0xb0528, .rodata, ov_SC02_027_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb053c, data, tail11] + - [0xb053c, data, tail12] - [0xb06e4, .rodata, ov_SC02_027_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb085c, data, tail12] + - [0xb085c, data, tail13] - [0xb08ec, .rodata, ov_SC02_027_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb0978, data, tail13] + - [0xb0978, data, tail14] - [0xb0990, .rodata, ov_SC02_027_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb09b0, data, tail14] + - [0xb09b0, data, tail15] - [0xB28E4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xB28E7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_028.yaml b/config/splat.ov_SC02_028.yaml index 716651e5e..a7b374587 100644 --- a/config/splat.ov_SC02_028.yaml +++ b/config/splat.ov_SC02_028.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_028_jr_80159C84] - [0x32270, c, ov_SC02_028_jr_8015A3C8] - [0x32cd4, c, ov_SC02_028_jr_8015AE2C] + - [0x341d4, c, ov_SC02_028_jr_8015C32C] - [0x42a14, c, ov_SC02_028_jr_8016AB6C] - [0x4b364, c, ov_SC02_028_jr_801734BC] - [0x50be8, c, ov_SC02_028_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xa9394, data, tail8] - [0xa9398, .rodata, ov_SC02_028_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xa93b4, data, tail9] + - [0xa93d8, .rodata, ov_SC02_028_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xa93f4, data, tail10] - [0xa940c, .rodata, ov_SC02_028_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa942c, data, tail10] + - [0xa942c, data, tail11] - [0xa94ac, .rodata, ov_SC02_028_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa94c0, data, tail11] + - [0xa94c0, data, tail12] - [0xa9668, .rodata, ov_SC02_028_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa97e0, data, tail12] + - [0xa97e0, data, tail13] - [0xa9870, .rodata, ov_SC02_028_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa98fc, data, tail13] + - [0xa98fc, data, tail14] - [0xa9914, .rodata, ov_SC02_028_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa9934, data, tail14] + - [0xa9934, data, tail15] - [0xAB4E4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xAB4E7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_031.yaml b/config/splat.ov_SC02_031.yaml index 2b9580ad0..8dab2ab70 100644 --- a/config/splat.ov_SC02_031.yaml +++ b/config/splat.ov_SC02_031.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_031_jr_80159C84] - [0x32270, c, ov_SC02_031_jr_8015A3C8] - [0x32cd4, c, ov_SC02_031_jr_8015AE2C] + - [0x341d4, c, ov_SC02_031_jr_8015C32C] - [0x42a14, c, ov_SC02_031_jr_8016AB6C] - [0x4b364, c, ov_SC02_031_jr_801734BC] - [0x50be8, c, ov_SC02_031_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x8db90, data, tail8] - [0x8db94, .rodata, ov_SC02_031_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8dbb0, data, tail9] + - [0x8dbd4, .rodata, ov_SC02_031_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8dbf0, data, tail10] - [0x8dc08, .rodata, ov_SC02_031_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8dc28, data, tail10] + - [0x8dc28, data, tail11] - [0x8dca8, .rodata, ov_SC02_031_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8dcbc, data, tail11] + - [0x8dcbc, data, tail12] - [0x8de64, .rodata, ov_SC02_031_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8dfdc, data, tail12] + - [0x8dfdc, data, tail13] - [0x8e06c, .rodata, ov_SC02_031_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8e0f8, data, tail13] + - [0x8e0f8, data, tail14] - [0x8F9B4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8F9B7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_035.yaml b/config/splat.ov_SC02_035.yaml index a1207928a..b418c9a6b 100644 --- a/config/splat.ov_SC02_035.yaml +++ b/config/splat.ov_SC02_035.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_035_jr_80159C84] - [0x32270, c, ov_SC02_035_jr_8015A3C8] - [0x32cd4, c, ov_SC02_035_jr_8015AE2C] + - [0x341d4, c, ov_SC02_035_jr_8015C32C] - [0x42a14, c, ov_SC02_035_jr_8016AB6C] - [0x4b364, c, ov_SC02_035_jr_801734BC] - [0x50be8, c, ov_SC02_035_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x94e58, data, tail8] - [0x94e5c, .rodata, ov_SC02_035_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x94e78, data, tail9] + - [0x94e9c, .rodata, ov_SC02_035_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x94eb8, data, tail10] - [0x94ed0, .rodata, ov_SC02_035_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x94ef0, data, tail10] + - [0x94ef0, data, tail11] - [0x94f70, .rodata, ov_SC02_035_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x94f84, data, tail11] + - [0x94f84, data, tail12] - [0x9512c, .rodata, ov_SC02_035_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x952a4, data, tail12] + - [0x952a4, data, tail13] - [0x95334, .rodata, ov_SC02_035_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x953c0, data, tail13] + - [0x953c0, data, tail14] - [0x953d8, .rodata, ov_SC02_035_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x953f8, data, tail14] + - [0x953f8, data, tail15] - [0x968EC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x968EF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_039.yaml b/config/splat.ov_SC02_039.yaml index 496d1150a..81cdc275e 100644 --- a/config/splat.ov_SC02_039.yaml +++ b/config/splat.ov_SC02_039.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_039_jr_80159C84] - [0x32270, c, ov_SC02_039_jr_8015A3C8] - [0x32cd4, c, ov_SC02_039_jr_8015AE2C] + - [0x341d4, c, ov_SC02_039_jr_8015C32C] - [0x42a14, c, ov_SC02_039_jr_8016AB6C] - [0x4b364, c, ov_SC02_039_jr_801734BC] - [0x50be8, c, ov_SC02_039_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x77244, data, tail8] - [0x77248, .rodata, ov_SC02_039_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x77264, data, tail9] + - [0x77288, .rodata, ov_SC02_039_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x772a4, data, tail10] - [0x772bc, .rodata, ov_SC02_039_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x772dc, data, tail10] + - [0x772dc, data, tail11] - [0x7735c, .rodata, ov_SC02_039_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77370, data, tail11] + - [0x77370, data, tail12] - [0x77518, .rodata, ov_SC02_039_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77690, data, tail12] + - [0x77690, data, tail13] - [0x77720, .rodata, ov_SC02_039_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x777ac, data, tail13] + - [0x777ac, data, tail14] - [0x777c4, .rodata, ov_SC02_039_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x777e4, data, tail14] + - [0x777e4, data, tail15] - [0x78CA4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x78CA7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC02_041.yaml b/config/splat.ov_SC02_041.yaml index 28b6b15ae..bbf6a8309 100644 --- a/config/splat.ov_SC02_041.yaml +++ b/config/splat.ov_SC02_041.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC02_041_jr_80159C84] - [0x32270, c, ov_SC02_041_jr_8015A3C8] - [0x32cd4, c, ov_SC02_041_jr_8015AE2C] + - [0x341d4, c, ov_SC02_041_jr_8015C32C] - [0x42a14, c, ov_SC02_041_jr_8016AB6C] - [0x4b364, c, ov_SC02_041_jr_801734BC] - [0x50be8, c, ov_SC02_041_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8f5b0, data, tail8] - [0x8f5b4, .rodata, ov_SC02_041_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8f5d0, data, tail9] + - [0x8f5f4, .rodata, ov_SC02_041_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8f610, data, tail10] - [0x8f628, .rodata, ov_SC02_041_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8f648, data, tail10] + - [0x8f648, data, tail11] - [0x8f6c8, .rodata, ov_SC02_041_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8f6dc, data, tail11] + - [0x8f6dc, data, tail12] - [0x8f884, .rodata, ov_SC02_041_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8f9fc, data, tail12] + - [0x8f9fc, data, tail13] - [0x8fa8c, .rodata, ov_SC02_041_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8fb18, data, tail13] + - [0x8fb18, data, tail14] - [0x8fb30, .rodata, ov_SC02_041_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8fb50, data, tail14] + - [0x8fb50, data, tail15] - [0x9157C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9157F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_001.yaml b/config/splat.ov_SC03_001.yaml index 85307dda5..2bb2cfa70 100644 --- a/config/splat.ov_SC03_001.yaml +++ b/config/splat.ov_SC03_001.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_001_jr_80159C84] - [0x32270, c, ov_SC03_001_jr_8015A3C8] - [0x32cd4, c, ov_SC03_001_jr_8015AE2C] + - [0x341d4, c, ov_SC03_001_jr_8015C32C] - [0x42a14, c, ov_SC03_001_jr_8016AB6C] - [0x4b364, c, ov_SC03_001_jr_801734BC] - [0x50be8, c, ov_SC03_001_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xc46d0, data, tail8] - [0xc46d4, .rodata, ov_SC03_001_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc46f0, data, tail9] + - [0xc4714, .rodata, ov_SC03_001_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc4730, data, tail10] - [0xc4748, .rodata, ov_SC03_001_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc4768, data, tail10] + - [0xc4768, data, tail11] - [0xc47e8, .rodata, ov_SC03_001_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc47fc, data, tail11] + - [0xc47fc, data, tail12] - [0xc49a4, .rodata, ov_SC03_001_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc4b1c, data, tail12] + - [0xc4b1c, data, tail13] - [0xc4bac, .rodata, ov_SC03_001_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc4c38, data, tail13] + - [0xc4c38, data, tail14] - [0xC730C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC730F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_002.yaml b/config/splat.ov_SC03_002.yaml index dd5bd7294..73317231a 100644 --- a/config/splat.ov_SC03_002.yaml +++ b/config/splat.ov_SC03_002.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_002_jr_80159C84] - [0x32270, c, ov_SC03_002_jr_8015A3C8] - [0x32cd4, c, ov_SC03_002_jr_8015AE2C] + - [0x341d4, c, ov_SC03_002_jr_8015C32C] - [0x42a14, c, ov_SC03_002_jr_8016AB6C] - [0x4b364, c, ov_SC03_002_jr_801734BC] - [0x50be8, c, ov_SC03_002_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xa1c2c, data, tail8] - [0xa1c30, .rodata, ov_SC03_002_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xa1c4c, data, tail9] + - [0xa1c70, .rodata, ov_SC03_002_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xa1c8c, data, tail10] - [0xa1ca4, .rodata, ov_SC03_002_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa1cc4, data, tail10] + - [0xa1cc4, data, tail11] - [0xa1d44, .rodata, ov_SC03_002_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa1d58, data, tail11] + - [0xa1d58, data, tail12] - [0xa1f00, .rodata, ov_SC03_002_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa2078, data, tail12] + - [0xa2078, data, tail13] - [0xa2108, .rodata, ov_SC03_002_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa2194, data, tail13] + - [0xa2194, data, tail14] - [0xa21ac, .rodata, ov_SC03_002_jr_8017D604] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa21cc, data, tail14] + - [0xa21cc, data, tail15] - [0xA39F4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xA39F7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_003.yaml b/config/splat.ov_SC03_003.yaml index 2880364fd..62e2a103d 100644 --- a/config/splat.ov_SC03_003.yaml +++ b/config/splat.ov_SC03_003.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_003_jr_80159C84] - [0x32270, c, ov_SC03_003_jr_8015A3C8] - [0x32cd4, c, ov_SC03_003_jr_8015AE2C] + - [0x341d4, c, ov_SC03_003_jr_8015C32C] - [0x42a14, c, ov_SC03_003_jr_8016AB6C] - [0x4b364, c, ov_SC03_003_jr_801734BC] - [0x50be8, c, ov_SC03_003_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x65fac, data, tail8] - [0x65fb0, .rodata, ov_SC03_003_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x65fcc, data, tail9] + - [0x65ff0, .rodata, ov_SC03_003_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6600c, data, tail10] - [0x66024, .rodata, ov_SC03_003_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66044, data, tail10] + - [0x66044, data, tail11] - [0x660c4, .rodata, ov_SC03_003_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x660d8, data, tail11] + - [0x660d8, data, tail12] - [0x66280, .rodata, ov_SC03_003_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x663f8, data, tail12] + - [0x663f8, data, tail13] - [0x66488, .rodata, ov_SC03_003_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66514, data, tail13] + - [0x66514, data, tail14] - [0x67A24, bin, trailing] # final 1 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x67A25] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_006.yaml b/config/splat.ov_SC03_006.yaml index 6314a9e63..a8e52e3ea 100644 --- a/config/splat.ov_SC03_006.yaml +++ b/config/splat.ov_SC03_006.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_006_jr_80159C84] - [0x32270, c, ov_SC03_006_jr_8015A3C8] - [0x32cd4, c, ov_SC03_006_jr_8015AE2C] + - [0x341d4, c, ov_SC03_006_jr_8015C32C] - [0x42a14, c, ov_SC03_006_jr_8016AB6C] - [0x4b364, c, ov_SC03_006_jr_801734BC] - [0x50be8, c, ov_SC03_006_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xcd868, data, tail8] - [0xcd86c, .rodata, ov_SC03_006_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xcd888, data, tail9] + - [0xcd8ac, .rodata, ov_SC03_006_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xcd8c8, data, tail10] - [0xcd8e0, .rodata, ov_SC03_006_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xcd900, data, tail10] + - [0xcd900, data, tail11] - [0xcd980, .rodata, ov_SC03_006_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xcd994, data, tail11] + - [0xcd994, data, tail12] - [0xcdb3c, .rodata, ov_SC03_006_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xcdcb4, data, tail12] + - [0xcdcb4, data, tail13] - [0xcdd44, .rodata, ov_SC03_006_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xcddd0, data, tail13] + - [0xcddd0, data, tail14] - [0xCF75C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xCF75F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_007.yaml b/config/splat.ov_SC03_007.yaml index 6491250bf..4be887f27 100644 --- a/config/splat.ov_SC03_007.yaml +++ b/config/splat.ov_SC03_007.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_007_jr_80159C84] - [0x32270, c, ov_SC03_007_jr_8015A3C8] - [0x32cd4, c, ov_SC03_007_jr_8015AE2C] + - [0x341d4, c, ov_SC03_007_jr_8015C32C] - [0x42a14, c, ov_SC03_007_jr_8016AB6C] - [0x4b364, c, ov_SC03_007_jr_801734BC] - [0x50be8, c, ov_SC03_007_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xc01f0, data, tail8] - [0xc01f4, .rodata, ov_SC03_007_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc0210, data, tail9] + - [0xc0234, .rodata, ov_SC03_007_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc0250, data, tail10] - [0xc0268, .rodata, ov_SC03_007_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc0288, data, tail10] + - [0xc0288, data, tail11] - [0xc0308, .rodata, ov_SC03_007_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc031c, data, tail11] + - [0xc031c, data, tail12] - [0xc04c4, .rodata, ov_SC03_007_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc063c, data, tail12] + - [0xc063c, data, tail13] - [0xc06cc, .rodata, ov_SC03_007_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc0758, data, tail13] + - [0xc0758, data, tail14] - [0xC316C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC316F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_010.yaml b/config/splat.ov_SC03_010.yaml index 23c6572ff..7e22f5566 100644 --- a/config/splat.ov_SC03_010.yaml +++ b/config/splat.ov_SC03_010.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_010_jr_80159C84] - [0x32270, c, ov_SC03_010_jr_8015A3C8] - [0x32cd4, c, ov_SC03_010_jr_8015AE2C] + - [0x341d4, c, ov_SC03_010_jr_8015C32C] - [0x42a14, c, ov_SC03_010_jr_8016AB6C] - [0x4b364, c, ov_SC03_010_jr_801734BC] - [0x50be8, c, ov_SC03_010_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x764cc, data, tail8] - [0x764d0, .rodata, ov_SC03_010_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x764ec, data, tail9] + - [0x76510, .rodata, ov_SC03_010_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x7652c, data, tail10] - [0x76544, .rodata, ov_SC03_010_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x76564, data, tail10] + - [0x76564, data, tail11] - [0x765e4, .rodata, ov_SC03_010_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x765f8, data, tail11] + - [0x765f8, data, tail12] - [0x767a0, .rodata, ov_SC03_010_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x76918, data, tail12] + - [0x76918, data, tail13] - [0x769a8, .rodata, ov_SC03_010_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x76a34, data, tail13] + - [0x76a34, data, tail14] - [0x78074, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x78077] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_011.yaml b/config/splat.ov_SC03_011.yaml index 5e240a5c3..3f7333797 100644 --- a/config/splat.ov_SC03_011.yaml +++ b/config/splat.ov_SC03_011.yaml @@ -103,6 +103,7 @@ segments: - [0x31b2c, c, ov_SC03_011_jr_80159C84] - [0x32270, c, ov_SC03_011_jr_8015A3C8] - [0x32cd4, c, ov_SC03_011_jr_8015AE2C] + - [0x341d4, c, ov_SC03_011_jr_8015C32C] - [0x42a14, c, ov_SC03_011_jr_8016AB6C] - [0x4b364, c, ov_SC03_011_jr_801734BC] - [0x50be8, c, ov_SC03_011_jr_80178D40] @@ -123,16 +124,18 @@ segments: - [0x7873c, data, tail7] - [0x78740, .rodata, ov_SC03_011_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x7875c, data, tail8] + - [0x78780, .rodata, ov_SC03_011_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x7879c, data, tail9] - [0x787b4, .rodata, ov_SC03_011_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x787d4, data, tail9] + - [0x787d4, data, tail10] - [0x78854, .rodata, ov_SC03_011_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78868, data, tail10] + - [0x78868, data, tail11] - [0x78a10, .rodata, ov_SC03_011_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78b88, data, tail11] + - [0x78b88, data, tail12] - [0x78c18, .rodata, ov_SC03_011_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78ca4, data, tail12] + - [0x78ca4, data, tail13] - [0x78cbc, .rodata, ov_SC03_011_jr_8017C730] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78cdc, data, tail13] + - [0x78cdc, data, tail14] - [0x7A2A8, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x7A2AB] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_012.yaml b/config/splat.ov_SC03_012.yaml index 7bfb938b0..747cf9253 100644 --- a/config/splat.ov_SC03_012.yaml +++ b/config/splat.ov_SC03_012.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_012_jr_80159C84] - [0x32270, c, ov_SC03_012_jr_8015A3C8] - [0x32cd4, c, ov_SC03_012_jr_8015AE2C] + - [0x341d4, c, ov_SC03_012_jr_8015C32C] - [0x42a14, c, ov_SC03_012_jr_8016AB6C] - [0x4b364, c, ov_SC03_012_jr_801734BC] - [0x50be8, c, ov_SC03_012_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x6b598, data, tail8] - [0x6b59c, .rodata, ov_SC03_012_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x6b5b8, data, tail9] + - [0x6b5dc, .rodata, ov_SC03_012_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6b5f8, data, tail10] - [0x6b610, .rodata, ov_SC03_012_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b630, data, tail10] + - [0x6b630, data, tail11] - [0x6b6b0, .rodata, ov_SC03_012_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b6c4, data, tail11] + - [0x6b6c4, data, tail12] - [0x6b86c, .rodata, ov_SC03_012_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b9e4, data, tail12] + - [0x6b9e4, data, tail13] - [0x6ba74, .rodata, ov_SC03_012_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6bb00, data, tail13] + - [0x6bb00, data, tail14] - [0x6D004, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6D007] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_013.yaml b/config/splat.ov_SC03_013.yaml index 8314a7f55..d9574471e 100644 --- a/config/splat.ov_SC03_013.yaml +++ b/config/splat.ov_SC03_013.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_013_jr_80159C84] - [0x32270, c, ov_SC03_013_jr_8015A3C8] - [0x32cd4, c, ov_SC03_013_jr_8015AE2C] + - [0x341d4, c, ov_SC03_013_jr_8015C32C] - [0x42a14, c, ov_SC03_013_jr_8016AB6C] - [0x4b364, c, ov_SC03_013_jr_801734BC] - [0x50be8, c, ov_SC03_013_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x83830, data, tail8] - [0x83834, .rodata, ov_SC03_013_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x83850, data, tail9] + - [0x83874, .rodata, ov_SC03_013_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x83890, data, tail10] - [0x838a8, .rodata, ov_SC03_013_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x838c8, data, tail10] + - [0x838c8, data, tail11] - [0x83948, .rodata, ov_SC03_013_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8395c, data, tail11] + - [0x8395c, data, tail12] - [0x83b04, .rodata, ov_SC03_013_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x83c7c, data, tail12] + - [0x83c7c, data, tail13] - [0x83d0c, .rodata, ov_SC03_013_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x83d98, data, tail13] + - [0x83d98, data, tail14] - [0x853FC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x853FF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_014.yaml b/config/splat.ov_SC03_014.yaml index 46881b788..413dda9bf 100644 --- a/config/splat.ov_SC03_014.yaml +++ b/config/splat.ov_SC03_014.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_014_jr_80159C84] - [0x32270, c, ov_SC03_014_jr_8015A3C8] - [0x32cd4, c, ov_SC03_014_jr_8015AE2C] + - [0x341d4, c, ov_SC03_014_jr_8015C32C] - [0x42a14, c, ov_SC03_014_jr_8016AB6C] - [0x4b364, c, ov_SC03_014_jr_801734BC] - [0x50be8, c, ov_SC03_014_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xc0c04, data, tail8] - [0xc0c08, .rodata, ov_SC03_014_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc0c24, data, tail9] + - [0xc0c48, .rodata, ov_SC03_014_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc0c64, data, tail10] - [0xc0c7c, .rodata, ov_SC03_014_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc0c9c, data, tail10] + - [0xc0c9c, data, tail11] - [0xc0d1c, .rodata, ov_SC03_014_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc0d30, data, tail11] + - [0xc0d30, data, tail12] - [0xc0ed8, .rodata, ov_SC03_014_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1050, data, tail12] + - [0xc1050, data, tail13] - [0xc10e0, .rodata, ov_SC03_014_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc116c, data, tail13] + - [0xc116c, data, tail14] - [0xc11b0, .rodata, ov_SC03_014_jr_8017EB7C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc11d0, data, tail14] + - [0xc11d0, data, tail15] - [0xC2EE4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC2EE7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_015.yaml b/config/splat.ov_SC03_015.yaml index 574ad8da5..48cc3e95d 100644 --- a/config/splat.ov_SC03_015.yaml +++ b/config/splat.ov_SC03_015.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_015_jr_80159C84] - [0x32270, c, ov_SC03_015_jr_8015A3C8] - [0x32cd4, c, ov_SC03_015_jr_8015AE2C] + - [0x341d4, c, ov_SC03_015_jr_8015C32C] - [0x42a14, c, ov_SC03_015_jr_8016AB6C] - [0x4b364, c, ov_SC03_015_jr_801734BC] - [0x50be8, c, ov_SC03_015_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xc0c04, data, tail8] - [0xc0c08, .rodata, ov_SC03_015_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc0c24, data, tail9] + - [0xc0c48, .rodata, ov_SC03_015_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc0c64, data, tail10] - [0xc0c7c, .rodata, ov_SC03_015_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc0c9c, data, tail10] + - [0xc0c9c, data, tail11] - [0xc0d1c, .rodata, ov_SC03_015_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc0d30, data, tail11] + - [0xc0d30, data, tail12] - [0xc0ed8, .rodata, ov_SC03_015_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1050, data, tail12] + - [0xc1050, data, tail13] - [0xc10e0, .rodata, ov_SC03_015_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc116c, data, tail13] + - [0xc116c, data, tail14] - [0xc11b0, .rodata, ov_SC03_015_jr_8017EB7C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc11d0, data, tail14] + - [0xc11d0, data, tail15] - [0xC2EE4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC2EE7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_023.yaml b/config/splat.ov_SC03_023.yaml index 8adfb93f3..fb38e6df9 100644 --- a/config/splat.ov_SC03_023.yaml +++ b/config/splat.ov_SC03_023.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_023_jr_80159C84] - [0x32270, c, ov_SC03_023_jr_8015A3C8] - [0x32cd4, c, ov_SC03_023_jr_8015AE2C] + - [0x341d4, c, ov_SC03_023_jr_8015C32C] - [0x42a14, c, ov_SC03_023_jr_8016AB6C] - [0x4b364, c, ov_SC03_023_jr_801734BC] - [0x50be8, c, ov_SC03_023_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x6f1dc, data, tail8] - [0x6f1e0, .rodata, ov_SC03_023_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x6f1fc, data, tail9] + - [0x6f220, .rodata, ov_SC03_023_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6f23c, data, tail10] - [0x6f254, .rodata, ov_SC03_023_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6f274, data, tail10] + - [0x6f274, data, tail11] - [0x6f2f4, .rodata, ov_SC03_023_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6f308, data, tail11] + - [0x6f308, data, tail12] - [0x6f4b0, .rodata, ov_SC03_023_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6f628, data, tail12] + - [0x6f628, data, tail13] - [0x6f6b8, .rodata, ov_SC03_023_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6f744, data, tail13] + - [0x6f744, data, tail14] - [0x70C2C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x70C2F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_024.yaml b/config/splat.ov_SC03_024.yaml index bd576ba1e..4eec0f307 100644 --- a/config/splat.ov_SC03_024.yaml +++ b/config/splat.ov_SC03_024.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_024_jr_80159C84] - [0x32270, c, ov_SC03_024_jr_8015A3C8] - [0x32cd4, c, ov_SC03_024_jr_8015AE2C] + - [0x341d4, c, ov_SC03_024_jr_8015C32C] - [0x42a14, c, ov_SC03_024_jr_8016AB6C] - [0x4b364, c, ov_SC03_024_jr_801734BC] - [0x50be8, c, ov_SC03_024_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x97664, data, tail8] - [0x97668, .rodata, ov_SC03_024_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x97684, data, tail9] + - [0x976a8, .rodata, ov_SC03_024_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x976c4, data, tail10] - [0x976dc, .rodata, ov_SC03_024_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x976fc, data, tail10] + - [0x976fc, data, tail11] - [0x9777c, .rodata, ov_SC03_024_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x97790, data, tail11] + - [0x97790, data, tail12] - [0x97938, .rodata, ov_SC03_024_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x97ab0, data, tail12] + - [0x97ab0, data, tail13] - [0x97b40, .rodata, ov_SC03_024_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x97bcc, data, tail13] + - [0x97bcc, data, tail14] - [0x97c10, .rodata, ov_SC03_024_jr_8017DF84] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x97c30, data, tail14] + - [0x97c30, data, tail15] - [0x996F4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x996F7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_028.yaml b/config/splat.ov_SC03_028.yaml index b654902a0..ea5e49e30 100644 --- a/config/splat.ov_SC03_028.yaml +++ b/config/splat.ov_SC03_028.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_028_jr_80159C84] - [0x32270, c, ov_SC03_028_jr_8015A3C8] - [0x32cd4, c, ov_SC03_028_jr_8015AE2C] + - [0x341d4, c, ov_SC03_028_jr_8015C32C] - [0x42a14, c, ov_SC03_028_jr_8016AB6C] - [0x4b364, c, ov_SC03_028_jr_801734BC] - [0x50be8, c, ov_SC03_028_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xc17ec, data, tail8] - [0xc17f0, .rodata, ov_SC03_028_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc180c, data, tail9] + - [0xc1830, .rodata, ov_SC03_028_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc184c, data, tail10] - [0xc1864, .rodata, ov_SC03_028_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1884, data, tail10] + - [0xc1884, data, tail11] - [0xc1904, .rodata, ov_SC03_028_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1918, data, tail11] + - [0xc1918, data, tail12] - [0xc1ac0, .rodata, ov_SC03_028_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1c38, data, tail12] + - [0xc1c38, data, tail13] - [0xc1cc8, .rodata, ov_SC03_028_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc1d54, data, tail13] + - [0xc1d54, data, tail14] - [0xC44AC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC44AF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_029.yaml b/config/splat.ov_SC03_029.yaml index 167adf466..456c6e88c 100644 --- a/config/splat.ov_SC03_029.yaml +++ b/config/splat.ov_SC03_029.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_029_jr_80159C84] - [0x32270, c, ov_SC03_029_jr_8015A3C8] - [0x32cd4, c, ov_SC03_029_jr_8015AE2C] + - [0x341d4, c, ov_SC03_029_jr_8015C32C] - [0x42a14, c, ov_SC03_029_jr_8016AB6C] - [0x4b364, c, ov_SC03_029_jr_801734BC] - [0x50be8, c, ov_SC03_029_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xaf920, data, tail8] - [0xaf924, .rodata, ov_SC03_029_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xaf940, data, tail9] + - [0xaf964, .rodata, ov_SC03_029_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xaf980, data, tail10] - [0xaf998, .rodata, ov_SC03_029_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaf9b8, data, tail10] + - [0xaf9b8, data, tail11] - [0xafa38, .rodata, ov_SC03_029_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xafa4c, data, tail11] + - [0xafa4c, data, tail12] - [0xafbf4, .rodata, ov_SC03_029_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xafd6c, data, tail12] + - [0xafd6c, data, tail13] - [0xafdfc, .rodata, ov_SC03_029_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xafe88, data, tail13] + - [0xafe88, data, tail14] - [0xafea0, .rodata, ov_SC03_029_jr_8017DC70] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xafec0, data, tail14] + - [0xafec0, data, tail15] - [0xB18EC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xB18EF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_030.yaml b/config/splat.ov_SC03_030.yaml index 845c8a338..0b73b342f 100644 --- a/config/splat.ov_SC03_030.yaml +++ b/config/splat.ov_SC03_030.yaml @@ -103,6 +103,7 @@ segments: - [0x31b2c, c, ov_SC03_030_jr_80159C84] - [0x32270, c, ov_SC03_030_jr_8015A3C8] - [0x32cd4, c, ov_SC03_030_jr_8015AE2C] + - [0x341d4, c, ov_SC03_030_jr_8015C32C] - [0x42a14, c, ov_SC03_030_jr_8016AB6C] - [0x4b364, c, ov_SC03_030_jr_801734BC] - [0x50be8, c, ov_SC03_030_jr_80178D40] @@ -122,14 +123,16 @@ segments: - [0xb7fc4, data, tail7] - [0xb7fc8, .rodata, ov_SC03_030_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xb7fe4, data, tail8] + - [0xb8008, .rodata, ov_SC03_030_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xb8024, data, tail9] - [0xb803c, .rodata, ov_SC03_030_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb805c, data, tail9] + - [0xb805c, data, tail10] - [0xb80dc, .rodata, ov_SC03_030_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb80f0, data, tail10] + - [0xb80f0, data, tail11] - [0xb8298, .rodata, ov_SC03_030_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb8410, data, tail11] + - [0xb8410, data, tail12] - [0xb84a0, .rodata, ov_SC03_030_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb852c, data, tail12] + - [0xb852c, data, tail13] - [0xB9AF0] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes # ` - [0x, bin, trailing]` (the final 1-3 bytes spimdisasm's data path drops); diff --git a/config/splat.ov_SC03_031.yaml b/config/splat.ov_SC03_031.yaml index f5c82e8f8..4c3cd904b 100644 --- a/config/splat.ov_SC03_031.yaml +++ b/config/splat.ov_SC03_031.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_031_jr_80159C84] - [0x32270, c, ov_SC03_031_jr_8015A3C8] - [0x32cd4, c, ov_SC03_031_jr_8015AE2C] + - [0x341d4, c, ov_SC03_031_jr_8015C32C] - [0x42a14, c, ov_SC03_031_jr_8016AB6C] - [0x4b364, c, ov_SC03_031_jr_801734BC] - [0x50be8, c, ov_SC03_031_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9c468, data, tail8] - [0x9c46c, .rodata, ov_SC03_031_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9c488, data, tail9] + - [0x9c4ac, .rodata, ov_SC03_031_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9c4c8, data, tail10] - [0x9c4e0, .rodata, ov_SC03_031_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9c500, data, tail10] + - [0x9c500, data, tail11] - [0x9c580, .rodata, ov_SC03_031_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9c594, data, tail11] + - [0x9c594, data, tail12] - [0x9c73c, .rodata, ov_SC03_031_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9c8b4, data, tail12] + - [0x9c8b4, data, tail13] - [0x9c944, .rodata, ov_SC03_031_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9c9d0, data, tail13] + - [0x9c9d0, data, tail14] - [0x9c9e8, .rodata, ov_SC03_031_jr_8017DB5C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9ca08, data, tail14] + - [0x9ca08, data, tail15] - [0x9E14C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9E14F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_089.yaml b/config/splat.ov_SC03_089.yaml index 9e54b61f4..8c8607e4f 100644 --- a/config/splat.ov_SC03_089.yaml +++ b/config/splat.ov_SC03_089.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_089_jr_80159C84] - [0x32270, c, ov_SC03_089_jr_8015A3C8] - [0x32cd4, c, ov_SC03_089_jr_8015AE2C] + - [0x341d4, c, ov_SC03_089_jr_8015C32C] - [0x42a14, c, ov_SC03_089_jr_8016AB6C] - [0x4b364, c, ov_SC03_089_jr_801734BC] - [0x50be8, c, ov_SC03_089_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9ccd4, data, tail8] - [0x9ccd8, .rodata, ov_SC03_089_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9ccf4, data, tail9] + - [0x9cd18, .rodata, ov_SC03_089_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9cd34, data, tail10] - [0x9cd4c, .rodata, ov_SC03_089_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9cd6c, data, tail10] + - [0x9cd6c, data, tail11] - [0x9cdec, .rodata, ov_SC03_089_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9ce00, data, tail11] + - [0x9ce00, data, tail12] - [0x9cfa8, .rodata, ov_SC03_089_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9d120, data, tail12] + - [0x9d120, data, tail13] - [0x9d1b0, .rodata, ov_SC03_089_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9d23c, data, tail13] + - [0x9d23c, data, tail14] - [0x9d254, .rodata, ov_SC03_089_jr_8017CA80] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9d274, data, tail14] + - [0x9d274, data, tail15] - [0x9E7C4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9E7C7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_090.yaml b/config/splat.ov_SC03_090.yaml index 27220e7a5..3dc370e2c 100644 --- a/config/splat.ov_SC03_090.yaml +++ b/config/splat.ov_SC03_090.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_090_jr_80159C84] - [0x32270, c, ov_SC03_090_jr_8015A3C8] - [0x32cd4, c, ov_SC03_090_jr_8015AE2C] + - [0x341d4, c, ov_SC03_090_jr_8015C32C] - [0x42a14, c, ov_SC03_090_jr_8016AB6C] - [0x4b364, c, ov_SC03_090_jr_801734BC] - [0x50be8, c, ov_SC03_090_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xa2140, data, tail8] - [0xa2144, .rodata, ov_SC03_090_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xa2160, data, tail9] + - [0xa2184, .rodata, ov_SC03_090_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xa21a0, data, tail10] - [0xa21b8, .rodata, ov_SC03_090_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa21d8, data, tail10] + - [0xa21d8, data, tail11] - [0xa2258, .rodata, ov_SC03_090_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa226c, data, tail11] + - [0xa226c, data, tail12] - [0xa2414, .rodata, ov_SC03_090_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa258c, data, tail12] + - [0xa258c, data, tail13] - [0xa261c, .rodata, ov_SC03_090_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa26a8, data, tail13] + - [0xa26a8, data, tail14] - [0xa26c0, .rodata, ov_SC03_090_jr_8017CA80] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa26e0, data, tail14] + - [0xa26e0, data, tail15] - [0xA3C34, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xA3C37] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_091.yaml b/config/splat.ov_SC03_091.yaml index 51116a922..9c79a1a17 100644 --- a/config/splat.ov_SC03_091.yaml +++ b/config/splat.ov_SC03_091.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_091_jr_80159C84] - [0x32270, c, ov_SC03_091_jr_8015A3C8] - [0x32cd4, c, ov_SC03_091_jr_8015AE2C] + - [0x341d4, c, ov_SC03_091_jr_8015C32C] - [0x42a14, c, ov_SC03_091_jr_8016AB6C] - [0x4b364, c, ov_SC03_091_jr_801734BC] - [0x50be8, c, ov_SC03_091_jr_80178D40] @@ -127,16 +128,18 @@ segments: - [0xa880c, data, tail8] - [0xa8810, .rodata, ov_SC03_091_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xa882c, data, tail9] + - [0xa8850, .rodata, ov_SC03_091_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xa886c, data, tail10] - [0xa8884, .rodata, ov_SC03_091_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa88a4, data, tail10] + - [0xa88a4, data, tail11] - [0xa8924, .rodata, ov_SC03_091_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa8938, data, tail11] + - [0xa8938, data, tail12] - [0xa8ae0, .rodata, ov_SC03_091_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa8c58, data, tail12] + - [0xa8c58, data, tail13] - [0xa8ce8, .rodata, ov_SC03_091_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa8d74, data, tail13] + - [0xa8d74, data, tail14] - [0xa8d8c, .rodata, ov_SC03_091_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa8dac, data, tail14] + - [0xa8dac, data, tail15] - [0xAA584, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xAA587] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_092.yaml b/config/splat.ov_SC03_092.yaml index d17b9b29b..1593d0b7a 100644 --- a/config/splat.ov_SC03_092.yaml +++ b/config/splat.ov_SC03_092.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_092_jr_80159C84] - [0x32270, c, ov_SC03_092_jr_8015A3C8] - [0x32cd4, c, ov_SC03_092_jr_8015AE2C] + - [0x341d4, c, ov_SC03_092_jr_8015C32C] - [0x42a14, c, ov_SC03_092_jr_8016AB6C] - [0x4b364, c, ov_SC03_092_jr_801734BC] - [0x50be8, c, ov_SC03_092_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x893e4, data, tail8] - [0x893e8, .rodata, ov_SC03_092_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x89404, data, tail9] + - [0x89428, .rodata, ov_SC03_092_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x89444, data, tail10] - [0x8945c, .rodata, ov_SC03_092_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8947c, data, tail10] + - [0x8947c, data, tail11] - [0x894fc, .rodata, ov_SC03_092_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x89510, data, tail11] + - [0x89510, data, tail12] - [0x896b8, .rodata, ov_SC03_092_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x89830, data, tail12] + - [0x89830, data, tail13] - [0x898c0, .rodata, ov_SC03_092_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8994c, data, tail13] + - [0x8994c, data, tail14] - [0x8AF2C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8AF2F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_093.yaml b/config/splat.ov_SC03_093.yaml index d7cb81e74..317a2b39b 100644 --- a/config/splat.ov_SC03_093.yaml +++ b/config/splat.ov_SC03_093.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_093_jr_80159C84] - [0x32270, c, ov_SC03_093_jr_8015A3C8] - [0x32cd4, c, ov_SC03_093_jr_8015AE2C] + - [0x341d4, c, ov_SC03_093_jr_8015C32C] - [0x42a14, c, ov_SC03_093_jr_8016AB6C] - [0x4b364, c, ov_SC03_093_jr_801734BC] - [0x50be8, c, ov_SC03_093_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xa2838, data, tail8] - [0xa283c, .rodata, ov_SC03_093_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xa2858, data, tail9] + - [0xa287c, .rodata, ov_SC03_093_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xa2898, data, tail10] - [0xa28b0, .rodata, ov_SC03_093_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa28d0, data, tail10] + - [0xa28d0, data, tail11] - [0xa2950, .rodata, ov_SC03_093_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa2964, data, tail11] + - [0xa2964, data, tail12] - [0xa2b0c, .rodata, ov_SC03_093_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa2c84, data, tail12] + - [0xa2c84, data, tail13] - [0xa2d14, .rodata, ov_SC03_093_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa2da0, data, tail13] + - [0xa2da0, data, tail14] - [0xa2db8, .rodata, ov_SC03_093_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa2dd8, data, tail14] + - [0xa2dd8, data, tail15] - [0xA4584, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xA4587] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_094.yaml b/config/splat.ov_SC03_094.yaml index 942d8108f..d6908e869 100644 --- a/config/splat.ov_SC03_094.yaml +++ b/config/splat.ov_SC03_094.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_094_jr_80159C84] - [0x32270, c, ov_SC03_094_jr_8015A3C8] - [0x32cd4, c, ov_SC03_094_jr_8015AE2C] + - [0x341d4, c, ov_SC03_094_jr_8015C32C] - [0x42a14, c, ov_SC03_094_jr_8016AB6C] - [0x4b364, c, ov_SC03_094_jr_801734BC] - [0x50be8, c, ov_SC03_094_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xa9674, data, tail8] - [0xa9678, .rodata, ov_SC03_094_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xa9694, data, tail9] + - [0xa96b8, .rodata, ov_SC03_094_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xa96d4, data, tail10] - [0xa96ec, .rodata, ov_SC03_094_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa970c, data, tail10] + - [0xa970c, data, tail11] - [0xa978c, .rodata, ov_SC03_094_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa97a0, data, tail11] + - [0xa97a0, data, tail12] - [0xa9948, .rodata, ov_SC03_094_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa9ac0, data, tail12] + - [0xa9ac0, data, tail13] - [0xa9b50, .rodata, ov_SC03_094_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa9bdc, data, tail13] + - [0xa9bdc, data, tail14] - [0xa9bf4, .rodata, ov_SC03_094_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa9c14, data, tail14] + - [0xa9c14, data, tail15] - [0xAB13C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xAB13F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_095.yaml b/config/splat.ov_SC03_095.yaml index 8080c9f06..5562f7aef 100644 --- a/config/splat.ov_SC03_095.yaml +++ b/config/splat.ov_SC03_095.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_095_jr_80159C84] - [0x32270, c, ov_SC03_095_jr_8015A3C8] - [0x32cd4, c, ov_SC03_095_jr_8015AE2C] + - [0x341d4, c, ov_SC03_095_jr_8015C32C] - [0x42a14, c, ov_SC03_095_jr_8016AB6C] - [0x4b364, c, ov_SC03_095_jr_801734BC] - [0x50be8, c, ov_SC03_095_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x722a0, data, tail8] - [0x722a4, .rodata, ov_SC03_095_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x722c0, data, tail9] + - [0x722e4, .rodata, ov_SC03_095_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x72300, data, tail10] - [0x72318, .rodata, ov_SC03_095_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x72338, data, tail10] + - [0x72338, data, tail11] - [0x723b8, .rodata, ov_SC03_095_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x723cc, data, tail11] + - [0x723cc, data, tail12] - [0x72574, .rodata, ov_SC03_095_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x726ec, data, tail12] + - [0x726ec, data, tail13] - [0x7277c, .rodata, ov_SC03_095_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x72808, data, tail13] + - [0x72808, data, tail14] - [0x72820, .rodata, ov_SC03_095_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x72840, data, tail14] + - [0x72840, data, tail15] - [0x73D3C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x73D3F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_096.yaml b/config/splat.ov_SC03_096.yaml index ec5f4f51c..bc81b5ccd 100644 --- a/config/splat.ov_SC03_096.yaml +++ b/config/splat.ov_SC03_096.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_096_jr_80159C84] - [0x32270, c, ov_SC03_096_jr_8015A3C8] - [0x32cd4, c, ov_SC03_096_jr_8015AE2C] + - [0x341d4, c, ov_SC03_096_jr_8015C32C] - [0x42a14, c, ov_SC03_096_jr_8016AB6C] - [0x4b364, c, ov_SC03_096_jr_801734BC] - [0x50be8, c, ov_SC03_096_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x70d54, data, tail8] - [0x70d58, .rodata, ov_SC03_096_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x70d74, data, tail9] + - [0x70d98, .rodata, ov_SC03_096_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x70db4, data, tail10] - [0x70dcc, .rodata, ov_SC03_096_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x70dec, data, tail10] + - [0x70dec, data, tail11] - [0x70e6c, .rodata, ov_SC03_096_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x70e80, data, tail11] + - [0x70e80, data, tail12] - [0x71028, .rodata, ov_SC03_096_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x711a0, data, tail12] + - [0x711a0, data, tail13] - [0x71230, .rodata, ov_SC03_096_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x712bc, data, tail13] + - [0x712bc, data, tail14] - [0x712d4, .rodata, ov_SC03_096_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x712f4, data, tail14] + - [0x712f4, data, tail15] - [0x727F4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x727F7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_097.yaml b/config/splat.ov_SC03_097.yaml index f45d64f99..fc1c9462f 100644 --- a/config/splat.ov_SC03_097.yaml +++ b/config/splat.ov_SC03_097.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_097_jr_80159C84] - [0x32270, c, ov_SC03_097_jr_8015A3C8] - [0x32cd4, c, ov_SC03_097_jr_8015AE2C] + - [0x341d4, c, ov_SC03_097_jr_8015C32C] - [0x42a14, c, ov_SC03_097_jr_8016AB6C] - [0x4b364, c, ov_SC03_097_jr_801734BC] - [0x50be8, c, ov_SC03_097_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x80dc4, data, tail8] - [0x80dc8, .rodata, ov_SC03_097_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x80de4, data, tail9] + - [0x80e08, .rodata, ov_SC03_097_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x80e24, data, tail10] - [0x80e3c, .rodata, ov_SC03_097_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80e5c, data, tail10] + - [0x80e5c, data, tail11] - [0x80edc, .rodata, ov_SC03_097_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80ef0, data, tail11] + - [0x80ef0, data, tail12] - [0x81098, .rodata, ov_SC03_097_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x81210, data, tail12] + - [0x81210, data, tail13] - [0x812a0, .rodata, ov_SC03_097_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8132c, data, tail13] + - [0x8132c, data, tail14] - [0x81344, .rodata, ov_SC03_097_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x81364, data, tail14] + - [0x81364, data, tail15] - [0x82D74, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x82D77] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_098.yaml b/config/splat.ov_SC03_098.yaml index b30375fe1..ffaf695f6 100644 --- a/config/splat.ov_SC03_098.yaml +++ b/config/splat.ov_SC03_098.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_098_jr_80159C84] - [0x32270, c, ov_SC03_098_jr_8015A3C8] - [0x32cd4, c, ov_SC03_098_jr_8015AE2C] + - [0x341d4, c, ov_SC03_098_jr_8015C32C] - [0x42a14, c, ov_SC03_098_jr_8016AB6C] - [0x4b364, c, ov_SC03_098_jr_801734BC] - [0x50be8, c, ov_SC03_098_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9ba48, data, tail8] - [0x9ba4c, .rodata, ov_SC03_098_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9ba68, data, tail9] + - [0x9ba8c, .rodata, ov_SC03_098_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9baa8, data, tail10] - [0x9bac0, .rodata, ov_SC03_098_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9bae0, data, tail10] + - [0x9bae0, data, tail11] - [0x9bb60, .rodata, ov_SC03_098_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9bb74, data, tail11] + - [0x9bb74, data, tail12] - [0x9bd1c, .rodata, ov_SC03_098_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9be94, data, tail12] + - [0x9be94, data, tail13] - [0x9bf24, .rodata, ov_SC03_098_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9bfb0, data, tail13] + - [0x9bfb0, data, tail14] - [0x9bfc8, .rodata, ov_SC03_098_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9bfe8, data, tail14] + - [0x9bfe8, data, tail15] - [0x9D75C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9D75F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_099.yaml b/config/splat.ov_SC03_099.yaml index 9d2084be9..344f2220d 100644 --- a/config/splat.ov_SC03_099.yaml +++ b/config/splat.ov_SC03_099.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_099_jr_80159C84] - [0x32270, c, ov_SC03_099_jr_8015A3C8] - [0x32cd4, c, ov_SC03_099_jr_8015AE2C] + - [0x341d4, c, ov_SC03_099_jr_8015C32C] - [0x42a14, c, ov_SC03_099_jr_8016AB6C] - [0x4b364, c, ov_SC03_099_jr_801734BC] - [0x50be8, c, ov_SC03_099_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9571c, data, tail8] - [0x95720, .rodata, ov_SC03_099_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9573c, data, tail9] + - [0x95760, .rodata, ov_SC03_099_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9577c, data, tail10] - [0x95794, .rodata, ov_SC03_099_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x957b4, data, tail10] + - [0x957b4, data, tail11] - [0x95834, .rodata, ov_SC03_099_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x95848, data, tail11] + - [0x95848, data, tail12] - [0x959f0, .rodata, ov_SC03_099_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x95b68, data, tail12] + - [0x95b68, data, tail13] - [0x95bf8, .rodata, ov_SC03_099_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x95c84, data, tail13] + - [0x95c84, data, tail14] - [0x95c9c, .rodata, ov_SC03_099_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x95cbc, data, tail14] + - [0x95cbc, data, tail15] - [0x97304, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x97307] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_100.yaml b/config/splat.ov_SC03_100.yaml index aedb95849..9223a7160 100644 --- a/config/splat.ov_SC03_100.yaml +++ b/config/splat.ov_SC03_100.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_100_jr_80159C84] - [0x32270, c, ov_SC03_100_jr_8015A3C8] - [0x32cd4, c, ov_SC03_100_jr_8015AE2C] + - [0x341d4, c, ov_SC03_100_jr_8015C32C] - [0x42a14, c, ov_SC03_100_jr_8016AB6C] - [0x4b364, c, ov_SC03_100_jr_801734BC] - [0x50be8, c, ov_SC03_100_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9e9a0, data, tail8] - [0x9e9a4, .rodata, ov_SC03_100_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9e9c0, data, tail9] + - [0x9e9e4, .rodata, ov_SC03_100_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9ea00, data, tail10] - [0x9ea18, .rodata, ov_SC03_100_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9ea38, data, tail10] + - [0x9ea38, data, tail11] - [0x9eab8, .rodata, ov_SC03_100_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9eacc, data, tail11] + - [0x9eacc, data, tail12] - [0x9ec74, .rodata, ov_SC03_100_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9edec, data, tail12] + - [0x9edec, data, tail13] - [0x9ee7c, .rodata, ov_SC03_100_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9ef08, data, tail13] + - [0x9ef08, data, tail14] - [0x9ef20, .rodata, ov_SC03_100_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9ef40, data, tail14] + - [0x9ef40, data, tail15] - [0xA080C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xA080F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_101.yaml b/config/splat.ov_SC03_101.yaml index d243dab37..c8801e14d 100644 --- a/config/splat.ov_SC03_101.yaml +++ b/config/splat.ov_SC03_101.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_101_jr_80159C84] - [0x32270, c, ov_SC03_101_jr_8015A3C8] - [0x32cd4, c, ov_SC03_101_jr_8015AE2C] + - [0x341d4, c, ov_SC03_101_jr_8015C32C] - [0x42a14, c, ov_SC03_101_jr_8016AB6C] - [0x4b364, c, ov_SC03_101_jr_801734BC] - [0x50be8, c, ov_SC03_101_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x74268, data, tail8] - [0x7426c, .rodata, ov_SC03_101_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x74288, data, tail9] + - [0x742ac, .rodata, ov_SC03_101_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x742c8, data, tail10] - [0x742e0, .rodata, ov_SC03_101_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x74300, data, tail10] + - [0x74300, data, tail11] - [0x74380, .rodata, ov_SC03_101_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x74394, data, tail11] + - [0x74394, data, tail12] - [0x7453c, .rodata, ov_SC03_101_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x746b4, data, tail12] + - [0x746b4, data, tail13] - [0x74744, .rodata, ov_SC03_101_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x747d0, data, tail13] + - [0x747d0, data, tail14] - [0x747e8, .rodata, ov_SC03_101_jr_8017CA80] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x74808, data, tail14] + - [0x74808, data, tail15] - [0x760CC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x760CF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_102.yaml b/config/splat.ov_SC03_102.yaml index fc9fa88f4..2ae7c60ff 100644 --- a/config/splat.ov_SC03_102.yaml +++ b/config/splat.ov_SC03_102.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_102_jr_80159C84] - [0x32270, c, ov_SC03_102_jr_8015A3C8] - [0x32cd4, c, ov_SC03_102_jr_8015AE2C] + - [0x341d4, c, ov_SC03_102_jr_8015C32C] - [0x42a14, c, ov_SC03_102_jr_8016AB6C] - [0x4b364, c, ov_SC03_102_jr_801734BC] - [0x50be8, c, ov_SC03_102_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8fee4, data, tail8] - [0x8fee8, .rodata, ov_SC03_102_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8ff04, data, tail9] + - [0x8ff28, .rodata, ov_SC03_102_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8ff44, data, tail10] - [0x8ff5c, .rodata, ov_SC03_102_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8ff7c, data, tail10] + - [0x8ff7c, data, tail11] - [0x8fffc, .rodata, ov_SC03_102_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x90010, data, tail11] + - [0x90010, data, tail12] - [0x901b8, .rodata, ov_SC03_102_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x90330, data, tail12] + - [0x90330, data, tail13] - [0x903c0, .rodata, ov_SC03_102_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9044c, data, tail13] + - [0x9044c, data, tail14] - [0x90464, .rodata, ov_SC03_102_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x90484, data, tail14] + - [0x90484, data, tail15] - [0x91ACC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x91ACF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_103.yaml b/config/splat.ov_SC03_103.yaml index 6cbb4eac1..153f6e5d2 100644 --- a/config/splat.ov_SC03_103.yaml +++ b/config/splat.ov_SC03_103.yaml @@ -103,6 +103,7 @@ segments: - [0x31b2c, c, ov_SC03_103_jr_80159C84] - [0x32270, c, ov_SC03_103_jr_8015A3C8] - [0x32cd4, c, ov_SC03_103_jr_8015AE2C] + - [0x341d4, c, ov_SC03_103_jr_8015C32C] - [0x42a14, c, ov_SC03_103_jr_8016AB6C] - [0x4b364, c, ov_SC03_103_jr_801734BC] - [0x50be8, c, ov_SC03_103_jr_80178D40] @@ -123,16 +124,18 @@ segments: - [0x9b098, data, tail7] - [0x9b09c, .rodata, ov_SC03_103_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9b0b8, data, tail8] + - [0x9b0dc, .rodata, ov_SC03_103_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9b0f8, data, tail9] - [0x9b110, .rodata, ov_SC03_103_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9b130, data, tail9] + - [0x9b130, data, tail10] - [0x9b1b0, .rodata, ov_SC03_103_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9b1c4, data, tail10] + - [0x9b1c4, data, tail11] - [0x9b36c, .rodata, ov_SC03_103_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9b4e4, data, tail11] + - [0x9b4e4, data, tail12] - [0x9b574, .rodata, ov_SC03_103_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9b600, data, tail12] + - [0x9b600, data, tail13] - [0x9b618, .rodata, ov_SC03_103_jr_8017C294] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9b638, data, tail13] + - [0x9b638, data, tail14] - [0x9CC7C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9CC7F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_104.yaml b/config/splat.ov_SC03_104.yaml index 590334aba..4b9ea8c65 100644 --- a/config/splat.ov_SC03_104.yaml +++ b/config/splat.ov_SC03_104.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_104_jr_80159C84] - [0x32270, c, ov_SC03_104_jr_8015A3C8] - [0x32cd4, c, ov_SC03_104_jr_8015AE2C] + - [0x341d4, c, ov_SC03_104_jr_8015C32C] - [0x42a14, c, ov_SC03_104_jr_8016AB6C] - [0x4b364, c, ov_SC03_104_jr_801734BC] - [0x50be8, c, ov_SC03_104_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x965f8, data, tail8] - [0x965fc, .rodata, ov_SC03_104_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x96618, data, tail9] + - [0x9663c, .rodata, ov_SC03_104_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x96658, data, tail10] - [0x96670, .rodata, ov_SC03_104_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x96690, data, tail10] + - [0x96690, data, tail11] - [0x96710, .rodata, ov_SC03_104_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x96724, data, tail11] + - [0x96724, data, tail12] - [0x968cc, .rodata, ov_SC03_104_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x96a44, data, tail12] + - [0x96a44, data, tail13] - [0x96ad4, .rodata, ov_SC03_104_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x96b60, data, tail13] + - [0x96b60, data, tail14] - [0x96b78, .rodata, ov_SC03_104_jr_8017CA80] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x96b98, data, tail14] + - [0x96b98, data, tail15] - [0x9833C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9833F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_105.yaml b/config/splat.ov_SC03_105.yaml index 3ffdfc14f..b36cb8c1e 100644 --- a/config/splat.ov_SC03_105.yaml +++ b/config/splat.ov_SC03_105.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_105_jr_80159C84] - [0x32270, c, ov_SC03_105_jr_8015A3C8] - [0x32cd4, c, ov_SC03_105_jr_8015AE2C] + - [0x341d4, c, ov_SC03_105_jr_8015C32C] - [0x42a14, c, ov_SC03_105_jr_8016AB6C] - [0x4b364, c, ov_SC03_105_jr_801734BC] - [0x50be8, c, ov_SC03_105_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8f8f0, data, tail8] - [0x8f8f4, .rodata, ov_SC03_105_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8f910, data, tail9] + - [0x8f934, .rodata, ov_SC03_105_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8f950, data, tail10] - [0x8f968, .rodata, ov_SC03_105_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8f988, data, tail10] + - [0x8f988, data, tail11] - [0x8fa08, .rodata, ov_SC03_105_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8fa1c, data, tail11] + - [0x8fa1c, data, tail12] - [0x8fbc4, .rodata, ov_SC03_105_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8fd3c, data, tail12] + - [0x8fd3c, data, tail13] - [0x8fdcc, .rodata, ov_SC03_105_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8fe58, data, tail13] + - [0x8fe58, data, tail14] - [0x8ffa8, .rodata, ov_SC03_105_jr_8017C8D0] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8ffc8, data, tail14] + - [0x8ffc8, data, tail15] - [0x94BC4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x94BC7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_108.yaml b/config/splat.ov_SC03_108.yaml index 6f61bd7cd..27ba8388e 100644 --- a/config/splat.ov_SC03_108.yaml +++ b/config/splat.ov_SC03_108.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_108_jr_80159C84] - [0x32270, c, ov_SC03_108_jr_8015A3C8] - [0x32cd4, c, ov_SC03_108_jr_8015AE2C] + - [0x341d4, c, ov_SC03_108_jr_8015C32C] - [0x42a14, c, ov_SC03_108_jr_8016AB6C] - [0x4b364, c, ov_SC03_108_jr_801734BC] - [0x50be8, c, ov_SC03_108_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x77df8, data, tail8] - [0x77dfc, .rodata, ov_SC03_108_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x77e18, data, tail9] + - [0x77e3c, .rodata, ov_SC03_108_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x77e58, data, tail10] - [0x77e70, .rodata, ov_SC03_108_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77e90, data, tail10] + - [0x77e90, data, tail11] - [0x77f10, .rodata, ov_SC03_108_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77f24, data, tail11] + - [0x77f24, data, tail12] - [0x780cc, .rodata, ov_SC03_108_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78244, data, tail12] + - [0x78244, data, tail13] - [0x782d4, .rodata, ov_SC03_108_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78360, data, tail13] + - [0x78360, data, tail14] - [0x78378, .rodata, ov_SC03_108_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78398, data, tail14] + - [0x78398, data, tail15] - [0x7994C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x7994F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_109.yaml b/config/splat.ov_SC03_109.yaml index 64ab21b37..827d30aa0 100644 --- a/config/splat.ov_SC03_109.yaml +++ b/config/splat.ov_SC03_109.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_109_jr_80159C84] - [0x32270, c, ov_SC03_109_jr_8015A3C8] - [0x32cd4, c, ov_SC03_109_jr_8015AE2C] + - [0x341d4, c, ov_SC03_109_jr_8015C32C] - [0x42a14, c, ov_SC03_109_jr_8016AB6C] - [0x4b364, c, ov_SC03_109_jr_801734BC] - [0x50be8, c, ov_SC03_109_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x70908, data, tail8] - [0x7090c, .rodata, ov_SC03_109_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x70928, data, tail9] + - [0x7094c, .rodata, ov_SC03_109_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x70968, data, tail10] - [0x70980, .rodata, ov_SC03_109_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x709a0, data, tail10] + - [0x709a0, data, tail11] - [0x70a20, .rodata, ov_SC03_109_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x70a34, data, tail11] + - [0x70a34, data, tail12] - [0x70bdc, .rodata, ov_SC03_109_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x70d54, data, tail12] + - [0x70d54, data, tail13] - [0x70de4, .rodata, ov_SC03_109_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x70e70, data, tail13] + - [0x70e70, data, tail14] - [0x70e88, .rodata, ov_SC03_109_jr_8017C180] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x70ea8, data, tail14] + - [0x70ea8, data, tail15] - [0x72354, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x72357] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_110.yaml b/config/splat.ov_SC03_110.yaml index ee3ec0433..55a647717 100644 --- a/config/splat.ov_SC03_110.yaml +++ b/config/splat.ov_SC03_110.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_110_jr_80159C84] - [0x32270, c, ov_SC03_110_jr_8015A3C8] - [0x32cd4, c, ov_SC03_110_jr_8015AE2C] + - [0x341d4, c, ov_SC03_110_jr_8015C32C] - [0x42a14, c, ov_SC03_110_jr_8016AB6C] - [0x4b364, c, ov_SC03_110_jr_801734BC] - [0x50be8, c, ov_SC03_110_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x785a4, data, tail8] - [0x785a8, .rodata, ov_SC03_110_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x785c4, data, tail9] + - [0x785e8, .rodata, ov_SC03_110_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x78604, data, tail10] - [0x7861c, .rodata, ov_SC03_110_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7863c, data, tail10] + - [0x7863c, data, tail11] - [0x786bc, .rodata, ov_SC03_110_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x786d0, data, tail11] + - [0x786d0, data, tail12] - [0x78878, .rodata, ov_SC03_110_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x789f0, data, tail12] + - [0x789f0, data, tail13] - [0x78a80, .rodata, ov_SC03_110_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78b0c, data, tail13] + - [0x78b0c, data, tail14] - [0x78b24, .rodata, ov_SC03_110_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x78b44, data, tail14] + - [0x78b44, data, tail15] - [0x7A384, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x7A387] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_111.yaml b/config/splat.ov_SC03_111.yaml index c6afda217..eed71e2be 100644 --- a/config/splat.ov_SC03_111.yaml +++ b/config/splat.ov_SC03_111.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_111_jr_80159C84] - [0x32270, c, ov_SC03_111_jr_8015A3C8] - [0x32cd4, c, ov_SC03_111_jr_8015AE2C] + - [0x341d4, c, ov_SC03_111_jr_8015C32C] - [0x42a14, c, ov_SC03_111_jr_8016AB6C] - [0x4b364, c, ov_SC03_111_jr_801734BC] - [0x50be8, c, ov_SC03_111_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8fb24, data, tail8] - [0x8fb28, .rodata, ov_SC03_111_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8fb44, data, tail9] + - [0x8fb68, .rodata, ov_SC03_111_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8fb84, data, tail10] - [0x8fb9c, .rodata, ov_SC03_111_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8fbbc, data, tail10] + - [0x8fbbc, data, tail11] - [0x8fc3c, .rodata, ov_SC03_111_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8fc50, data, tail11] + - [0x8fc50, data, tail12] - [0x8fdf8, .rodata, ov_SC03_111_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8ff70, data, tail12] + - [0x8ff70, data, tail13] - [0x90000, .rodata, ov_SC03_111_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9008c, data, tail13] + - [0x9008c, data, tail14] - [0x900a4, .rodata, ov_SC03_111_jr_8017EC58] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x900c4, data, tail14] + - [0x900c4, data, tail15] - [0x91A2C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x91A2F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_112.yaml b/config/splat.ov_SC03_112.yaml index e04e41437..8d8a18d83 100644 --- a/config/splat.ov_SC03_112.yaml +++ b/config/splat.ov_SC03_112.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_112_jr_80159C84] - [0x32270, c, ov_SC03_112_jr_8015A3C8] - [0x32cd4, c, ov_SC03_112_jr_8015AE2C] + - [0x341d4, c, ov_SC03_112_jr_8015C32C] - [0x42a14, c, ov_SC03_112_jr_8016AB6C] - [0x4b364, c, ov_SC03_112_jr_801734BC] - [0x50be8, c, ov_SC03_112_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8328c, data, tail8] - [0x83290, .rodata, ov_SC03_112_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x832ac, data, tail9] + - [0x832d0, .rodata, ov_SC03_112_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x832ec, data, tail10] - [0x83304, .rodata, ov_SC03_112_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x83324, data, tail10] + - [0x83324, data, tail11] - [0x833a4, .rodata, ov_SC03_112_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x833b8, data, tail11] + - [0x833b8, data, tail12] - [0x83560, .rodata, ov_SC03_112_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x836d8, data, tail12] + - [0x836d8, data, tail13] - [0x83768, .rodata, ov_SC03_112_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x837f4, data, tail13] + - [0x837f4, data, tail14] - [0x8380c, .rodata, ov_SC03_112_jr_8017C294] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8382c, data, tail14] + - [0x8382c, data, tail15] - [0x84FF4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x84FF7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_113.yaml b/config/splat.ov_SC03_113.yaml index f03cdd842..75a433729 100644 --- a/config/splat.ov_SC03_113.yaml +++ b/config/splat.ov_SC03_113.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_113_jr_80159C84] - [0x32270, c, ov_SC03_113_jr_8015A3C8] - [0x32cd4, c, ov_SC03_113_jr_8015AE2C] + - [0x341d4, c, ov_SC03_113_jr_8015C32C] - [0x42a14, c, ov_SC03_113_jr_8016AB6C] - [0x4b364, c, ov_SC03_113_jr_801734BC] - [0x50be8, c, ov_SC03_113_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x7bf14, data, tail8] - [0x7bf18, .rodata, ov_SC03_113_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x7bf34, data, tail9] + - [0x7bf58, .rodata, ov_SC03_113_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x7bf74, data, tail10] - [0x7bf8c, .rodata, ov_SC03_113_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7bfac, data, tail10] + - [0x7bfac, data, tail11] - [0x7c02c, .rodata, ov_SC03_113_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7c040, data, tail11] + - [0x7c040, data, tail12] - [0x7c1e8, .rodata, ov_SC03_113_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7c360, data, tail12] + - [0x7c360, data, tail13] - [0x7c3f0, .rodata, ov_SC03_113_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7c47c, data, tail13] + - [0x7c47c, data, tail14] - [0x7c494, .rodata, ov_SC03_113_jr_8017C294] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7c4b4, data, tail14] + - [0x7c4b4, data, tail15] - [0x7DB94, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x7DB97] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_114.yaml b/config/splat.ov_SC03_114.yaml index 8ee32a223..08e7e3f2e 100644 --- a/config/splat.ov_SC03_114.yaml +++ b/config/splat.ov_SC03_114.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_114_jr_80159C84] - [0x32270, c, ov_SC03_114_jr_8015A3C8] - [0x32cd4, c, ov_SC03_114_jr_8015AE2C] + - [0x341d4, c, ov_SC03_114_jr_8015C32C] - [0x42a14, c, ov_SC03_114_jr_8016AB6C] - [0x4b364, c, ov_SC03_114_jr_801734BC] - [0x50be8, c, ov_SC03_114_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x7fc20, data, tail8] - [0x7fc24, .rodata, ov_SC03_114_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x7fc40, data, tail9] + - [0x7fc64, .rodata, ov_SC03_114_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x7fc80, data, tail10] - [0x7fc98, .rodata, ov_SC03_114_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7fcb8, data, tail10] + - [0x7fcb8, data, tail11] - [0x7fd38, .rodata, ov_SC03_114_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7fd4c, data, tail11] + - [0x7fd4c, data, tail12] - [0x7fef4, .rodata, ov_SC03_114_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8006c, data, tail12] + - [0x8006c, data, tail13] - [0x800fc, .rodata, ov_SC03_114_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80188, data, tail13] + - [0x80188, data, tail14] - [0x801a0, .rodata, ov_SC03_114_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x801c0, data, tail14] + - [0x801c0, data, tail15] - [0x8170C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8170F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_115.yaml b/config/splat.ov_SC03_115.yaml index b59c4d618..976c91edb 100644 --- a/config/splat.ov_SC03_115.yaml +++ b/config/splat.ov_SC03_115.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_115_jr_80159C84] - [0x32270, c, ov_SC03_115_jr_8015A3C8] - [0x32cd4, c, ov_SC03_115_jr_8015AE2C] + - [0x341d4, c, ov_SC03_115_jr_8015C32C] - [0x42a14, c, ov_SC03_115_jr_8016AB6C] - [0x4b364, c, ov_SC03_115_jr_801734BC] - [0x50be8, c, ov_SC03_115_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x6b594, data, tail8] - [0x6b598, .rodata, ov_SC03_115_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x6b5b4, data, tail9] + - [0x6b5d8, .rodata, ov_SC03_115_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6b5f4, data, tail10] - [0x6b60c, .rodata, ov_SC03_115_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b62c, data, tail10] + - [0x6b62c, data, tail11] - [0x6b6ac, .rodata, ov_SC03_115_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b6c0, data, tail11] + - [0x6b6c0, data, tail12] - [0x6b868, .rodata, ov_SC03_115_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b9e0, data, tail12] + - [0x6b9e0, data, tail13] - [0x6ba70, .rodata, ov_SC03_115_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6bafc, data, tail13] + - [0x6bafc, data, tail14] - [0x6bb14, .rodata, ov_SC03_115_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6bb34, data, tail14] + - [0x6bb34, data, tail15] - [0x6CFE4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6CFE7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_116.yaml b/config/splat.ov_SC03_116.yaml index 6b653c398..a7de136be 100644 --- a/config/splat.ov_SC03_116.yaml +++ b/config/splat.ov_SC03_116.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_116_jr_80159C84] - [0x32270, c, ov_SC03_116_jr_8015A3C8] - [0x32cd4, c, ov_SC03_116_jr_8015AE2C] + - [0x341d4, c, ov_SC03_116_jr_8015C32C] - [0x42a14, c, ov_SC03_116_jr_8016AB6C] - [0x4b364, c, ov_SC03_116_jr_801734BC] - [0x50be8, c, ov_SC03_116_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x6e130, data, tail8] - [0x6e134, .rodata, ov_SC03_116_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x6e150, data, tail9] + - [0x6e174, .rodata, ov_SC03_116_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6e190, data, tail10] - [0x6e1a8, .rodata, ov_SC03_116_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6e1c8, data, tail10] + - [0x6e1c8, data, tail11] - [0x6e248, .rodata, ov_SC03_116_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6e25c, data, tail11] + - [0x6e25c, data, tail12] - [0x6e404, .rodata, ov_SC03_116_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6e57c, data, tail12] + - [0x6e57c, data, tail13] - [0x6e60c, .rodata, ov_SC03_116_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6e698, data, tail13] + - [0x6e698, data, tail14] - [0x6FBF4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6FBF7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_117.yaml b/config/splat.ov_SC03_117.yaml index bb1ee6750..b7b0a72a6 100644 --- a/config/splat.ov_SC03_117.yaml +++ b/config/splat.ov_SC03_117.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_117_jr_80159C84] - [0x32270, c, ov_SC03_117_jr_8015A3C8] - [0x32cd4, c, ov_SC03_117_jr_8015AE2C] + - [0x341d4, c, ov_SC03_117_jr_8015C32C] - [0x42a14, c, ov_SC03_117_jr_8016AB6C] - [0x4b364, c, ov_SC03_117_jr_801734BC] - [0x50be8, c, ov_SC03_117_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xa47d0, data, tail8] - [0xa47d4, .rodata, ov_SC03_117_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xa47f0, data, tail9] + - [0xa4814, .rodata, ov_SC03_117_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xa4830, data, tail10] - [0xa4848, .rodata, ov_SC03_117_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa4868, data, tail10] + - [0xa4868, data, tail11] - [0xa48e8, .rodata, ov_SC03_117_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa48fc, data, tail11] + - [0xa48fc, data, tail12] - [0xa4aa4, .rodata, ov_SC03_117_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa4c1c, data, tail12] + - [0xa4c1c, data, tail13] - [0xa4cac, .rodata, ov_SC03_117_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa4d38, data, tail13] + - [0xa4d38, data, tail14] - [0xa4d50, .rodata, ov_SC03_117_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xa4d70, data, tail14] + - [0xa4d70, data, tail15] - [0xA67EC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xA67EF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_118.yaml b/config/splat.ov_SC03_118.yaml index fff337a10..2d4efd40f 100644 --- a/config/splat.ov_SC03_118.yaml +++ b/config/splat.ov_SC03_118.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_118_jr_80159C84] - [0x32270, c, ov_SC03_118_jr_8015A3C8] - [0x32cd4, c, ov_SC03_118_jr_8015AE2C] + - [0x341d4, c, ov_SC03_118_jr_8015C32C] - [0x42a14, c, ov_SC03_118_jr_8016AB6C] - [0x4b364, c, ov_SC03_118_jr_801734BC] - [0x50be8, c, ov_SC03_118_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xaa72c, data, tail8] - [0xaa730, .rodata, ov_SC03_118_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xaa74c, data, tail9] + - [0xaa770, .rodata, ov_SC03_118_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xaa78c, data, tail10] - [0xaa7a4, .rodata, ov_SC03_118_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaa7c4, data, tail10] + - [0xaa7c4, data, tail11] - [0xaa844, .rodata, ov_SC03_118_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaa858, data, tail11] + - [0xaa858, data, tail12] - [0xaaa00, .rodata, ov_SC03_118_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaab78, data, tail12] + - [0xaab78, data, tail13] - [0xaac08, .rodata, ov_SC03_118_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaac94, data, tail13] + - [0xaac94, data, tail14] - [0xaacd8, .rodata, ov_SC03_118_jr_8017FB84] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaacf8, data, tail14] + - [0xaacf8, data, tail15] - [0xAC6F4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xAC6F7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_119.yaml b/config/splat.ov_SC03_119.yaml index 5a205b3ad..0d572c9c7 100644 --- a/config/splat.ov_SC03_119.yaml +++ b/config/splat.ov_SC03_119.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_119_jr_80159C84] - [0x32270, c, ov_SC03_119_jr_8015A3C8] - [0x32cd4, c, ov_SC03_119_jr_8015AE2C] + - [0x341d4, c, ov_SC03_119_jr_8015C32C] - [0x42a14, c, ov_SC03_119_jr_8016AB6C] - [0x4b364, c, ov_SC03_119_jr_801734BC] - [0x50be8, c, ov_SC03_119_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xaa72c, data, tail8] - [0xaa730, .rodata, ov_SC03_119_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xaa74c, data, tail9] + - [0xaa770, .rodata, ov_SC03_119_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xaa78c, data, tail10] - [0xaa7a4, .rodata, ov_SC03_119_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaa7c4, data, tail10] + - [0xaa7c4, data, tail11] - [0xaa844, .rodata, ov_SC03_119_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaa858, data, tail11] + - [0xaa858, data, tail12] - [0xaaa00, .rodata, ov_SC03_119_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaab78, data, tail12] + - [0xaab78, data, tail13] - [0xaac08, .rodata, ov_SC03_119_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaac94, data, tail13] + - [0xaac94, data, tail14] - [0xaacd8, .rodata, ov_SC03_119_jr_8017FB84] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xaacf8, data, tail14] + - [0xaacf8, data, tail15] - [0xAC6F4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xAC6F7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_121.yaml b/config/splat.ov_SC03_121.yaml index 2ea269786..fd9280973 100644 --- a/config/splat.ov_SC03_121.yaml +++ b/config/splat.ov_SC03_121.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_121_jr_80159C84] - [0x32270, c, ov_SC03_121_jr_8015A3C8] - [0x32cd4, c, ov_SC03_121_jr_8015AE2C] + - [0x341d4, c, ov_SC03_121_jr_8015C32C] - [0x42a14, c, ov_SC03_121_jr_8016AB6C] - [0x4b364, c, ov_SC03_121_jr_801734BC] - [0x50be8, c, ov_SC03_121_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x85234, data, tail8] - [0x85238, .rodata, ov_SC03_121_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x85254, data, tail9] + - [0x85278, .rodata, ov_SC03_121_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x85294, data, tail10] - [0x852ac, .rodata, ov_SC03_121_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x852cc, data, tail10] + - [0x852cc, data, tail11] - [0x8534c, .rodata, ov_SC03_121_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x85360, data, tail11] + - [0x85360, data, tail12] - [0x85508, .rodata, ov_SC03_121_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x85680, data, tail12] + - [0x85680, data, tail13] - [0x85710, .rodata, ov_SC03_121_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8579c, data, tail13] + - [0x8579c, data, tail14] - [0x857b4, .rodata, ov_SC03_121_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x857d4, data, tail14] + - [0x857d4, data, tail15] - [0x86E54, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x86E57] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_124.yaml b/config/splat.ov_SC03_124.yaml index 7886b8d22..8890c0ea4 100644 --- a/config/splat.ov_SC03_124.yaml +++ b/config/splat.ov_SC03_124.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_124_jr_80159C84] - [0x32270, c, ov_SC03_124_jr_8015A3C8] - [0x32cd4, c, ov_SC03_124_jr_8015AE2C] + - [0x341d4, c, ov_SC03_124_jr_8015C32C] - [0x42a14, c, ov_SC03_124_jr_8016AB6C] - [0x4b364, c, ov_SC03_124_jr_801734BC] - [0x50be8, c, ov_SC03_124_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xb7988, data, tail8] - [0xb798c, .rodata, ov_SC03_124_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xb79a8, data, tail9] + - [0xb79cc, .rodata, ov_SC03_124_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xb79e8, data, tail10] - [0xb7a00, .rodata, ov_SC03_124_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb7a20, data, tail10] + - [0xb7a20, data, tail11] - [0xb7aa0, .rodata, ov_SC03_124_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb7ab4, data, tail11] + - [0xb7ab4, data, tail12] - [0xb7c5c, .rodata, ov_SC03_124_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb7dd4, data, tail12] + - [0xb7dd4, data, tail13] - [0xb7e64, .rodata, ov_SC03_124_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xb7ef0, data, tail13] + - [0xb7ef0, data, tail14] - [0xBA48C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xBA48F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_125.yaml b/config/splat.ov_SC03_125.yaml index 06c3cac8a..214b105d0 100644 --- a/config/splat.ov_SC03_125.yaml +++ b/config/splat.ov_SC03_125.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_125_jr_80159C84] - [0x32270, c, ov_SC03_125_jr_8015A3C8] - [0x32cd4, c, ov_SC03_125_jr_8015AE2C] + - [0x341d4, c, ov_SC03_125_jr_8015C32C] - [0x42a14, c, ov_SC03_125_jr_8016AB6C] - [0x4b364, c, ov_SC03_125_jr_801734BC] - [0x50be8, c, ov_SC03_125_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9a674, data, tail8] - [0x9a678, .rodata, ov_SC03_125_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9a694, data, tail9] + - [0x9a6b8, .rodata, ov_SC03_125_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9a6d4, data, tail10] - [0x9a6ec, .rodata, ov_SC03_125_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9a70c, data, tail10] + - [0x9a70c, data, tail11] - [0x9a78c, .rodata, ov_SC03_125_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9a7a0, data, tail11] + - [0x9a7a0, data, tail12] - [0x9a948, .rodata, ov_SC03_125_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9aac0, data, tail12] + - [0x9aac0, data, tail13] - [0x9ab50, .rodata, ov_SC03_125_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9abdc, data, tail13] + - [0x9abdc, data, tail14] - [0x9abf4, .rodata, ov_SC03_125_jr_8017D604] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9ac14, data, tail14] + - [0x9ac14, data, tail15] - [0x9C3E4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9C3E7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC03_126.yaml b/config/splat.ov_SC03_126.yaml index 06f79ce96..f7ca9060c 100644 --- a/config/splat.ov_SC03_126.yaml +++ b/config/splat.ov_SC03_126.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC03_126_jr_80159C84] - [0x32270, c, ov_SC03_126_jr_8015A3C8] - [0x32cd4, c, ov_SC03_126_jr_8015AE2C] + - [0x341d4, c, ov_SC03_126_jr_8015C32C] - [0x42a14, c, ov_SC03_126_jr_8016AB6C] - [0x4b364, c, ov_SC03_126_jr_801734BC] - [0x50be8, c, ov_SC03_126_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x65f60, data, tail8] - [0x65f64, .rodata, ov_SC03_126_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x65f80, data, tail9] + - [0x65fa4, .rodata, ov_SC03_126_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x65fc0, data, tail10] - [0x65fd8, .rodata, ov_SC03_126_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x65ff8, data, tail10] + - [0x65ff8, data, tail11] - [0x66078, .rodata, ov_SC03_126_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6608c, data, tail11] + - [0x6608c, data, tail12] - [0x66234, .rodata, ov_SC03_126_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x663ac, data, tail12] + - [0x663ac, data, tail13] - [0x6643c, .rodata, ov_SC03_126_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x664c8, data, tail13] + - [0x664c8, data, tail14] - [0x66500, .rodata, ov_SC03_126_jr_8017D5C0] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66520, data, tail14] + - [0x66520, data, tail15] - [0x679D4, bin, trailing] # final 1 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x679D5] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_000.yaml b/config/splat.ov_SC04_000.yaml index 512f85afd..14d25b2cb 100644 --- a/config/splat.ov_SC04_000.yaml +++ b/config/splat.ov_SC04_000.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_000_jr_80159C84] - [0x32270, c, ov_SC04_000_jr_8015A3C8] - [0x32cd4, c, ov_SC04_000_jr_8015AE2C] + - [0x341d4, c, ov_SC04_000_jr_8015C32C] - [0x42a14, c, ov_SC04_000_jr_8016AB6C] - [0x4b364, c, ov_SC04_000_jr_801734BC] - [0x50be8, c, ov_SC04_000_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x7ffdc, data, tail8] - [0x7ffe0, .rodata, ov_SC04_000_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x7fffc, data, tail9] + - [0x80020, .rodata, ov_SC04_000_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8003c, data, tail10] - [0x80054, .rodata, ov_SC04_000_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80074, data, tail10] + - [0x80074, data, tail11] - [0x800f4, .rodata, ov_SC04_000_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80108, data, tail11] + - [0x80108, data, tail12] - [0x802b0, .rodata, ov_SC04_000_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80428, data, tail12] + - [0x80428, data, tail13] - [0x804b8, .rodata, ov_SC04_000_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80544, data, tail13] + - [0x80544, data, tail14] - [0x8055c, .rodata, ov_SC04_000_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8057c, data, tail14] + - [0x8057c, data, tail15] - [0x82EFC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x82EFF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_002.yaml b/config/splat.ov_SC04_002.yaml index 5aa1af35d..63f323058 100644 --- a/config/splat.ov_SC04_002.yaml +++ b/config/splat.ov_SC04_002.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_002_jr_80159C84] - [0x32270, c, ov_SC04_002_jr_8015A3C8] - [0x32cd4, c, ov_SC04_002_jr_8015AE2C] + - [0x341d4, c, ov_SC04_002_jr_8015C32C] - [0x42a14, c, ov_SC04_002_jr_8016AB6C] - [0x4b364, c, ov_SC04_002_jr_801734BC] - [0x50be8, c, ov_SC04_002_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9732c, data, tail8] - [0x97330, .rodata, ov_SC04_002_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9734c, data, tail9] + - [0x97370, .rodata, ov_SC04_002_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9738c, data, tail10] - [0x973a4, .rodata, ov_SC04_002_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x973c4, data, tail10] + - [0x973c4, data, tail11] - [0x97444, .rodata, ov_SC04_002_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x97458, data, tail11] + - [0x97458, data, tail12] - [0x97600, .rodata, ov_SC04_002_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x97778, data, tail12] + - [0x97778, data, tail13] - [0x97808, .rodata, ov_SC04_002_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x97894, data, tail13] + - [0x97894, data, tail14] - [0x978ac, .rodata, ov_SC04_002_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x978cc, data, tail14] + - [0x978cc, data, tail15] - [0x995DC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x995DF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_003.yaml b/config/splat.ov_SC04_003.yaml index 41ff12514..06b202ffc 100644 --- a/config/splat.ov_SC04_003.yaml +++ b/config/splat.ov_SC04_003.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_003_jr_80159C84] - [0x32270, c, ov_SC04_003_jr_8015A3C8] - [0x32cd4, c, ov_SC04_003_jr_8015AE2C] + - [0x341d4, c, ov_SC04_003_jr_8015C32C] - [0x42a14, c, ov_SC04_003_jr_8016AB6C] - [0x4b364, c, ov_SC04_003_jr_801734BC] - [0x50be8, c, ov_SC04_003_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x71fa8, data, tail8] - [0x71fac, .rodata, ov_SC04_003_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x71fc8, data, tail9] + - [0x71fec, .rodata, ov_SC04_003_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x72008, data, tail10] - [0x72020, .rodata, ov_SC04_003_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x72040, data, tail10] + - [0x72040, data, tail11] - [0x720c0, .rodata, ov_SC04_003_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x720d4, data, tail11] + - [0x720d4, data, tail12] - [0x7227c, .rodata, ov_SC04_003_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x723f4, data, tail12] + - [0x723f4, data, tail13] - [0x72484, .rodata, ov_SC04_003_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x72510, data, tail13] + - [0x72510, data, tail14] - [0x72528, .rodata, ov_SC04_003_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x72548, data, tail14] + - [0x72548, data, tail15] - [0x73A94, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x73A97] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_004.yaml b/config/splat.ov_SC04_004.yaml index 9161edfa1..54ad9688d 100644 --- a/config/splat.ov_SC04_004.yaml +++ b/config/splat.ov_SC04_004.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_004_jr_80159C84] - [0x32270, c, ov_SC04_004_jr_8015A3C8] - [0x32cd4, c, ov_SC04_004_jr_8015AE2C] + - [0x341d4, c, ov_SC04_004_jr_8015C32C] - [0x42a14, c, ov_SC04_004_jr_8016AB6C] - [0x4b364, c, ov_SC04_004_jr_801734BC] - [0x50be8, c, ov_SC04_004_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x89da4, data, tail8] - [0x89da8, .rodata, ov_SC04_004_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x89dc4, data, tail9] + - [0x89de8, .rodata, ov_SC04_004_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x89e04, data, tail10] - [0x89e1c, .rodata, ov_SC04_004_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x89e3c, data, tail10] + - [0x89e3c, data, tail11] - [0x89ebc, .rodata, ov_SC04_004_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x89ed0, data, tail11] + - [0x89ed0, data, tail12] - [0x8a078, .rodata, ov_SC04_004_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8a1f0, data, tail12] + - [0x8a1f0, data, tail13] - [0x8a280, .rodata, ov_SC04_004_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8a30c, data, tail13] + - [0x8a30c, data, tail14] - [0x8BAFC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8BAFF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_005.yaml b/config/splat.ov_SC04_005.yaml index 415f9c954..4ed65db05 100644 --- a/config/splat.ov_SC04_005.yaml +++ b/config/splat.ov_SC04_005.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_005_jr_80159C84] - [0x32270, c, ov_SC04_005_jr_8015A3C8] - [0x32cd4, c, ov_SC04_005_jr_8015AE2C] + - [0x341d4, c, ov_SC04_005_jr_8015C32C] - [0x42a14, c, ov_SC04_005_jr_8016AB6C] - [0x4b364, c, ov_SC04_005_jr_801734BC] - [0x50be8, c, ov_SC04_005_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x97f68, data, tail8] - [0x97f6c, .rodata, ov_SC04_005_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x97f88, data, tail9] + - [0x97fac, .rodata, ov_SC04_005_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x97fc8, data, tail10] - [0x97fe0, .rodata, ov_SC04_005_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x98000, data, tail10] + - [0x98000, data, tail11] - [0x98080, .rodata, ov_SC04_005_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x98094, data, tail11] + - [0x98094, data, tail12] - [0x9823c, .rodata, ov_SC04_005_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x983b4, data, tail12] + - [0x983b4, data, tail13] - [0x98444, .rodata, ov_SC04_005_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x984d0, data, tail13] + - [0x984d0, data, tail14] - [0x984e8, .rodata, ov_SC04_005_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x98508, data, tail14] + - [0x98508, data, tail15] - [0x9A1D4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9A1D7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_006.yaml b/config/splat.ov_SC04_006.yaml index f7ca5f791..abb0ebac8 100644 --- a/config/splat.ov_SC04_006.yaml +++ b/config/splat.ov_SC04_006.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_006_jr_80159C84] - [0x32270, c, ov_SC04_006_jr_8015A3C8] - [0x32cd4, c, ov_SC04_006_jr_8015AE2C] + - [0x341d4, c, ov_SC04_006_jr_8015C32C] - [0x42a14, c, ov_SC04_006_jr_8016AB6C] - [0x4b364, c, ov_SC04_006_jr_801734BC] - [0x50be8, c, ov_SC04_006_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x74210, data, tail8] - [0x74214, .rodata, ov_SC04_006_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x74230, data, tail9] + - [0x74254, .rodata, ov_SC04_006_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x74270, data, tail10] - [0x74288, .rodata, ov_SC04_006_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x742a8, data, tail10] + - [0x742a8, data, tail11] - [0x74328, .rodata, ov_SC04_006_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7433c, data, tail11] + - [0x7433c, data, tail12] - [0x744e4, .rodata, ov_SC04_006_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7465c, data, tail12] + - [0x7465c, data, tail13] - [0x746ec, .rodata, ov_SC04_006_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x74778, data, tail13] + - [0x74778, data, tail14] - [0x74790, .rodata, ov_SC04_006_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x747b0, data, tail14] + - [0x747b0, data, tail15] - [0x75C74, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x75C77] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_007.yaml b/config/splat.ov_SC04_007.yaml index 3a21ef394..b08255130 100644 --- a/config/splat.ov_SC04_007.yaml +++ b/config/splat.ov_SC04_007.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_007_jr_80159C84] - [0x32270, c, ov_SC04_007_jr_8015A3C8] - [0x32cd4, c, ov_SC04_007_jr_8015AE2C] + - [0x341d4, c, ov_SC04_007_jr_8015C32C] - [0x42a14, c, ov_SC04_007_jr_8016AB6C] - [0x4b364, c, ov_SC04_007_jr_801734BC] - [0x50be8, c, ov_SC04_007_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8b7cc, data, tail8] - [0x8b7d0, .rodata, ov_SC04_007_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8b7ec, data, tail9] + - [0x8b810, .rodata, ov_SC04_007_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8b82c, data, tail10] - [0x8b844, .rodata, ov_SC04_007_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8b864, data, tail10] + - [0x8b864, data, tail11] - [0x8b8e4, .rodata, ov_SC04_007_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8b8f8, data, tail11] + - [0x8b8f8, data, tail12] - [0x8baa0, .rodata, ov_SC04_007_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8bc18, data, tail12] + - [0x8bc18, data, tail13] - [0x8bca8, .rodata, ov_SC04_007_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8bd34, data, tail13] + - [0x8bd34, data, tail14] - [0x8bd4c, .rodata, ov_SC04_007_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8bd6c, data, tail14] + - [0x8bd6c, data, tail15] - [0x8DA34, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8DA37] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_008.yaml b/config/splat.ov_SC04_008.yaml index ffccea69c..06ec879a9 100644 --- a/config/splat.ov_SC04_008.yaml +++ b/config/splat.ov_SC04_008.yaml @@ -103,6 +103,7 @@ segments: - [0x2c2f4, c, ov_SC04_008_jr_8015444C] - [0x31b2c, c, ov_SC04_008_jr_80159C84] - [0x32cd4, c, ov_SC04_008_jr_8015AE2C] + - [0x341d4, c, ov_SC04_008_jr_8015C32C] - [0x42a14, c, ov_SC04_008_jr_8016AB6C] - [0x4b364, c, ov_SC04_008_jr_801734BC] - [0x50be8, c, ov_SC04_008_jr_80178D40] @@ -122,14 +123,16 @@ segments: - [0x68494, data, tail7] - [0x684b8, .rodata, ov_SC04_008_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x684d4, data, tail8] + - [0x684f8, .rodata, ov_SC04_008_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x68514, data, tail9] - [0x6852c, .rodata, ov_SC04_008_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6854c, data, tail9] + - [0x6854c, data, tail10] - [0x685cc, .rodata, ov_SC04_008_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x685e0, data, tail10] + - [0x685e0, data, tail11] - [0x68788, .rodata, ov_SC04_008_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x68900, data, tail11] + - [0x68900, data, tail12] - [0x68990, .rodata, ov_SC04_008_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x68a1c, data, tail12] + - [0x68a1c, data, tail13] - [0x6B364, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6B367] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_009.yaml b/config/splat.ov_SC04_009.yaml index 0810645d1..fdaa8b249 100644 --- a/config/splat.ov_SC04_009.yaml +++ b/config/splat.ov_SC04_009.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_009_jr_80159C84] - [0x32270, c, ov_SC04_009_jr_8015A3C8] - [0x32cd4, c, ov_SC04_009_jr_8015AE2C] + - [0x341d4, c, ov_SC04_009_jr_8015C32C] - [0x42a14, c, ov_SC04_009_jr_8016AB6C] - [0x4b364, c, ov_SC04_009_jr_801734BC] - [0x50be8, c, ov_SC04_009_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x6e6c8, data, tail8] - [0x6e6cc, .rodata, ov_SC04_009_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x6e6e8, data, tail9] + - [0x6e70c, .rodata, ov_SC04_009_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6e728, data, tail10] - [0x6e740, .rodata, ov_SC04_009_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6e760, data, tail10] + - [0x6e760, data, tail11] - [0x6e7e0, .rodata, ov_SC04_009_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6e7f4, data, tail11] + - [0x6e7f4, data, tail12] - [0x6e99c, .rodata, ov_SC04_009_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6eb14, data, tail12] + - [0x6eb14, data, tail13] - [0x6eba4, .rodata, ov_SC04_009_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6ec30, data, tail13] + - [0x6ec30, data, tail14] - [0x6ec48, .rodata, ov_SC04_009_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6ec68, data, tail14] + - [0x6ec68, data, tail15] - [0x70114, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x70117] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_010.yaml b/config/splat.ov_SC04_010.yaml index fe291c729..a721df499 100644 --- a/config/splat.ov_SC04_010.yaml +++ b/config/splat.ov_SC04_010.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_010_jr_80159C84] - [0x32270, c, ov_SC04_010_jr_8015A3C8] - [0x32cd4, c, ov_SC04_010_jr_8015AE2C] + - [0x341d4, c, ov_SC04_010_jr_8015C32C] - [0x42a14, c, ov_SC04_010_jr_8016AB6C] - [0x4b364, c, ov_SC04_010_jr_801734BC] - [0x50be8, c, ov_SC04_010_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x65b54, data, tail8] - [0x65b58, .rodata, ov_SC04_010_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x65b74, data, tail9] + - [0x65b98, .rodata, ov_SC04_010_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x65bb4, data, tail10] - [0x65bcc, .rodata, ov_SC04_010_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x65bec, data, tail10] + - [0x65bec, data, tail11] - [0x65c6c, .rodata, ov_SC04_010_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x65c80, data, tail11] + - [0x65c80, data, tail12] - [0x65e28, .rodata, ov_SC04_010_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x65fa0, data, tail12] + - [0x65fa0, data, tail13] - [0x66030, .rodata, ov_SC04_010_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x660bc, data, tail13] + - [0x660bc, data, tail14] - [0x660d4, .rodata, ov_SC04_010_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x660f4, data, tail14] + - [0x660f4, data, tail15] - [0x675EC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x675EF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_011.yaml b/config/splat.ov_SC04_011.yaml index f1f426b66..0dddad143 100644 --- a/config/splat.ov_SC04_011.yaml +++ b/config/splat.ov_SC04_011.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_011_jr_80159C84] - [0x32270, c, ov_SC04_011_jr_8015A3C8] - [0x32cd4, c, ov_SC04_011_jr_8015AE2C] + - [0x341d4, c, ov_SC04_011_jr_8015C32C] - [0x42a14, c, ov_SC04_011_jr_8016AB6C] - [0x4b364, c, ov_SC04_011_jr_801734BC] - [0x50be8, c, ov_SC04_011_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xc50f0, data, tail8] - [0xc50f4, .rodata, ov_SC04_011_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc5110, data, tail9] + - [0xc5134, .rodata, ov_SC04_011_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc5150, data, tail10] - [0xc5168, .rodata, ov_SC04_011_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc5188, data, tail10] + - [0xc5188, data, tail11] - [0xc5208, .rodata, ov_SC04_011_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc521c, data, tail11] + - [0xc521c, data, tail12] - [0xc53c4, .rodata, ov_SC04_011_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc553c, data, tail12] + - [0xc553c, data, tail13] - [0xc55cc, .rodata, ov_SC04_011_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc5658, data, tail13] + - [0xc5658, data, tail14] - [0xc57a8, .rodata, ov_SC04_011_jr_8017D494] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc57c8, data, tail14] + - [0xc57c8, data, tail15] - [0xC9554, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC9557] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_012.yaml b/config/splat.ov_SC04_012.yaml index 7a059797a..678730020 100644 --- a/config/splat.ov_SC04_012.yaml +++ b/config/splat.ov_SC04_012.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_012_jr_80159C84] - [0x32270, c, ov_SC04_012_jr_8015A3C8] - [0x32cd4, c, ov_SC04_012_jr_8015AE2C] + - [0x341d4, c, ov_SC04_012_jr_8015C32C] - [0x42a14, c, ov_SC04_012_jr_8016AB6C] - [0x4b364, c, ov_SC04_012_jr_801734BC] - [0x50be8, c, ov_SC04_012_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x68234, data, tail8] - [0x68238, .rodata, ov_SC04_012_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x68254, data, tail9] + - [0x68278, .rodata, ov_SC04_012_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x68294, data, tail10] - [0x682ac, .rodata, ov_SC04_012_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x682cc, data, tail10] + - [0x682cc, data, tail11] - [0x6834c, .rodata, ov_SC04_012_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x68360, data, tail11] + - [0x68360, data, tail12] - [0x68508, .rodata, ov_SC04_012_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x68680, data, tail12] + - [0x68680, data, tail13] - [0x68710, .rodata, ov_SC04_012_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6879c, data, tail13] + - [0x6879c, data, tail14] - [0x6B0E4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6B0E7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_015.yaml b/config/splat.ov_SC04_015.yaml index 9590710b1..526669fd7 100644 --- a/config/splat.ov_SC04_015.yaml +++ b/config/splat.ov_SC04_015.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_015_jr_80159C84] - [0x32270, c, ov_SC04_015_jr_8015A3C8] - [0x32cd4, c, ov_SC04_015_jr_8015AE2C] + - [0x341d4, c, ov_SC04_015_jr_8015C32C] - [0x42a14, c, ov_SC04_015_jr_8016AB6C] - [0x4b364, c, ov_SC04_015_jr_801734BC] - [0x50be8, c, ov_SC04_015_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x9eecc, data, tail8] - [0x9eed0, .rodata, ov_SC04_015_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9eeec, data, tail9] + - [0x9ef10, .rodata, ov_SC04_015_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9ef2c, data, tail10] - [0x9ef44, .rodata, ov_SC04_015_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9ef64, data, tail10] + - [0x9ef64, data, tail11] - [0x9efe4, .rodata, ov_SC04_015_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9eff8, data, tail11] + - [0x9eff8, data, tail12] - [0x9f1a0, .rodata, ov_SC04_015_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9f318, data, tail12] + - [0x9f318, data, tail13] - [0x9f3a8, .rodata, ov_SC04_015_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9f434, data, tail13] + - [0x9f434, data, tail14] - [0xA1284, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xA1287] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_016.yaml b/config/splat.ov_SC04_016.yaml index 0a5bf204c..988f59711 100644 --- a/config/splat.ov_SC04_016.yaml +++ b/config/splat.ov_SC04_016.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_016_jr_80159C84] - [0x32270, c, ov_SC04_016_jr_8015A3C8] - [0x32cd4, c, ov_SC04_016_jr_8015AE2C] + - [0x341d4, c, ov_SC04_016_jr_8015C32C] - [0x42a14, c, ov_SC04_016_jr_8016AB6C] - [0x4b364, c, ov_SC04_016_jr_801734BC] - [0x50be8, c, ov_SC04_016_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x7d084, data, tail8] - [0x7d088, .rodata, ov_SC04_016_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x7d0a4, data, tail9] + - [0x7d0c8, .rodata, ov_SC04_016_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x7d0e4, data, tail10] - [0x7d0fc, .rodata, ov_SC04_016_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7d11c, data, tail10] + - [0x7d11c, data, tail11] - [0x7d19c, .rodata, ov_SC04_016_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7d1b0, data, tail11] + - [0x7d1b0, data, tail12] - [0x7d358, .rodata, ov_SC04_016_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7d4d0, data, tail12] + - [0x7d4d0, data, tail13] - [0x7d560, .rodata, ov_SC04_016_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7d5ec, data, tail13] + - [0x7d5ec, data, tail14] - [0x7d604, .rodata, ov_SC04_016_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7d624, data, tail14] + - [0x7d624, data, tail15] - [0x84184, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x84187] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_018.yaml b/config/splat.ov_SC04_018.yaml index 69b8f519b..adf60f62f 100644 --- a/config/splat.ov_SC04_018.yaml +++ b/config/splat.ov_SC04_018.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_018_jr_80159C84] - [0x32270, c, ov_SC04_018_jr_8015A3C8] - [0x32cd4, c, ov_SC04_018_jr_8015AE2C] + - [0x341d4, c, ov_SC04_018_jr_8015C32C] - [0x42a14, c, ov_SC04_018_jr_8016AB6C] - [0x4b364, c, ov_SC04_018_jr_801734BC] - [0x50be8, c, ov_SC04_018_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xbce9c, data, tail8] - [0xbcea0, .rodata, ov_SC04_018_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xbcebc, data, tail9] + - [0xbcee0, .rodata, ov_SC04_018_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xbcefc, data, tail10] - [0xbcf14, .rodata, ov_SC04_018_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbcf34, data, tail10] + - [0xbcf34, data, tail11] - [0xbcfb4, .rodata, ov_SC04_018_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbcfc8, data, tail11] + - [0xbcfc8, data, tail12] - [0xbd170, .rodata, ov_SC04_018_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbd2e8, data, tail12] + - [0xbd2e8, data, tail13] - [0xbd378, .rodata, ov_SC04_018_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbd404, data, tail13] + - [0xbd404, data, tail14] - [0xBF9CC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xBF9CF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_019.yaml b/config/splat.ov_SC04_019.yaml index 278b27da3..3c27e6959 100644 --- a/config/splat.ov_SC04_019.yaml +++ b/config/splat.ov_SC04_019.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_019_jr_80159C84] - [0x32270, c, ov_SC04_019_jr_8015A3C8] - [0x32cd4, c, ov_SC04_019_jr_8015AE2C] + - [0x341d4, c, ov_SC04_019_jr_8015C32C] - [0x42a14, c, ov_SC04_019_jr_8016AB6C] - [0x4b364, c, ov_SC04_019_jr_801734BC] - [0x50be8, c, ov_SC04_019_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xbce9c, data, tail8] - [0xbcea0, .rodata, ov_SC04_019_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xbcebc, data, tail9] + - [0xbcee0, .rodata, ov_SC04_019_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xbcefc, data, tail10] - [0xbcf14, .rodata, ov_SC04_019_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbcf34, data, tail10] + - [0xbcf34, data, tail11] - [0xbcfb4, .rodata, ov_SC04_019_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbcfc8, data, tail11] + - [0xbcfc8, data, tail12] - [0xbd170, .rodata, ov_SC04_019_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbd2e8, data, tail12] + - [0xbd2e8, data, tail13] - [0xbd378, .rodata, ov_SC04_019_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbd404, data, tail13] + - [0xbd404, data, tail14] - [0xBF9CC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xBF9CF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_020.yaml b/config/splat.ov_SC04_020.yaml index 1da309558..ebbd5a7a7 100644 --- a/config/splat.ov_SC04_020.yaml +++ b/config/splat.ov_SC04_020.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_020_jr_80159C84] - [0x32270, c, ov_SC04_020_jr_8015A3C8] - [0x32cd4, c, ov_SC04_020_jr_8015AE2C] + - [0x341d4, c, ov_SC04_020_jr_8015C32C] - [0x42a14, c, ov_SC04_020_jr_8016AB6C] - [0x4b364, c, ov_SC04_020_jr_801734BC] - [0x50be8, c, ov_SC04_020_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x928c4, data, tail8] - [0x928c8, .rodata, ov_SC04_020_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x928e4, data, tail9] + - [0x92908, .rodata, ov_SC04_020_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x92924, data, tail10] - [0x9293c, .rodata, ov_SC04_020_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9295c, data, tail10] + - [0x9295c, data, tail11] - [0x929dc, .rodata, ov_SC04_020_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x929f0, data, tail11] + - [0x929f0, data, tail12] - [0x92b98, .rodata, ov_SC04_020_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x92d10, data, tail12] + - [0x92d10, data, tail13] - [0x92da0, .rodata, ov_SC04_020_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x92e2c, data, tail13] + - [0x92e2c, data, tail14] - [0x92e44, .rodata, ov_SC04_020_jr_8017D604] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x92e64, data, tail14] + - [0x92e64, data, tail15] - [0x94654, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x94657] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC04_021.yaml b/config/splat.ov_SC04_021.yaml index 5a68969ec..0e036b567 100644 --- a/config/splat.ov_SC04_021.yaml +++ b/config/splat.ov_SC04_021.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC04_021_jr_80159C84] - [0x32270, c, ov_SC04_021_jr_8015A3C8] - [0x32cd4, c, ov_SC04_021_jr_8015AE2C] + - [0x341d4, c, ov_SC04_021_jr_8015C32C] - [0x42a14, c, ov_SC04_021_jr_8016AB6C] - [0x4b364, c, ov_SC04_021_jr_801734BC] - [0x50be8, c, ov_SC04_021_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x65f60, data, tail8] - [0x65f64, .rodata, ov_SC04_021_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x65f80, data, tail9] + - [0x65fa4, .rodata, ov_SC04_021_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x65fc0, data, tail10] - [0x65fd8, .rodata, ov_SC04_021_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x65ff8, data, tail10] + - [0x65ff8, data, tail11] - [0x66078, .rodata, ov_SC04_021_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6608c, data, tail11] + - [0x6608c, data, tail12] - [0x66234, .rodata, ov_SC04_021_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x663ac, data, tail12] + - [0x663ac, data, tail13] - [0x6643c, .rodata, ov_SC04_021_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x664c8, data, tail13] + - [0x664c8, data, tail14] - [0x66500, .rodata, ov_SC04_021_jr_8017D5C0] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66520, data, tail14] + - [0x66520, data, tail15] - [0x679D4, bin, trailing] # final 1 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x679D5] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_000.yaml b/config/splat.ov_SC05_000.yaml index 59d620710..c51700b08 100644 --- a/config/splat.ov_SC05_000.yaml +++ b/config/splat.ov_SC05_000.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_000_jr_80159C84] - [0x32270, c, ov_SC05_000_jr_8015A3C8] - [0x32cd4, c, ov_SC05_000_jr_8015AE2C] + - [0x341d4, c, ov_SC05_000_jr_8015C32C] - [0x42a14, c, ov_SC05_000_jr_8016AB6C] - [0x4b364, c, ov_SC05_000_jr_801734BC] - [0x50be8, c, ov_SC05_000_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x710b0, data, tail8] - [0x710b4, .rodata, ov_SC05_000_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x710d0, data, tail9] + - [0x710f4, .rodata, ov_SC05_000_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x71110, data, tail10] - [0x71128, .rodata, ov_SC05_000_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x71148, data, tail10] + - [0x71148, data, tail11] - [0x711c8, .rodata, ov_SC05_000_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x711dc, data, tail11] + - [0x711dc, data, tail12] - [0x71384, .rodata, ov_SC05_000_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x714fc, data, tail12] + - [0x714fc, data, tail13] - [0x7158c, .rodata, ov_SC05_000_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x71618, data, tail13] + - [0x71618, data, tail14] - [0x71630, .rodata, ov_SC05_000_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x71650, data, tail14] + - [0x71650, data, tail15] - [0x72AFC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x72AFF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_001.yaml b/config/splat.ov_SC05_001.yaml index 9c3435d71..506cc6d13 100644 --- a/config/splat.ov_SC05_001.yaml +++ b/config/splat.ov_SC05_001.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_001_jr_80159C84] - [0x32270, c, ov_SC05_001_jr_8015A3C8] - [0x32cd4, c, ov_SC05_001_jr_8015AE2C] + - [0x341d4, c, ov_SC05_001_jr_8015C32C] - [0x42a14, c, ov_SC05_001_jr_8016AB6C] - [0x4b364, c, ov_SC05_001_jr_801734BC] - [0x50be8, c, ov_SC05_001_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8c064, data, tail8] - [0x8c068, .rodata, ov_SC05_001_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8c084, data, tail9] + - [0x8c0a8, .rodata, ov_SC05_001_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8c0c4, data, tail10] - [0x8c0dc, .rodata, ov_SC05_001_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8c0fc, data, tail10] + - [0x8c0fc, data, tail11] - [0x8c17c, .rodata, ov_SC05_001_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8c190, data, tail11] + - [0x8c190, data, tail12] - [0x8c338, .rodata, ov_SC05_001_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8c4b0, data, tail12] + - [0x8c4b0, data, tail13] - [0x8c540, .rodata, ov_SC05_001_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8c5cc, data, tail13] + - [0x8c5cc, data, tail14] - [0x8c5e4, .rodata, ov_SC05_001_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8c604, data, tail14] + - [0x8c604, data, tail15] - [0x8DEAC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8DEAF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_002.yaml b/config/splat.ov_SC05_002.yaml index fc716468a..63af860f4 100644 --- a/config/splat.ov_SC05_002.yaml +++ b/config/splat.ov_SC05_002.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_002_jr_80159C84] - [0x32270, c, ov_SC05_002_jr_8015A3C8] - [0x32cd4, c, ov_SC05_002_jr_8015AE2C] + - [0x341d4, c, ov_SC05_002_jr_8015C32C] - [0x42a14, c, ov_SC05_002_jr_8016AB6C] - [0x4b364, c, ov_SC05_002_jr_801734BC] - [0x50be8, c, ov_SC05_002_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x76410, data, tail8] - [0x76414, .rodata, ov_SC05_002_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x76430, data, tail9] + - [0x76454, .rodata, ov_SC05_002_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x76470, data, tail10] - [0x76488, .rodata, ov_SC05_002_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x764a8, data, tail10] + - [0x764a8, data, tail11] - [0x76528, .rodata, ov_SC05_002_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7653c, data, tail11] + - [0x7653c, data, tail12] - [0x766e4, .rodata, ov_SC05_002_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7685c, data, tail12] + - [0x7685c, data, tail13] - [0x768ec, .rodata, ov_SC05_002_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x76978, data, tail13] + - [0x76978, data, tail14] - [0x76990, .rodata, ov_SC05_002_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x769b0, data, tail14] + - [0x769b0, data, tail15] - [0x77E64, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x77E67] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_003.yaml b/config/splat.ov_SC05_003.yaml index 53209dede..b02fa6b61 100644 --- a/config/splat.ov_SC05_003.yaml +++ b/config/splat.ov_SC05_003.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_003_jr_80159C84] - [0x32270, c, ov_SC05_003_jr_8015A3C8] - [0x32cd4, c, ov_SC05_003_jr_8015AE2C] + - [0x341d4, c, ov_SC05_003_jr_8015C32C] - [0x42a14, c, ov_SC05_003_jr_8016AB6C] - [0x4b364, c, ov_SC05_003_jr_801734BC] - [0x50be8, c, ov_SC05_003_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x82f0c, data, tail8] - [0x82f10, .rodata, ov_SC05_003_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x82f2c, data, tail9] + - [0x82f50, .rodata, ov_SC05_003_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x82f6c, data, tail10] - [0x82f84, .rodata, ov_SC05_003_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x82fa4, data, tail10] + - [0x82fa4, data, tail11] - [0x83024, .rodata, ov_SC05_003_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x83038, data, tail11] + - [0x83038, data, tail12] - [0x831e0, .rodata, ov_SC05_003_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x83358, data, tail12] + - [0x83358, data, tail13] - [0x833e8, .rodata, ov_SC05_003_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x83474, data, tail13] + - [0x83474, data, tail14] - [0x8348c, .rodata, ov_SC05_003_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x834ac, data, tail14] + - [0x834ac, data, tail15] - [0x84974, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x84977] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_004.yaml b/config/splat.ov_SC05_004.yaml index 61c78adb3..7c1579c99 100644 --- a/config/splat.ov_SC05_004.yaml +++ b/config/splat.ov_SC05_004.yaml @@ -103,6 +103,7 @@ segments: - [0x31b2c, c, ov_SC05_004_jr_80159C84] - [0x32270, c, ov_SC05_004_jr_8015A3C8] - [0x32cd4, c, ov_SC05_004_jr_8015AE2C] + - [0x341d4, c, ov_SC05_004_jr_8015C32C] - [0x42a14, c, ov_SC05_004_jr_8016AB6C] - [0x4b364, c, ov_SC05_004_jr_801734BC] - [0x50be8, c, ov_SC05_004_jr_80178D40] @@ -123,16 +124,18 @@ segments: - [0x75500, data, tail7] - [0x75504, .rodata, ov_SC05_004_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x75520, data, tail8] + - [0x75544, .rodata, ov_SC05_004_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x75560, data, tail9] - [0x75578, .rodata, ov_SC05_004_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x75598, data, tail9] + - [0x75598, data, tail10] - [0x75618, .rodata, ov_SC05_004_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7562c, data, tail10] + - [0x7562c, data, tail11] - [0x757d4, .rodata, ov_SC05_004_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7594c, data, tail11] + - [0x7594c, data, tail12] - [0x759dc, .rodata, ov_SC05_004_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x75a68, data, tail12] + - [0x75a68, data, tail13] - [0x75a80, .rodata, ov_SC05_004_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x75aa0, data, tail13] + - [0x75aa0, data, tail14] - [0x771CC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x771CF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_005.yaml b/config/splat.ov_SC05_005.yaml index 9594f7378..c6fd2bd3a 100644 --- a/config/splat.ov_SC05_005.yaml +++ b/config/splat.ov_SC05_005.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_005_jr_80159C84] - [0x32270, c, ov_SC05_005_jr_8015A3C8] - [0x32cd4, c, ov_SC05_005_jr_8015AE2C] + - [0x341d4, c, ov_SC05_005_jr_8015C32C] - [0x42a14, c, ov_SC05_005_jr_8016AB6C] - [0x4b364, c, ov_SC05_005_jr_801734BC] - [0x50be8, c, ov_SC05_005_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x881e8, data, tail8] - [0x881ec, .rodata, ov_SC05_005_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x88208, data, tail9] + - [0x8822c, .rodata, ov_SC05_005_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x88248, data, tail10] - [0x88260, .rodata, ov_SC05_005_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x88280, data, tail10] + - [0x88280, data, tail11] - [0x88300, .rodata, ov_SC05_005_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x88314, data, tail11] + - [0x88314, data, tail12] - [0x884bc, .rodata, ov_SC05_005_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x88634, data, tail12] + - [0x88634, data, tail13] - [0x886c4, .rodata, ov_SC05_005_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x88750, data, tail13] + - [0x88750, data, tail14] - [0x88768, .rodata, ov_SC05_005_jr_8017D898] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x88788, data, tail14] + - [0x88788, data, tail15] - [0x89ED4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x89ED7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_006.yaml b/config/splat.ov_SC05_006.yaml index d8f0ff9c8..6eda72cd9 100644 --- a/config/splat.ov_SC05_006.yaml +++ b/config/splat.ov_SC05_006.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_006_jr_80159C84] - [0x32270, c, ov_SC05_006_jr_8015A3C8] - [0x32cd4, c, ov_SC05_006_jr_8015AE2C] + - [0x341d4, c, ov_SC05_006_jr_8015C32C] - [0x42a14, c, ov_SC05_006_jr_8016AB6C] - [0x4b364, c, ov_SC05_006_jr_801734BC] - [0x50be8, c, ov_SC05_006_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x66338, data, tail8] - [0x6633c, .rodata, ov_SC05_006_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x66358, data, tail9] + - [0x6637c, .rodata, ov_SC05_006_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x66398, data, tail10] - [0x663b0, .rodata, ov_SC05_006_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x663d0, data, tail10] + - [0x663d0, data, tail11] - [0x66450, .rodata, ov_SC05_006_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66464, data, tail11] + - [0x66464, data, tail12] - [0x6660c, .rodata, ov_SC05_006_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66784, data, tail12] + - [0x66784, data, tail13] - [0x66814, .rodata, ov_SC05_006_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x668a0, data, tail13] + - [0x668a0, data, tail14] - [0x668b8, .rodata, ov_SC05_006_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x668d8, data, tail14] + - [0x668d8, data, tail15] - [0x68004, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x68007] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_007.yaml b/config/splat.ov_SC05_007.yaml index ae126929d..0f7747253 100644 --- a/config/splat.ov_SC05_007.yaml +++ b/config/splat.ov_SC05_007.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_007_jr_80159C84] - [0x32270, c, ov_SC05_007_jr_8015A3C8] - [0x32cd4, c, ov_SC05_007_jr_8015AE2C] + - [0x341d4, c, ov_SC05_007_jr_8015C32C] - [0x42a14, c, ov_SC05_007_jr_8016AB6C] - [0x4b364, c, ov_SC05_007_jr_801734BC] - [0x50be8, c, ov_SC05_007_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x73310, data, tail8] - [0x73314, .rodata, ov_SC05_007_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x73330, data, tail9] + - [0x73354, .rodata, ov_SC05_007_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x73370, data, tail10] - [0x73388, .rodata, ov_SC05_007_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x733a8, data, tail10] + - [0x733a8, data, tail11] - [0x73428, .rodata, ov_SC05_007_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7343c, data, tail11] + - [0x7343c, data, tail12] - [0x735e4, .rodata, ov_SC05_007_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7375c, data, tail12] + - [0x7375c, data, tail13] - [0x737ec, .rodata, ov_SC05_007_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x73878, data, tail13] + - [0x73878, data, tail14] - [0x73890, .rodata, ov_SC05_007_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x738b0, data, tail14] + - [0x738b0, data, tail15] - [0x74DA4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x74DA7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_008.yaml b/config/splat.ov_SC05_008.yaml index 7208355f1..edfbce5b4 100644 --- a/config/splat.ov_SC05_008.yaml +++ b/config/splat.ov_SC05_008.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_008_jr_80159C84] - [0x32270, c, ov_SC05_008_jr_8015A3C8] - [0x32cd4, c, ov_SC05_008_jr_8015AE2C] + - [0x341d4, c, ov_SC05_008_jr_8015C32C] - [0x42a14, c, ov_SC05_008_jr_8016AB6C] - [0x4b364, c, ov_SC05_008_jr_801734BC] - [0x50be8, c, ov_SC05_008_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0x77644, data, tail8] - [0x77648, .rodata, ov_SC05_008_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x77664, data, tail9] + - [0x77688, .rodata, ov_SC05_008_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x776a4, data, tail10] - [0x776bc, .rodata, ov_SC05_008_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x776dc, data, tail10] + - [0x776dc, data, tail11] - [0x7775c, .rodata, ov_SC05_008_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77770, data, tail11] + - [0x77770, data, tail12] - [0x77918, .rodata, ov_SC05_008_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77a90, data, tail12] + - [0x77a90, data, tail13] - [0x77b20, .rodata, ov_SC05_008_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77bac, data, tail13] + - [0x77bac, data, tail14] - [0x79190, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x79193] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_009.yaml b/config/splat.ov_SC05_009.yaml index 1a0a1f5ed..5a7dcf453 100644 --- a/config/splat.ov_SC05_009.yaml +++ b/config/splat.ov_SC05_009.yaml @@ -103,6 +103,7 @@ segments: - [0x2c2f4, c, ov_SC05_009_jr_8015444C] - [0x31b2c, c, ov_SC05_009_jr_80159C84] - [0x32cd4, c, ov_SC05_009_jr_8015AE2C] + - [0x341d4, c, ov_SC05_009_jr_8015C32C] - [0x42a14, c, ov_SC05_009_jr_8016AB6C] - [0x4b364, c, ov_SC05_009_jr_801734BC] - [0x50be8, c, ov_SC05_009_jr_80178D40] @@ -123,16 +124,18 @@ segments: - [0x6d038, data, tail7] - [0x6d05c, .rodata, ov_SC05_009_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x6d078, data, tail8] + - [0x6d09c, .rodata, ov_SC05_009_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6d0b8, data, tail9] - [0x6d0d0, .rodata, ov_SC05_009_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6d0f0, data, tail9] + - [0x6d0f0, data, tail10] - [0x6d170, .rodata, ov_SC05_009_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6d184, data, tail10] + - [0x6d184, data, tail11] - [0x6d32c, .rodata, ov_SC05_009_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6d4a4, data, tail11] + - [0x6d4a4, data, tail12] - [0x6d534, .rodata, ov_SC05_009_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6d5c0, data, tail12] + - [0x6d5c0, data, tail13] - [0x6d5d8, .rodata, ov_SC05_009_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6d5f8, data, tail13] + - [0x6d5f8, data, tail14] - [0x6EAEC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6EAEF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_010.yaml b/config/splat.ov_SC05_010.yaml index 5c124fdd0..031db292e 100644 --- a/config/splat.ov_SC05_010.yaml +++ b/config/splat.ov_SC05_010.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_010_jr_80159C84] - [0x32270, c, ov_SC05_010_jr_8015A3C8] - [0x32cd4, c, ov_SC05_010_jr_8015AE2C] + - [0x341d4, c, ov_SC05_010_jr_8015C32C] - [0x42a14, c, ov_SC05_010_jr_8016AB6C] - [0x4b364, c, ov_SC05_010_jr_801734BC] - [0x50be8, c, ov_SC05_010_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x9d28c, data, tail8] - [0x9d290, .rodata, ov_SC05_010_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x9d2ac, data, tail9] + - [0x9d2d0, .rodata, ov_SC05_010_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x9d2ec, data, tail10] - [0x9d304, .rodata, ov_SC05_010_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9d324, data, tail10] + - [0x9d324, data, tail11] - [0x9d3a4, .rodata, ov_SC05_010_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9d3b8, data, tail11] + - [0x9d3b8, data, tail12] - [0x9d560, .rodata, ov_SC05_010_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9d6d8, data, tail12] + - [0x9d6d8, data, tail13] - [0x9d768, .rodata, ov_SC05_010_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9d7f4, data, tail13] + - [0x9d7f4, data, tail14] - [0x9d944, .rodata, ov_SC05_010_jr_8017C8D0] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x9d964, data, tail14] + - [0x9d964, data, tail15] - [0x9FED4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x9FED7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_011.yaml b/config/splat.ov_SC05_011.yaml index 571ed171f..3563e718b 100644 --- a/config/splat.ov_SC05_011.yaml +++ b/config/splat.ov_SC05_011.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_011_jr_80159C84] - [0x32270, c, ov_SC05_011_jr_8015A3C8] - [0x32cd4, c, ov_SC05_011_jr_8015AE2C] + - [0x341d4, c, ov_SC05_011_jr_8015C32C] - [0x42a14, c, ov_SC05_011_jr_8016AB6C] - [0x4b364, c, ov_SC05_011_jr_801734BC] - [0x50be8, c, ov_SC05_011_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x735f0, data, tail8] - [0x735f4, .rodata, ov_SC05_011_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x73610, data, tail9] + - [0x73634, .rodata, ov_SC05_011_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x73650, data, tail10] - [0x73668, .rodata, ov_SC05_011_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x73688, data, tail10] + - [0x73688, data, tail11] - [0x73708, .rodata, ov_SC05_011_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7371c, data, tail11] + - [0x7371c, data, tail12] - [0x738c4, .rodata, ov_SC05_011_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x73a3c, data, tail12] + - [0x73a3c, data, tail13] - [0x73acc, .rodata, ov_SC05_011_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x73b58, data, tail13] + - [0x73b58, data, tail14] - [0x73b70, .rodata, ov_SC05_011_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x73b90, data, tail14] + - [0x73b90, data, tail15] - [0x75084, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x75087] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_017.yaml b/config/splat.ov_SC05_017.yaml index 430d27664..e9c37e11f 100644 --- a/config/splat.ov_SC05_017.yaml +++ b/config/splat.ov_SC05_017.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_017_jr_80159C84] - [0x32270, c, ov_SC05_017_jr_8015A3C8] - [0x32cd4, c, ov_SC05_017_jr_8015AE2C] + - [0x341d4, c, ov_SC05_017_jr_8015C32C] - [0x42a14, c, ov_SC05_017_jr_8016AB6C] - [0x4b364, c, ov_SC05_017_jr_801734BC] - [0x50be8, c, ov_SC05_017_jr_80178D40] @@ -125,14 +126,16 @@ segments: - [0xc2cd8, data, tail8] - [0xc2cdc, .rodata, ov_SC05_017_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xc2cf8, data, tail9] + - [0xc2d1c, .rodata, ov_SC05_017_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xc2d38, data, tail10] - [0xc2d50, .rodata, ov_SC05_017_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc2d70, data, tail10] + - [0xc2d70, data, tail11] - [0xc2df0, .rodata, ov_SC05_017_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc2e04, data, tail11] + - [0xc2e04, data, tail12] - [0xc2fac, .rodata, ov_SC05_017_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc3124, data, tail12] + - [0xc3124, data, tail13] - [0xc31b4, .rodata, ov_SC05_017_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xc3240, data, tail13] + - [0xc3240, data, tail14] - [0xC582C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xC582F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_018.yaml b/config/splat.ov_SC05_018.yaml index 96be4d6a7..b8167da22 100644 --- a/config/splat.ov_SC05_018.yaml +++ b/config/splat.ov_SC05_018.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_018_jr_80159C84] - [0x32270, c, ov_SC05_018_jr_8015A3C8] - [0x32cd4, c, ov_SC05_018_jr_8015AE2C] + - [0x341d4, c, ov_SC05_018_jr_8015C32C] - [0x42a14, c, ov_SC05_018_jr_8016AB6C] - [0x4b364, c, ov_SC05_018_jr_801734BC] - [0x50be8, c, ov_SC05_018_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xbc84c, data, tail8] - [0xbc850, .rodata, ov_SC05_018_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xbc86c, data, tail9] + - [0xbc890, .rodata, ov_SC05_018_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xbc8ac, data, tail10] - [0xbc8c4, .rodata, ov_SC05_018_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbc8e4, data, tail10] + - [0xbc8e4, data, tail11] - [0xbc964, .rodata, ov_SC05_018_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbc978, data, tail11] + - [0xbc978, data, tail12] - [0xbcb20, .rodata, ov_SC05_018_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbcc98, data, tail12] + - [0xbcc98, data, tail13] - [0xbcd28, .rodata, ov_SC05_018_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbcdb4, data, tail13] + - [0xbcdb4, data, tail14] - [0xbcdcc, .rodata, ov_SC05_018_jr_8017D604] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xbcdec, data, tail14] + - [0xbcdec, data, tail15] - [0xBE734, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xBE737] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC05_019.yaml b/config/splat.ov_SC05_019.yaml index d098647d9..3d868c23b 100644 --- a/config/splat.ov_SC05_019.yaml +++ b/config/splat.ov_SC05_019.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC05_019_jr_80159C84] - [0x32270, c, ov_SC05_019_jr_8015A3C8] - [0x32cd4, c, ov_SC05_019_jr_8015AE2C] + - [0x341d4, c, ov_SC05_019_jr_8015C32C] - [0x42a14, c, ov_SC05_019_jr_8016AB6C] - [0x4b364, c, ov_SC05_019_jr_801734BC] - [0x50be8, c, ov_SC05_019_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x65f60, data, tail8] - [0x65f64, .rodata, ov_SC05_019_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x65f80, data, tail9] + - [0x65fa4, .rodata, ov_SC05_019_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x65fc0, data, tail10] - [0x65fd8, .rodata, ov_SC05_019_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x65ff8, data, tail10] + - [0x65ff8, data, tail11] - [0x66078, .rodata, ov_SC05_019_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6608c, data, tail11] + - [0x6608c, data, tail12] - [0x66234, .rodata, ov_SC05_019_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x663ac, data, tail12] + - [0x663ac, data, tail13] - [0x6643c, .rodata, ov_SC05_019_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x664c8, data, tail13] + - [0x664c8, data, tail14] - [0x66500, .rodata, ov_SC05_019_jr_8017D5C0] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x66520, data, tail14] + - [0x66520, data, tail15] - [0x679D4, bin, trailing] # final 1 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x679D5] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_000.yaml b/config/splat.ov_SC06_000.yaml index 08bfcb318..0f7f76f30 100644 --- a/config/splat.ov_SC06_000.yaml +++ b/config/splat.ov_SC06_000.yaml @@ -103,6 +103,7 @@ segments: - [0x31b2c, c, ov_SC06_000_jr_80159C84] - [0x32270, c, ov_SC06_000_jr_8015A3C8] - [0x32cd4, c, ov_SC06_000_jr_8015AE2C] + - [0x341d4, c, ov_SC06_000_jr_8015C32C] - [0x42a14, c, ov_SC06_000_jr_8016AB6C] - [0x4b364, c, ov_SC06_000_jr_801734BC] - [0x50be8, c, ov_SC06_000_jr_80178D40] @@ -122,14 +123,16 @@ segments: - [0x84bd8, data, tail7] - [0x84bdc, .rodata, ov_SC06_000_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x84bf8, data, tail8] + - [0x84c1c, .rodata, ov_SC06_000_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x84c38, data, tail9] - [0x84c50, .rodata, ov_SC06_000_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x84c70, data, tail9] + - [0x84c70, data, tail10] - [0x84cf0, .rodata, ov_SC06_000_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x84d04, data, tail10] + - [0x84d04, data, tail11] - [0x84eac, .rodata, ov_SC06_000_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x85024, data, tail11] + - [0x85024, data, tail12] - [0x850b4, .rodata, ov_SC06_000_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x85140, data, tail12] + - [0x85140, data, tail13] - [0x8A02C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8A02F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_006.yaml b/config/splat.ov_SC06_006.yaml index dc7d6e041..b6110f4af 100644 --- a/config/splat.ov_SC06_006.yaml +++ b/config/splat.ov_SC06_006.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC06_006_jr_80159C84] - [0x32270, c, ov_SC06_006_jr_8015A3C8] - [0x32cd4, c, ov_SC06_006_jr_8015AE2C] + - [0x341d4, c, ov_SC06_006_jr_8015C32C] - [0x42a14, c, ov_SC06_006_jr_8016AB6C] - [0x4b364, c, ov_SC06_006_jr_801734BC] - [0x50be8, c, ov_SC06_006_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0xce4e0, data, tail8] - [0xce4e4, .rodata, ov_SC06_006_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0xce500, data, tail9] + - [0xce524, .rodata, ov_SC06_006_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0xce540, data, tail10] - [0xce558, .rodata, ov_SC06_006_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xce578, data, tail10] + - [0xce578, data, tail11] - [0xce5f8, .rodata, ov_SC06_006_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xce60c, data, tail11] + - [0xce60c, data, tail12] - [0xce7b4, .rodata, ov_SC06_006_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xce92c, data, tail12] + - [0xce92c, data, tail13] - [0xce9bc, .rodata, ov_SC06_006_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xcea48, data, tail13] + - [0xcea48, data, tail14] - [0xcea60, .rodata, ov_SC06_006_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0xcea80, data, tail14] + - [0xcea80, data, tail15] - [0xD0A0C, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0xD0A0F] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_008.yaml b/config/splat.ov_SC06_008.yaml index 0e701f926..256a6e1ce 100644 --- a/config/splat.ov_SC06_008.yaml +++ b/config/splat.ov_SC06_008.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC06_008_jr_80159C84] - [0x32270, c, ov_SC06_008_jr_8015A3C8] - [0x32cd4, c, ov_SC06_008_jr_8015AE2C] + - [0x341d4, c, ov_SC06_008_jr_8015C32C] - [0x42a14, c, ov_SC06_008_jr_8016AB6C] - [0x4b364, c, ov_SC06_008_jr_801734BC] - [0x50be8, c, ov_SC06_008_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x805b8, data, tail8] - [0x805bc, .rodata, ov_SC06_008_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x805d8, data, tail9] + - [0x805fc, .rodata, ov_SC06_008_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x80618, data, tail10] - [0x80630, .rodata, ov_SC06_008_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80650, data, tail10] + - [0x80650, data, tail11] - [0x806d0, .rodata, ov_SC06_008_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x806e4, data, tail11] + - [0x806e4, data, tail12] - [0x8088c, .rodata, ov_SC06_008_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80a04, data, tail12] + - [0x80a04, data, tail13] - [0x80a94, .rodata, ov_SC06_008_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80b20, data, tail13] + - [0x80b20, data, tail14] - [0x80b38, .rodata, ov_SC06_008_jr_8017C294] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x80b58, data, tail14] + - [0x80b58, data, tail15] - [0x826DC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x826DF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_010.yaml b/config/splat.ov_SC06_010.yaml index 88c69ae28..960f8dac5 100644 --- a/config/splat.ov_SC06_010.yaml +++ b/config/splat.ov_SC06_010.yaml @@ -103,6 +103,7 @@ segments: - [0x31b2c, c, ov_SC06_010_jr_80159C84] - [0x32270, c, ov_SC06_010_jr_8015A3C8] - [0x32cd4, c, ov_SC06_010_jr_8015AE2C] + - [0x341d4, c, ov_SC06_010_jr_8015C32C] - [0x42a14, c, ov_SC06_010_jr_8016AB6C] - [0x4b364, c, ov_SC06_010_jr_801734BC] - [0x50be8, c, ov_SC06_010_jr_80178D40] @@ -122,14 +123,16 @@ segments: - [0x8860c, data, tail7] - [0x88610, .rodata, ov_SC06_010_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8862c, data, tail8] + - [0x88650, .rodata, ov_SC06_010_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x8866c, data, tail9] - [0x88684, .rodata, ov_SC06_010_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x886a4, data, tail9] + - [0x886a4, data, tail10] - [0x88724, .rodata, ov_SC06_010_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x88738, data, tail10] + - [0x88738, data, tail11] - [0x888e0, .rodata, ov_SC06_010_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x88a58, data, tail11] + - [0x88a58, data, tail12] - [0x88ae8, .rodata, ov_SC06_010_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x88b74, data, tail12] + - [0x88b74, data, tail13] - [0x8AB24, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x8AB27] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_011.yaml b/config/splat.ov_SC06_011.yaml index 4f28da66e..2520774cc 100644 --- a/config/splat.ov_SC06_011.yaml +++ b/config/splat.ov_SC06_011.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC06_011_jr_80159C84] - [0x32270, c, ov_SC06_011_jr_8015A3C8] - [0x32cd4, c, ov_SC06_011_jr_8015AE2C] + - [0x341d4, c, ov_SC06_011_jr_8015C32C] - [0x42a14, c, ov_SC06_011_jr_8016AB6C] - [0x4b364, c, ov_SC06_011_jr_801734BC] - [0x50be8, c, ov_SC06_011_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x8216c, data, tail8] - [0x82170, .rodata, ov_SC06_011_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x8218c, data, tail9] + - [0x821b0, .rodata, ov_SC06_011_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x821cc, data, tail10] - [0x821e4, .rodata, ov_SC06_011_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x82204, data, tail10] + - [0x82204, data, tail11] - [0x82284, .rodata, ov_SC06_011_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x82298, data, tail11] + - [0x82298, data, tail12] - [0x82440, .rodata, ov_SC06_011_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x825b8, data, tail12] + - [0x825b8, data, tail13] - [0x82648, .rodata, ov_SC06_011_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x826d4, data, tail13] + - [0x826d4, data, tail14] - [0x826ec, .rodata, ov_SC06_011_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x8270c, data, tail14] + - [0x8270c, data, tail15] - [0x83BFC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x83BFF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_013.yaml b/config/splat.ov_SC06_013.yaml index 5bc74c96b..d5c02905e 100644 --- a/config/splat.ov_SC06_013.yaml +++ b/config/splat.ov_SC06_013.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC06_013_jr_80159C84] - [0x32270, c, ov_SC06_013_jr_8015A3C8] - [0x32cd4, c, ov_SC06_013_jr_8015AE2C] + - [0x341d4, c, ov_SC06_013_jr_8015C32C] - [0x42a14, c, ov_SC06_013_jr_8016AB6C] - [0x4b364, c, ov_SC06_013_jr_801734BC] - [0x50be8, c, ov_SC06_013_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x71040, data, tail8] - [0x71044, .rodata, ov_SC06_013_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x71060, data, tail9] + - [0x71084, .rodata, ov_SC06_013_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x710a0, data, tail10] - [0x710b8, .rodata, ov_SC06_013_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x710d8, data, tail10] + - [0x710d8, data, tail11] - [0x71158, .rodata, ov_SC06_013_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7116c, data, tail11] + - [0x7116c, data, tail12] - [0x71314, .rodata, ov_SC06_013_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x7148c, data, tail12] + - [0x7148c, data, tail13] - [0x7151c, .rodata, ov_SC06_013_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x715a8, data, tail13] + - [0x715a8, data, tail14] - [0x715c0, .rodata, ov_SC06_013_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x715e0, data, tail14] + - [0x715e0, data, tail15] - [0x72AAC, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x72AAF] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_014.yaml b/config/splat.ov_SC06_014.yaml index 6bb489365..144b9cb84 100644 --- a/config/splat.ov_SC06_014.yaml +++ b/config/splat.ov_SC06_014.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC06_014_jr_80159C84] - [0x32270, c, ov_SC06_014_jr_8015A3C8] - [0x32cd4, c, ov_SC06_014_jr_8015AE2C] + - [0x341d4, c, ov_SC06_014_jr_8015C32C] - [0x42a14, c, ov_SC06_014_jr_8016AB6C] - [0x4b364, c, ov_SC06_014_jr_801734BC] - [0x50be8, c, ov_SC06_014_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x77a30, data, tail8] - [0x77a34, .rodata, ov_SC06_014_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x77a50, data, tail9] + - [0x77a74, .rodata, ov_SC06_014_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x77a90, data, tail10] - [0x77aa8, .rodata, ov_SC06_014_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77ac8, data, tail10] + - [0x77ac8, data, tail11] - [0x77b48, .rodata, ov_SC06_014_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77b5c, data, tail11] + - [0x77b5c, data, tail12] - [0x77d04, .rodata, ov_SC06_014_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77e7c, data, tail12] + - [0x77e7c, data, tail13] - [0x77f0c, .rodata, ov_SC06_014_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77f98, data, tail13] + - [0x77f98, data, tail14] - [0x77fb0, .rodata, ov_SC06_014_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x77fd0, data, tail14] + - [0x77fd0, data, tail15] - [0x794C4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x794C7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_015.yaml b/config/splat.ov_SC06_015.yaml index 07ddd9283..5b823c3b8 100644 --- a/config/splat.ov_SC06_015.yaml +++ b/config/splat.ov_SC06_015.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC06_015_jr_80159C84] - [0x32270, c, ov_SC06_015_jr_8015A3C8] - [0x32cd4, c, ov_SC06_015_jr_8015AE2C] + - [0x341d4, c, ov_SC06_015_jr_8015C32C] - [0x42a14, c, ov_SC06_015_jr_8016AB6C] - [0x4b364, c, ov_SC06_015_jr_801734BC] - [0x50be8, c, ov_SC06_015_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x6ae10, data, tail8] - [0x6ae14, .rodata, ov_SC06_015_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x6ae30, data, tail9] + - [0x6ae54, .rodata, ov_SC06_015_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x6ae70, data, tail10] - [0x6ae88, .rodata, ov_SC06_015_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6aea8, data, tail10] + - [0x6aea8, data, tail11] - [0x6af28, .rodata, ov_SC06_015_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6af3c, data, tail11] + - [0x6af3c, data, tail12] - [0x6b0e4, .rodata, ov_SC06_015_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b25c, data, tail12] + - [0x6b25c, data, tail13] - [0x6b2ec, .rodata, ov_SC06_015_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b378, data, tail13] + - [0x6b378, data, tail14] - [0x6b390, .rodata, ov_SC06_015_jr_8017BEBC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x6b3b0, data, tail14] + - [0x6b3b0, data, tail15] - [0x6C8A4, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x6C8A7] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/config/splat.ov_SC06_016.yaml b/config/splat.ov_SC06_016.yaml index 9056d9a10..de57fd283 100644 --- a/config/splat.ov_SC06_016.yaml +++ b/config/splat.ov_SC06_016.yaml @@ -104,6 +104,7 @@ segments: - [0x31b2c, c, ov_SC06_016_jr_80159C84] - [0x32270, c, ov_SC06_016_jr_8015A3C8] - [0x32cd4, c, ov_SC06_016_jr_8015AE2C] + - [0x341d4, c, ov_SC06_016_jr_8015C32C] - [0x42a14, c, ov_SC06_016_jr_8016AB6C] - [0x4b364, c, ov_SC06_016_jr_801734BC] - [0x50be8, c, ov_SC06_016_jr_80178D40] @@ -126,16 +127,18 @@ segments: - [0x75a58, data, tail8] - [0x75a5c, .rodata, ov_SC06_016_jr_8015AE2C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - [0x75a78, data, tail9] + - [0x75a9c, .rodata, ov_SC06_016_jr_8015C32C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) + - [0x75ab8, data, tail10] - [0x75ad0, .rodata, ov_SC06_016_jr_8016AB6C] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x75af0, data, tail10] + - [0x75af0, data, tail11] - [0x75b70, .rodata, ov_SC06_016_jr_801734BC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x75b84, data, tail11] + - [0x75b84, data, tail12] - [0x75d2c, .rodata, ov_SC06_016_jr_80178D40] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x75ea4, data, tail12] + - [0x75ea4, data, tail13] - [0x75f34, .rodata, ov_SC06_016_jr_8017A4AC] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x75fc0, data, tail13] + - [0x75fc0, data, tail14] - [0x76110, .rodata, ov_SC06_016_jr_8017C8D0] # Phase-26 §8 jtbl-rodata carve (jtbl_carve.py) - - [0x76130, data, tail14] + - [0x76130, data, tail15] - [0x78114, bin, trailing] # final 3 bytes (EOF not 4-aligned; spimdisasm drops a partial word) - [0x78117] # EOF marker = the 0.4.dec byte length # @TRAILING@ (above) is replaced by tools/new_overlay.sh: for a non-4-aligned overlay it becomes diff --git a/src/ov_SC01_080/ov_SC01_080_jr_8015AE2C.c b/src/ov_SC01_080/ov_SC01_080_jr_8015AE2C.c index 6ba01ad8b..d1eb35b2b 100644 --- a/src/ov_SC01_080/ov_SC01_080_jr_8015AE2C.c +++ b/src/ov_SC01_080/ov_SC01_080_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80185D80[])(void); - -void func_8015C714(void *a0) { - D_80185D80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80185BF4[])(void*); - extern int D_80185B98; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80185BF4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80185BF4)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185B98); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80185BF4[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80185BF4[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80185BF4[])(void*); - extern int D_80185B98; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80185BF4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185B98); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80185BF4)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80185D90[])(void); - D_80185D90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80185BF4[])(struct Ent_8015CD20 *); - extern u8 D_80185BA8; - extern u8 D_80185D98; - extern u8 D_80185DA8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80185BF4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185BA8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185D98); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185DA8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80185BF4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80185DC8[])(void); - D_80185DC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80185DB8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80185DB8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80185BF4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80185E24; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80185E24, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80184F08[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80184F08; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80185E2C[])(void); - D_80185E2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80185E38[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80185E38[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80185E38[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80185E38[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80185BF4[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80185E38[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80185BB8[]; - extern u8 D_80185BC8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185BB8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185BC8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80185E38[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185E38[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185E38[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80185E6C[])(void); - D_80185E6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185BF4[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80185E74[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80185E8C[])(void); - D_80185E8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185BF4[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80185E74[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80185EAC[])(void); - D_80185EAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80185BF4[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185BF4)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80185EBC; -extern u16 D_80185EBE; -extern u16 D_80185EC0; -extern s32 D_80185EC4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80185EBC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80185EBE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80185EC0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185EC4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80185ECC; - -void func_8015E588(void) { - func_8013C9C4(&D_80185ECC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80185BF4[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185BF4)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80185EE0[])(void); - D_80185EE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80185BF4[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80185BF4[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80185EE8[])(void); - D_80185EE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80185BD8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185BD8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80185BF4[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80185EF0[])(void); - D_80185EF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80185BF4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80185BF4[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80185EF8[])(void); - D_80185EF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80185BF4[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80185F00; - extern s32 D_80185F10; - extern s32 D_80185F20; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80185BF4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185F00); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185F10); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80185BF4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185F20); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80185F30[])(void); - D_80185F30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80185BF4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80185BF4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80185BF4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185BF4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80185F3C[])(void); - D_80185F3C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80185BF4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185BF4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80185BF4[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185BF4[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80185F50[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80185F50[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80185BF4[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80185BF4)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80185BF4[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185BF4[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80185FCC[])(void); - D_80185FCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80185BF4[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80185BF4)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80185FDC[])(void); - D_80185FDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80185BF4[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80185BF4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80185BF4[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80185BF4[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80185BF4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80185BF4[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80185BF4[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80185FE4[])(void); - D_80185FE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80185BF4[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80185BF4)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80185BF4[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80185BF4)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80185FF0[])(void); - D_80185FF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185BF4 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80185BF4[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80185BF4[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80185BF4[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80186000[])(void); - -void func_80160EA4(void *a0) { - D_80186000[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80185BF4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80185BF4[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80186030[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80186030[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80186094; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80186094); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C48E0[]; - extern u8 D_80186060[]; - extern u8 D_80186080[]; - extern u8 D_801C48EC[]; - extern u8 D_801C4914[]; - extern u8 D_801C492C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C48E0[0] = p; - func_80024054(&D_80186060, &D_801C48EC); - func_8001CE28(p, &D_801C48EC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C48E0[1] = p; - func_80024054(&D_80186080, &D_801C4914); - func_8001CE28(p, &D_801C4914); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C48E0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C492C, 0x84); - func_8001CE68(p, &D_801C492C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C492C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C48E0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C48E0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80186094; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80186094; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80186094; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80186094; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C48E0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C48E0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801860B8[])(void); - -void func_80162330(void *a0) { - D_801860B8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C4938[i] via `extern int D_801C4938[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801860C4[]; - extern s32 D_801860DC; - extern u8 D_801C4944[]; - extern u8 D_801C496C[]; - extern u8 D_801C4988[]; - extern int D_801C4938[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C4938[0] = (s32)item; - func_80024054(D_801860C4, D_801C4944); - func_8001CE28(item, D_801C4944); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C4938[1] = (s32)item; - func_80024054(((u8 *)&D_801860DC), D_801C496C); - func_8001CE28(item, D_801C496C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C4938[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C4988, 0x84); - func_8001CE68(item, D_801C4988); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C4988, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C4938[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C4938; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_801627E8); - - -extern void (*D_80186100[])(void); - -void func_80162834(void *a0) { - D_80186100[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801860F0; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801860F0, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C4190[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C4190, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C4190[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C4190, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80186108[])(void); - -void func_80163A58(void *a0) { - D_80186108[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C4198; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C4198; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018615C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018615C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80186124; -extern s16 D_80186158; -extern s16 D_80186156; -extern s16 D_80186154; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80186124; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80186158 = 0x80; - D_80186156 = 0x80; - D_80186154 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80186158 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80186158` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80186158 - 8; - D_80186158 = nv; - D_80186156 = nv; - D_80186154 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80186168[])(void); - -void func_80164BA0(void *a0) { - D_80186168[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C4998; -extern u8 D_801C4999; -extern u8 D_801C499A; -extern u8 D_801C499B; -extern u8 D_801C499C; -extern u8 D_801C499D; -extern u8 D_801C499E; -extern u8 D_801C499F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C4998; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C4999 = 0xf0; - *(u8 *)base = 0xf0; - D_801C499A = 0xc0; - D_801C499E = 0; - D_801C499D = 0; - D_801C499C = 0; - D_801C499F = 0; - D_801C499B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C4998; -extern u8 D_801C4999; -extern u8 D_801C499A; - -s32 func_80164E40(void) { - u8 *p = &D_801C4998; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C4999 != 0) { - D_801C4999 -= 0x10; - } - if (D_801C499A != 0) { - D_801C499A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80186178[])(void); - -void func_80164EA4(void *a0) { - D_80186178[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C49E4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C49E4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C49D8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C49D8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C49D8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C49D8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C49D8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018618C[]; - extern u32 D_801861AC, D_801861B0, D_801861B4, D_801861B8; - extern u32 D_801861AC, D_801861B0, D_801861B4, D_801861B8; - extern u32 D_801861AC, D_801861B0, D_801861B4, D_801861B8; - extern u32 D_801861AC, D_801861B0, D_801861B4, D_801861B8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018618C[0x00], p); - ApplyMatrixSV(mat, &D_8018618C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018618C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018618C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801861B4; - *(u32 *)(prim + 0x24) = D_801861AC; - *(u32 *)(prim + 0x28) = D_801861B8; - *(u32 *)(prim + 0x2c) = D_801861B0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801861BC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801861BC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801861BC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801861BC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80186238[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80186238[a1 & 0x7F]; -} - - - -extern s32 D_80186258[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80186258[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801862D4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801862D4[a1 & 0x7F]; -} - - - -extern u8 D_801862F4[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801862F4[a1 & 0x7F]; -} - - - -extern u8 D_80186314[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80186314[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80186334[])(void); - D_80186334[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801863B0[])(void); - -void func_80165AC8(void) { - D_801863B0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018642C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018642C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C41A0; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C41A0, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80186438[])(void); - -void func_80166018(void *a0) { - D_80186438[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80186440[])(void); - -void func_801663FC(void *a0) { - D_80186440[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80186508[])(void); - -void func_80166618(void *a0) { - D_80186508[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80186518[])(void); - -void func_80166654(void *a0) { - D_80186518[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C4A58[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C4A58[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C4A58). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C4A58[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C4A58)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C4A58[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C4A58[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018645C[]; - extern u8 D_80186448[]; - extern u8 D_80186470[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018645C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80186448; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80186470; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80167714); - - -extern void (*D_80186528[])(void); - -void func_801678B4(void *a0) { - D_80186528[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80186534[])(void); - -void func_80167A9C(void *a0) { - D_80186534[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80186640; - extern u8 D_80186654[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80186640); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80186654; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80186494[]; -extern u8 D_801864A8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80186494; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801864A8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018654C[])(void); - -void func_80168744(void *a0) { - D_8018654C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018653C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018653C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018653C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80186554[])(void); - -void func_801689D8(void *a0) { - D_80186554[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018655C[])(void); - -void func_80168AA8(void *a0) { - D_8018655C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80186564[])(void); - -void func_80168D58(void *a0) { - D_80186564[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018656C[])(void); - -void func_8016901C(void *a0) { - D_8018656C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015AE2C", func_80169228); - - -extern void (*D_80186574[])(void); - -void func_801693CC(void *a0) { - D_80186574[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018657C[])(void); - -void func_80169830(void *a0) { - D_8018657C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80186630[])(void); - -void func_80169B80(void *a0) { - D_80186630[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80186584[]; - extern u8 D_801865F4[]; - extern u8 D_80186624[]; - extern u8 D_801C7E08[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80186624, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80186584[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C7E08; - RotMatrixYXZ(rot, D_801C7E08); - func_80048D9C(D_801C7E08, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801865F4); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80186638[])(void); - -void func_80169F00(void *a0) { - D_80186638[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801865E8[]; -extern char D_801865A8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801865E8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801865A8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80186670[])(void); - -void func_8016A020(void *a0) { - D_80186670[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80186640; - extern u8 D_80186654[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80186640); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80186654; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018667C[])(void); - -void func_8016A700(void *a0) { - D_8018667C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801866C4[])(void); - -void func_8016AB30(void *a0) { - D_801866C4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c b/src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c new file mode 100644 index 000000000..c5afb9968 --- /dev/null +++ b/src/ov_SC01_080/ov_SC01_080_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80185A90; +extern u8 D_80185A00; +extern u8 D_801859DC; +extern u8 D_801859B8; +extern u8 D_80185A6C; +extern u8 D_80185A48; +extern u8 D_80185A24; +extern u8 D_80185994; +extern void func_80145934(void); +extern u8 D_80185B20; +extern u8 D_80185AFC; +extern u8 D_80185AD8; +extern u8 D_80185AB4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80184F18[]; +extern unsigned char D_80184F48[]; +extern unsigned char D_80184F98[]; +extern unsigned char D_80184FC8[]; +extern unsigned char D_80184FF8[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80185048[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80185110[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80185198[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801851A0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C4888; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C488C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801851D0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80185278[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018529C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018528C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801852B0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801852BC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801852CC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801852E4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801852D4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801852F8[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80185314[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80185304; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80185328[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018533C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80185350; +extern void (*D_80185378[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80185358; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801853C4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801853C8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018582C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018583C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C48C0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80185864[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80185844; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80185854; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801858A4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801858AC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80185878; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801858B8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80185888; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C48C8; +extern s32 D_801C48D4; +extern s32 D_801C48D8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801858F4[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801858C8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C48D0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80185B44[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80185964[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80185BE8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80185D3C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80185B58; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80185D44[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80185B68; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80185B88; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80185D4C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80185D74[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80185BF4[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80185D80[])(void); + +void func_8015C714(void *a0) { + D_80185D80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80185BF4[])(void*); + extern int D_80185B98; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80185BF4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80185BF4)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185B98); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80185BF4[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80185BF4[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80185BF4[])(void*); + extern int D_80185B98; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80185BF4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185B98); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80185BF4)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80185D90[])(void); + D_80185D90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80185BF4[])(struct Ent_8015CD20 *); + extern u8 D_80185BA8; + extern u8 D_80185D98; + extern u8 D_80185DA8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80185BF4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185BA8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185D98); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185DA8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80185BF4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80185DC8[])(void); + D_80185DC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80185DB8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80185DB8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80185BF4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80185E24; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80185E24, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80184F08[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80184F08; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80185E2C[])(void); + D_80185E2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80185E38[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80185E38[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80185E38[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80185E38[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80185BF4[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80185E38[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80185BB8[]; + extern u8 D_80185BC8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185BB8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185BC8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80185E38[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185E38[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185E38[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80185E6C[])(void); + D_80185E6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185BF4[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80185E74[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80185E8C[])(void); + D_80185E8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185BF4[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80185E74[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80185E74[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80185EAC[])(void); + D_80185EAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80185BF4[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185BF4)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80185EBC; +extern u16 D_80185EBE; +extern u16 D_80185EC0; +extern s32 D_80185EC4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80185EBC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80185EBE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80185EC0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185EC4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80185ECC; + +void func_8015E588(void) { + func_8013C9C4(&D_80185ECC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80185BF4[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185BF4)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80185EE0[])(void); + D_80185EE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80185BF4[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80185BF4[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80185EE8[])(void); + D_80185EE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80185BD8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185BD8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80185BF4[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80185EF0[])(void); + D_80185EF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80185BF4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80185BF4[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80185EF8[])(void); + D_80185EF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80185BF4[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80185F00; + extern s32 D_80185F10; + extern s32 D_80185F20; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185F00); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185F10); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80185BF4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185F20); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80185F30[])(void); + D_80185F30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80185BF4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80185BF4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80185BF4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185BF4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80185F3C[])(void); + D_80185F3C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80185BF4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185BF4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80185BF4[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185BF4[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80185F50[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80185F50[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80185BF4[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80185BF4)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80185BF4[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185BF4[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80185FCC[])(void); + D_80185FCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80185BF4[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80185BF4)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80185FDC[])(void); + D_80185FDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80185BF4[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80185BF4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80185BF4[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80185BF4[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80185BF4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80185BF4[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80185BF4[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80185FE4[])(void); + D_80185FE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80185BF4[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80185BF4)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80185BF4[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80185BF4)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80185FF0[])(void); + D_80185FF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185BF4 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80185BF4[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80185BF4[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80185BF4[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80186000[])(void); + +void func_80160EA4(void *a0) { + D_80186000[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80185BF4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80185BF4[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80186030[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80186030[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80186094; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80186094); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C48E0[]; + extern u8 D_80186060[]; + extern u8 D_80186080[]; + extern u8 D_801C48EC[]; + extern u8 D_801C4914[]; + extern u8 D_801C492C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C48E0[0] = p; + func_80024054(&D_80186060, &D_801C48EC); + func_8001CE28(p, &D_801C48EC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C48E0[1] = p; + func_80024054(&D_80186080, &D_801C4914); + func_8001CE28(p, &D_801C4914); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C48E0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C492C, 0x84); + func_8001CE68(p, &D_801C492C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C492C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C48E0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C48E0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80186094; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80186094; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80186094; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80186094; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C48E0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C48E0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801860B8[])(void); + +void func_80162330(void *a0) { + D_801860B8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C4938[i] via `extern int D_801C4938[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801860C4[]; + extern s32 D_801860DC; + extern u8 D_801C4944[]; + extern u8 D_801C496C[]; + extern u8 D_801C4988[]; + extern int D_801C4938[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C4938[0] = (s32)item; + func_80024054(D_801860C4, D_801C4944); + func_8001CE28(item, D_801C4944); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C4938[1] = (s32)item; + func_80024054(((u8 *)&D_801860DC), D_801C496C); + func_8001CE28(item, D_801C496C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C4938[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C4988, 0x84); + func_8001CE68(item, D_801C4988); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C4988, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C4938[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C4938; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_801627E8); + + +extern void (*D_80186100[])(void); + +void func_80162834(void *a0) { + D_80186100[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801860F0; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801860F0, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C4190[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C4190, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C4190[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C4190, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80186108[])(void); + +void func_80163A58(void *a0) { + D_80186108[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C4198; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C4198; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018615C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018615C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80186124; +extern s16 D_80186158; +extern s16 D_80186156; +extern s16 D_80186154; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80186124; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80186158 = 0x80; + D_80186156 = 0x80; + D_80186154 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80186158 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80186158` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80186158 - 8; + D_80186158 = nv; + D_80186156 = nv; + D_80186154 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80186168[])(void); + +void func_80164BA0(void *a0) { + D_80186168[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C4998; +extern u8 D_801C4999; +extern u8 D_801C499A; +extern u8 D_801C499B; +extern u8 D_801C499C; +extern u8 D_801C499D; +extern u8 D_801C499E; +extern u8 D_801C499F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C4998; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C4999 = 0xf0; + *(u8 *)base = 0xf0; + D_801C499A = 0xc0; + D_801C499E = 0; + D_801C499D = 0; + D_801C499C = 0; + D_801C499F = 0; + D_801C499B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C4998; +extern u8 D_801C4999; +extern u8 D_801C499A; + +s32 func_80164E40(void) { + u8 *p = &D_801C4998; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C4999 != 0) { + D_801C4999 -= 0x10; + } + if (D_801C499A != 0) { + D_801C499A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80186178[])(void); + +void func_80164EA4(void *a0) { + D_80186178[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C49E4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C49E4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C49D8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C49D8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C49D8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C49D8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C49D8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018618C[]; + extern u32 D_801861AC, D_801861B0, D_801861B4, D_801861B8; + extern u32 D_801861AC, D_801861B0, D_801861B4, D_801861B8; + extern u32 D_801861AC, D_801861B0, D_801861B4, D_801861B8; + extern u32 D_801861AC, D_801861B0, D_801861B4, D_801861B8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018618C[0x00], p); + ApplyMatrixSV(mat, &D_8018618C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018618C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018618C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801861B4; + *(u32 *)(prim + 0x24) = D_801861AC; + *(u32 *)(prim + 0x28) = D_801861B8; + *(u32 *)(prim + 0x2c) = D_801861B0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801861BC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801861BC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801861BC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801861BC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80186238[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80186238[a1 & 0x7F]; +} + + + +extern s32 D_80186258[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80186258[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801862D4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801862D4[a1 & 0x7F]; +} + + + +extern u8 D_801862F4[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801862F4[a1 & 0x7F]; +} + + + +extern u8 D_80186314[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80186314[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80186334[])(void); + D_80186334[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801863B0[])(void); + +void func_80165AC8(void) { + D_801863B0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018642C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018642C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C41A0; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C41A0, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80186438[])(void); + +void func_80166018(void *a0) { + D_80186438[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80186440[])(void); + +void func_801663FC(void *a0) { + D_80186440[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80186508[])(void); + +void func_80166618(void *a0) { + D_80186508[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80186518[])(void); + +void func_80166654(void *a0) { + D_80186518[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C4A58[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C4A58[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C4A58). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C4A58[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C4A58)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C4A58[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C4A58[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018645C[]; + extern u8 D_80186448[]; + extern u8 D_80186470[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018645C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80186448; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80186470; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80167714); + + +extern void (*D_80186528[])(void); + +void func_801678B4(void *a0) { + D_80186528[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80186534[])(void); + +void func_80167A9C(void *a0) { + D_80186534[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80186640; + extern u8 D_80186654[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80186640); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80186654; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80186494[]; +extern u8 D_801864A8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80186494; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801864A8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018654C[])(void); + +void func_80168744(void *a0) { + D_8018654C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018653C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018653C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018653C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80186554[])(void); + +void func_801689D8(void *a0) { + D_80186554[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018655C[])(void); + +void func_80168AA8(void *a0) { + D_8018655C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80186564[])(void); + +void func_80168D58(void *a0) { + D_80186564[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018656C[])(void); + +void func_8016901C(void *a0) { + D_8018656C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_080/nonmatchings/ov_SC01_080_jr_8015C32C", func_80169228); + + +extern void (*D_80186574[])(void); + +void func_801693CC(void *a0) { + D_80186574[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018657C[])(void); + +void func_80169830(void *a0) { + D_8018657C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80186630[])(void); + +void func_80169B80(void *a0) { + D_80186630[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80186584[]; + extern u8 D_801865F4[]; + extern u8 D_80186624[]; + extern u8 D_801C7E08[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80186624, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80186584[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C7E08; + RotMatrixYXZ(rot, D_801C7E08); + func_80048D9C(D_801C7E08, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801865F4); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80186638[])(void); + +void func_80169F00(void *a0) { + D_80186638[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801865E8[]; +extern char D_801865A8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801865E8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801865A8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80186670[])(void); + +void func_8016A020(void *a0) { + D_80186670[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80186640; + extern u8 D_80186654[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80186640); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80186654; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018667C[])(void); + +void func_8016A700(void *a0) { + D_8018667C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801866C4[])(void); + +void func_8016AB30(void *a0) { + D_801866C4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC01_084/ov_SC01_084_jr_8015AE2C.c b/src/ov_SC01_084/ov_SC01_084_jr_8015AE2C.c index 306475e46..50ec8637b 100644 --- a/src/ov_SC01_084/ov_SC01_084_jr_8015AE2C.c +++ b/src/ov_SC01_084/ov_SC01_084_jr_8015AE2C.c @@ -1642,4589 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80189074[])(void); - -void func_8015C714(void *a0) { - D_80189074[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80188EE8[])(void*); - extern int D_80188E8C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80188EE8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80188EE8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188E8C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80188EE8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80188EE8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80188EE8[])(void*); - extern int D_80188E8C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80188EE8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188E8C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80188EE8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80189084[])(void); - D_80189084[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80188EE8[])(struct Ent_8015CD20 *); - extern u8 D_80188E9C; - extern u8 D_8018908C; - extern u8 D_8018909C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80188EE8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188E9C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018908C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018909C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80188EE8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801890BC[])(void); - D_801890BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801890AC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801890AC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80188EE8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80189118; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80189118, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801881FC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801881FC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80189120[])(void); - D_80189120[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018912C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018912C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018912C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018912C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80188EE8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018912C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80188EAC[]; - extern u8 D_80188EBC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188EAC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188EBC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018912C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018912C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018912C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80189160[])(void); - D_80189160[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188EE8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80189168[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80189180[])(void); - D_80189180[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188EE8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80189168[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - -extern void (*D_801891A0[])(void); - -s32 func_8015E1B8(s32 a0) -{ - D_801891A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80188EE8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188EE8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801891B0; -extern u16 D_801891B2; -extern u16 D_801891B4; -extern s32 D_801891B8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801891B0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801891B2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801891B4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801891B8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801891C0; - -void func_8015E588(void) { - func_8013C9C4(&D_801891C0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80188EE8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188EE8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801891D4[])(void); - D_801891D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80188EE8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80188EE8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801891DC[])(void); - D_801891DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80188ECC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188ECC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80188EE8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801891E4[])(void); - D_801891E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80188EE8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80188EE8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801891EC[])(void); - D_801891EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80188EE8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801891F4; - extern s32 D_80189204; - extern s32 D_80189214; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80188EE8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801891F4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189204); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80188EE8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189214); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80189224[])(void); - D_80189224[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80188EE8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80188EE8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80188EE8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188EE8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80189230[])(void); - D_80189230[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80188EE8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188EE8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80188EE8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188EE8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80189244[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80189244[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80188EE8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80188EE8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80188EE8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188EE8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801892C0[])(void); - D_801892C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80188EE8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80188EE8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801892D0[])(void); - D_801892D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80188EE8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80188EE8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80188EE8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80188EE8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80188EE8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80188EE8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80188EE8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801892D8[])(void); - D_801892D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80188EE8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80188EE8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80188EE8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80188EE8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801892E4[])(void); - D_801892E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188EE8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80188EE8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80188EE8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80188EE8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801892F4[])(void); - -void func_80160EA4(void *a0) { - D_801892F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80188EE8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80188EE8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80189324[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80189324[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80189388; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80189388); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C6388[]; - extern u8 D_80189354[]; - extern u8 D_80189374[]; - extern u8 D_801C6394[]; - extern u8 D_801C63BC[]; - extern u8 D_801C63D4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C6388[0] = p; - func_80024054(&D_80189354, &D_801C6394); - func_8001CE28(p, &D_801C6394); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C6388[1] = p; - func_80024054(&D_80189374, &D_801C63BC); - func_8001CE28(p, &D_801C63BC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C6388[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C63D4, 0x84); - func_8001CE68(p, &D_801C63D4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C63D4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C6388[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C6388; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80189388; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80189388; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80189388; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80189388; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C6388[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C6388; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801893AC[])(void); - -void func_80162330(void *a0) { - D_801893AC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C63E0[i] via `extern int D_801C63E0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801893B8[]; - extern s32 D_801893D0; - extern u8 D_801C63EC[]; - extern u8 D_801C6414[]; - extern u8 D_801C6430[]; - extern int D_801C63E0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C63E0[0] = (s32)item; - func_80024054(D_801893B8, D_801C63EC); - func_8001CE28(item, D_801C63EC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C63E0[1] = (s32)item; - func_80024054(((u8 *)&D_801893D0), D_801C6414); - func_8001CE28(item, D_801C6414); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C63E0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C6430, 0x84); - func_8001CE68(item, D_801C6430); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C6430, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C63E0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C63E0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_801627E8); - - -extern void (*D_801893F4[])(void); - -void func_80162834(void *a0) { - D_801893F4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801893E4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801893E4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C5B60[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C5B60, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C5B60[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C5B60, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801893FC[])(void); - -void func_80163A58(void *a0) { - D_801893FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C5B68; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C5B68; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80189450[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80189450[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80189418; -extern s16 D_8018944C; -extern s16 D_8018944A; -extern s16 D_80189448; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80189418; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018944C = 0x80; - D_8018944A = 0x80; - D_80189448 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018944C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018944C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018944C - 8; - D_8018944C = nv; - D_8018944A = nv; - D_80189448 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018945C[])(void); - -void func_80164BA0(void *a0) { - D_8018945C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C6440; -extern u8 D_801C6441; -extern u8 D_801C6442; -extern u8 D_801C6443; -extern u8 D_801C6444; -extern u8 D_801C6445; -extern u8 D_801C6446; -extern u8 D_801C6447; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C6440; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C6441 = 0xf0; - *(u8 *)base = 0xf0; - D_801C6442 = 0xc0; - D_801C6446 = 0; - D_801C6445 = 0; - D_801C6444 = 0; - D_801C6447 = 0; - D_801C6443 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C6440; -extern u8 D_801C6441; -extern u8 D_801C6442; - -s32 func_80164E40(void) { - u8 *p = &D_801C6440; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C6441 != 0) { - D_801C6441 -= 0x10; - } - if (D_801C6442 != 0) { - D_801C6442 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018946C[])(void); - -void func_80164EA4(void *a0) { - D_8018946C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C648C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C648C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C6480[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C6480[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C6480[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C6480; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C6480; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80189480[]; - extern u32 D_801894A0, D_801894A4, D_801894A8, D_801894AC; - extern u32 D_801894A0, D_801894A4, D_801894A8, D_801894AC; - extern u32 D_801894A0, D_801894A4, D_801894A8, D_801894AC; - extern u32 D_801894A0, D_801894A4, D_801894A8, D_801894AC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80189480[0x00], p); - ApplyMatrixSV(mat, &D_80189480[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80189480[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80189480[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801894A8; - *(u32 *)(prim + 0x24) = D_801894A0; - *(u32 *)(prim + 0x28) = D_801894AC; - *(u32 *)(prim + 0x2c) = D_801894A4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801894B0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801894B0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801894B0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801894B0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018952C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018952C[a1 & 0x7F]; -} - - - -extern s32 D_8018954C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018954C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801895C8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801895C8[a1 & 0x7F]; -} - - - -extern u8 D_801895E8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801895E8[a1 & 0x7F]; -} - - - -extern u8 D_80189608[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80189608[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80189628[])(void); - D_80189628[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801896A4[])(void); - -void func_80165AC8(void) { - D_801896A4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80189720[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80189720[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C5B70; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C5B70, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018972C[])(void); - -void func_80166018(void *a0) { - D_8018972C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80189734[])(void); - -void func_801663FC(void *a0) { - D_80189734[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801897FC[])(void); - -void func_80166618(void *a0) { - D_801897FC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018980C[])(void); - -void func_80166654(void *a0) { - D_8018980C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C6500[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C6500[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C6500). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C6500[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C6500)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C6500[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C6500[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80189750[]; - extern u8 D_8018973C[]; - extern u8 D_80189764[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80189750; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018973C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80189764; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80167714); - - -extern void (*D_8018981C[])(void); - -void func_801678B4(void *a0) { - D_8018981C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80189828[])(void); - -void func_80167A9C(void *a0) { - D_80189828[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80189934; - extern u8 D_80189948[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80189934); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80189948; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80189788[]; -extern u8 D_8018979C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80189788; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018979C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80189840[])(void); - -void func_80168744(void *a0) { - D_80189840[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80189830 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80189830[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80189830; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80189848[])(void); - -void func_801689D8(void *a0) { - D_80189848[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80189850[])(void); - -void func_80168AA8(void *a0) { - D_80189850[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80189858[])(void); - -void func_80168D58(void *a0) { - D_80189858[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80189860[])(void); - -void func_8016901C(void *a0) { - D_80189860[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015AE2C", func_80169228); - - -extern void (*D_80189868[])(void); - -void func_801693CC(void *a0) { - D_80189868[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80189870[])(void); - -void func_80169830(void *a0) { - D_80189870[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80189924[])(void); - -void func_80169B80(void *a0) { - D_80189924[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80189878[]; - extern u8 D_801898E8[]; - extern u8 D_80189918[]; - extern u8 D_801C7768[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80189918, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80189878[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C7768; - RotMatrixYXZ(rot, D_801C7768); - func_80048D9C(D_801C7768, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801898E8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018992C[])(void); - -void func_80169F00(void *a0) { - D_8018992C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801898DC[]; -extern char D_8018989C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801898DC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018989C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80189964[])(void); - -void func_8016A020(void *a0) { - D_80189964[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80189934; - extern u8 D_80189948[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80189934); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80189948; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80189970[])(void); - -void func_8016A700(void *a0) { - D_80189970[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801899B8[])(void); - -void func_8016AB30(void *a0) { - D_801899B8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c b/src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c new file mode 100644 index 000000000..532d03a5a --- /dev/null +++ b/src/ov_SC01_084/ov_SC01_084_jr_8015C32C.c @@ -0,0 +1,5946 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80188D84; +extern u8 D_80188CF4; +extern u8 D_80188CD0; +extern u8 D_80188CAC; +extern u8 D_80188D60; +extern u8 D_80188D3C; +extern u8 D_80188D18; +extern u8 D_80188C88; +extern void func_80145934(void); +extern u8 D_80188E14; +extern u8 D_80188DF0; +extern u8 D_80188DCC; +extern u8 D_80188DA8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018820C[]; +extern unsigned char D_8018823C[]; +extern unsigned char D_8018828C[]; +extern unsigned char D_801882BC[]; +extern unsigned char D_801882EC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018833C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80188404[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018848C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80188494; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C6330; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C6334; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801884C4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018856C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80188590[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80188580; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801885A4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801885B0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801885C0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801885D8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801885C8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801885EC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80188608[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801885F8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018861C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80188630[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80188644; +extern void (*D_8018866C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018864C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801886B8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801886BC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80188B20[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80188B30[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C6368; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80188B58[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80188B38; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80188B48; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80188B98[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80188BA0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80188B6C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80188BAC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80188B7C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C6370; +extern s32 D_801C637C; +extern s32 D_801C6380; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80188BE8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80188BBC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C6378; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80188E38[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80188C58[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80188EDC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80189030[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80188E4C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80189038[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80188E5C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80188E7C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80189040[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80189068[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80188EE8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80189074[])(void); + +void func_8015C714(void *a0) { + D_80189074[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80188EE8[])(void*); + extern int D_80188E8C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80188EE8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80188EE8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188E8C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80188EE8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80188EE8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80188EE8[])(void*); + extern int D_80188E8C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80188EE8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188E8C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80188EE8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80189084[])(void); + D_80189084[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80188EE8[])(struct Ent_8015CD20 *); + extern u8 D_80188E9C; + extern u8 D_8018908C; + extern u8 D_8018909C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80188EE8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188E9C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018908C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018909C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80188EE8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801890BC[])(void); + D_801890BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801890AC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801890AC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80188EE8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80189118; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80189118, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801881FC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801881FC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80189120[])(void); + D_80189120[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018912C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018912C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018912C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018912C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80188EE8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018912C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80188EAC[]; + extern u8 D_80188EBC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188EAC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188EBC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018912C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018912C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018912C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80189160[])(void); + D_80189160[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188EE8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80189168[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80189180[])(void); + D_80189180[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188EE8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80189168[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80189168[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + +extern void (*D_801891A0[])(void); + +s32 func_8015E1B8(s32 a0) +{ + D_801891A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80188EE8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188EE8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801891B0; +extern u16 D_801891B2; +extern u16 D_801891B4; +extern s32 D_801891B8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801891B0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801891B2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801891B4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801891B8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801891C0; + +void func_8015E588(void) { + func_8013C9C4(&D_801891C0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80188EE8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188EE8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801891D4[])(void); + D_801891D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80188EE8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80188EE8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801891DC[])(void); + D_801891DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80188ECC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188ECC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80188EE8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801891E4[])(void); + D_801891E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80188EE8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80188EE8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801891EC[])(void); + D_801891EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80188EE8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801891F4; + extern s32 D_80189204; + extern s32 D_80189214; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801891F4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189204); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80188EE8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189214); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80189224[])(void); + D_80189224[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80188EE8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80188EE8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80188EE8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188EE8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80189230[])(void); + D_80189230[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80188EE8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188EE8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80188EE8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188EE8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80189244[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80189244[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80188EE8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80188EE8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80188EE8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188EE8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801892C0[])(void); + D_801892C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80188EE8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80188EE8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801892D0[])(void); + D_801892D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80188EE8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80188EE8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80188EE8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80188EE8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80188EE8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80188EE8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80188EE8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801892D8[])(void); + D_801892D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80188EE8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80188EE8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80188EE8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80188EE8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801892E4[])(void); + D_801892E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188EE8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80188EE8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80188EE8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80188EE8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801892F4[])(void); + +void func_80160EA4(void *a0) { + D_801892F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80188EE8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80188EE8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80189324[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80189324[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80189388; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80189388); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C6388[]; + extern u8 D_80189354[]; + extern u8 D_80189374[]; + extern u8 D_801C6394[]; + extern u8 D_801C63BC[]; + extern u8 D_801C63D4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C6388[0] = p; + func_80024054(&D_80189354, &D_801C6394); + func_8001CE28(p, &D_801C6394); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C6388[1] = p; + func_80024054(&D_80189374, &D_801C63BC); + func_8001CE28(p, &D_801C63BC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C6388[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C63D4, 0x84); + func_8001CE68(p, &D_801C63D4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C63D4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C6388[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C6388; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80189388; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80189388; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80189388; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80189388; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C6388[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C6388; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801893AC[])(void); + +void func_80162330(void *a0) { + D_801893AC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C63E0[i] via `extern int D_801C63E0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801893B8[]; + extern s32 D_801893D0; + extern u8 D_801C63EC[]; + extern u8 D_801C6414[]; + extern u8 D_801C6430[]; + extern int D_801C63E0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C63E0[0] = (s32)item; + func_80024054(D_801893B8, D_801C63EC); + func_8001CE28(item, D_801C63EC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C63E0[1] = (s32)item; + func_80024054(((u8 *)&D_801893D0), D_801C6414); + func_8001CE28(item, D_801C6414); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C63E0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C6430, 0x84); + func_8001CE68(item, D_801C6430); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C6430, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C63E0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C63E0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_801627E8); + + +extern void (*D_801893F4[])(void); + +void func_80162834(void *a0) { + D_801893F4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801893E4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801893E4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C5B60[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C5B60, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C5B60[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C5B60, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801893FC[])(void); + +void func_80163A58(void *a0) { + D_801893FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C5B68; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C5B68; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80189450[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80189450[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80189418; +extern s16 D_8018944C; +extern s16 D_8018944A; +extern s16 D_80189448; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80189418; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018944C = 0x80; + D_8018944A = 0x80; + D_80189448 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018944C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018944C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018944C - 8; + D_8018944C = nv; + D_8018944A = nv; + D_80189448 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018945C[])(void); + +void func_80164BA0(void *a0) { + D_8018945C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C6440; +extern u8 D_801C6441; +extern u8 D_801C6442; +extern u8 D_801C6443; +extern u8 D_801C6444; +extern u8 D_801C6445; +extern u8 D_801C6446; +extern u8 D_801C6447; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C6440; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C6441 = 0xf0; + *(u8 *)base = 0xf0; + D_801C6442 = 0xc0; + D_801C6446 = 0; + D_801C6445 = 0; + D_801C6444 = 0; + D_801C6447 = 0; + D_801C6443 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C6440; +extern u8 D_801C6441; +extern u8 D_801C6442; + +s32 func_80164E40(void) { + u8 *p = &D_801C6440; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C6441 != 0) { + D_801C6441 -= 0x10; + } + if (D_801C6442 != 0) { + D_801C6442 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018946C[])(void); + +void func_80164EA4(void *a0) { + D_8018946C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C648C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C648C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C6480[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C6480[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C6480[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C6480; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C6480; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80189480[]; + extern u32 D_801894A0, D_801894A4, D_801894A8, D_801894AC; + extern u32 D_801894A0, D_801894A4, D_801894A8, D_801894AC; + extern u32 D_801894A0, D_801894A4, D_801894A8, D_801894AC; + extern u32 D_801894A0, D_801894A4, D_801894A8, D_801894AC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80189480[0x00], p); + ApplyMatrixSV(mat, &D_80189480[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80189480[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80189480[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801894A8; + *(u32 *)(prim + 0x24) = D_801894A0; + *(u32 *)(prim + 0x28) = D_801894AC; + *(u32 *)(prim + 0x2c) = D_801894A4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801894B0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801894B0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801894B0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801894B0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018952C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018952C[a1 & 0x7F]; +} + + + +extern s32 D_8018954C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018954C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801895C8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801895C8[a1 & 0x7F]; +} + + + +extern u8 D_801895E8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801895E8[a1 & 0x7F]; +} + + + +extern u8 D_80189608[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80189608[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80189628[])(void); + D_80189628[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801896A4[])(void); + +void func_80165AC8(void) { + D_801896A4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80189720[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80189720[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C5B70; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C5B70, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018972C[])(void); + +void func_80166018(void *a0) { + D_8018972C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80189734[])(void); + +void func_801663FC(void *a0) { + D_80189734[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801897FC[])(void); + +void func_80166618(void *a0) { + D_801897FC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018980C[])(void); + +void func_80166654(void *a0) { + D_8018980C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C6500[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C6500[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C6500). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C6500[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C6500)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C6500[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C6500[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80189750[]; + extern u8 D_8018973C[]; + extern u8 D_80189764[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80189750; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018973C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80189764; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80167714); + + +extern void (*D_8018981C[])(void); + +void func_801678B4(void *a0) { + D_8018981C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80189828[])(void); + +void func_80167A9C(void *a0) { + D_80189828[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80189934; + extern u8 D_80189948[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80189934); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80189948; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80189788[]; +extern u8 D_8018979C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80189788; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018979C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80189840[])(void); + +void func_80168744(void *a0) { + D_80189840[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80189830 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80189830[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80189830; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80189848[])(void); + +void func_801689D8(void *a0) { + D_80189848[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80189850[])(void); + +void func_80168AA8(void *a0) { + D_80189850[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80189858[])(void); + +void func_80168D58(void *a0) { + D_80189858[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80189860[])(void); + +void func_8016901C(void *a0) { + D_80189860[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC01_084/nonmatchings/ov_SC01_084_jr_8015C32C", func_80169228); + + +extern void (*D_80189868[])(void); + +void func_801693CC(void *a0) { + D_80189868[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80189870[])(void); + +void func_80169830(void *a0) { + D_80189870[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80189924[])(void); + +void func_80169B80(void *a0) { + D_80189924[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80189878[]; + extern u8 D_801898E8[]; + extern u8 D_80189918[]; + extern u8 D_801C7768[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80189918, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80189878[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C7768; + RotMatrixYXZ(rot, D_801C7768); + func_80048D9C(D_801C7768, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801898E8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018992C[])(void); + +void func_80169F00(void *a0) { + D_8018992C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801898DC[]; +extern char D_8018989C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801898DC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018989C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80189964[])(void); + +void func_8016A020(void *a0) { + D_80189964[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80189934; + extern u8 D_80189948[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80189934); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80189948; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80189970[])(void); + +void func_8016A700(void *a0) { + D_80189970[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801899B8[])(void); + +void func_8016AB30(void *a0) { + D_801899B8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_000/ov_SC02_000_jr_8015AE2C.c b/src/ov_SC02_000/ov_SC02_000_jr_8015AE2C.c index cc79e8654..05f06cbec 100644 --- a/src/ov_SC02_000/ov_SC02_000_jr_8015AE2C.c +++ b/src/ov_SC02_000/ov_SC02_000_jr_8015AE2C.c @@ -1642,4588 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018D424[])(void); - -void func_8015C714(void *a0) { - D_8018D424[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018D298[])(void*); - extern int D_8018D23C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D23C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018D298[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018D298[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018D298[])(void*); - extern int D_8018D23C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D23C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018D434[])(void); - D_8018D434[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018D298[])(struct Ent_8015CD20 *); - extern u8 D_8018D24C; - extern u8 D_8018D43C; - extern u8 D_8018D44C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018D298[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D24C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D43C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D44C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018D298[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018D46C[])(void); - D_8018D46C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018D45C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018D45C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018D298[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018D4C8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018D4C8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018C5AC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018C5AC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018D4D0[])(void); - D_8018D4D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018D4DC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018D4DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018D4DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018D4DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018D298[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018D4DC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018D25C[]; - extern u8 D_8018D26C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D25C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D26C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018D510[])(void); - D_8018D510[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D298[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018D518[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018D530[])(void); - D_8018D530[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D298[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018D518[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018D550[])(void); - D_8018D550[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018D298[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D298)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018D560; -extern u16 D_8018D562; -extern u16 D_8018D564; -extern s32 D_8018D568; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018D560 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018D562 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018D564 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018D568, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - -extern s32 func_8013C9C4(s32 *a0); -void func_8015E588(void) { - - extern s32 D_8018D570; - func_8013C9C4(&D_8018D570); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018D298[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D298)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018D584[])(void); - D_8018D584[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018D298[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018D298[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018D58C[])(void); - D_8018D58C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018D27C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D27C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018D298[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018D594[])(void); - D_8018D594[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018D298[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018D298[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018D59C[])(void); - D_8018D59C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018D298[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018D5A4; - extern s32 D_8018D5B4; - extern s32 D_8018D5C4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018D298[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5A4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5B4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018D298[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5C4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018D5D4[])(void); - D_8018D5D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018D298[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018D298[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018D5E0[])(void); - D_8018D5E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018D298[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018D298[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D298[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018D5F4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018D5F4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018D298[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018D298)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018D298[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D298[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018D670[])(void); - D_8018D670[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018D298[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018D298)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018D680[])(void); - D_8018D680[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018D298[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018D298[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018D298[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018D298[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018D298[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018D298[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018D298[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018D688[])(void); - D_8018D688[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018D298[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018D298)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018D298[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018D694[])(void); - D_8018D694[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D298 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018D298[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018D298[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018D298[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018D6A4[])(void); - -void func_80160EA4(void *a0) { - D_8018D6A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018D298[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018D298[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018D6D4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018D6D4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018D738; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018D738); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E6EB8[]; - extern u8 D_8018D704[]; - extern u8 D_8018D724[]; - extern u8 D_801E6EC4[]; - extern u8 D_801E6EEC[]; - extern u8 D_801E6F04[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E6EB8[0] = p; - func_80024054(&D_8018D704, &D_801E6EC4); - func_8001CE28(p, &D_801E6EC4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E6EB8[1] = p; - func_80024054(&D_8018D724, &D_801E6EEC); - func_8001CE28(p, &D_801E6EEC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E6EB8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E6F04, 0x84); - func_8001CE68(p, &D_801E6F04); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E6F04, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E6EB8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E6EB8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018D738; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018D738; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018D738; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018D738; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E6EB8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E6EB8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018D75C[])(void); - -void func_80162330(void *a0) { - D_8018D75C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E6F10[i] via `extern int D_801E6F10[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018D768[]; - extern s32 D_8018D780; - extern u8 D_801E6F1C[]; - extern u8 D_801E6F44[]; - extern u8 D_801E6F60[]; - extern int D_801E6F10[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E6F10[0] = (s32)item; - func_80024054(D_8018D768, D_801E6F1C); - func_8001CE28(item, D_801E6F1C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E6F10[1] = (s32)item; - func_80024054(((u8 *)&D_8018D780), D_801E6F44); - func_8001CE28(item, D_801E6F44); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E6F10[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E6F60, 0x84); - func_8001CE68(item, D_801E6F60); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E6F60, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E6F10[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E6F10; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018D7A4[])(void); - -void func_80162834(void *a0) { - D_8018D7A4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018D794; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018D794, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E63B4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E63B4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E63B4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E63B4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018D7AC[])(void); - -void func_80163A58(void *a0) { - D_8018D7AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E63BC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E63BC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018D800[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018D800[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018D7C8; -extern s16 D_8018D7FC; -extern s16 D_8018D7FA; -extern s16 D_8018D7F8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018D7C8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018D7FC = 0x80; - D_8018D7FA = 0x80; - D_8018D7F8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018D7FC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D7FC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018D7FC - 8; - D_8018D7FC = nv; - D_8018D7FA = nv; - D_8018D7F8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018D80C[])(void); - -void func_80164BA0(void *a0) { - D_8018D80C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E6F70; -extern u8 D_801E6F71; -extern u8 D_801E6F72; -extern u8 D_801E6F73; -extern u8 D_801E6F74; -extern u8 D_801E6F75; -extern u8 D_801E6F76; -extern u8 D_801E6F77; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E6F70; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E6F71 = 0xf0; - *(u8 *)base = 0xf0; - D_801E6F72 = 0xc0; - D_801E6F76 = 0; - D_801E6F75 = 0; - D_801E6F74 = 0; - D_801E6F77 = 0; - D_801E6F73 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E6F70; -extern u8 D_801E6F71; -extern u8 D_801E6F72; - -s32 func_80164E40(void) { - u8 *p = &D_801E6F70; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E6F71 != 0) { - D_801E6F71 -= 0x10; - } - if (D_801E6F72 != 0) { - D_801E6F72 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018D81C[])(void); - -void func_80164EA4(void *a0) { - D_8018D81C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E6FBC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E6FBC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E6FB0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E6FB0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E6FB0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E6FB0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E6FB0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018D830[]; - extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; - extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; - extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; - extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018D830[0x00], p); - ApplyMatrixSV(mat, &D_8018D830[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018D830[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018D830[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018D858; - *(u32 *)(prim + 0x24) = D_8018D850; - *(u32 *)(prim + 0x28) = D_8018D85C; - *(u32 *)(prim + 0x2c) = D_8018D854; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018D860[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018D860[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018D860[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018D860[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018D8DC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018D8DC[a1 & 0x7F]; -} - - - -extern s32 D_8018D8FC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018D8FC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018D978[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018D978[a1 & 0x7F]; -} - - - -extern u8 D_8018D998[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018D998[a1 & 0x7F]; -} - - - -extern u8 D_8018D9B8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018D9B8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018D9D8[])(void); - D_8018D9D8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018DA54[])(void); - -void func_80165AC8(void) { - D_8018DA54[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018DAD0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018DAD0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E63C4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E63C4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018DADC[])(void); - -void func_80166018(void *a0) { - D_8018DADC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018DAE4[])(void); - -void func_801663FC(void *a0) { - D_8018DAE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018DBAC[])(void); - -void func_80166618(void *a0) { - D_8018DBAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018DBBC[])(void); - -void func_80166654(void *a0) { - D_8018DBBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E7030[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E7030[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E7030). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E7030[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E7030)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E7030[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E7030[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018DB00[]; - extern u8 D_8018DAEC[]; - extern u8 D_8018DB14[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018DB00; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018DAEC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018DB14; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80167714); - - -extern void (*D_8018DBCC[])(void); - -void func_801678B4(void *a0) { - D_8018DBCC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018DBD8[])(void); - -void func_80167A9C(void *a0) { - D_8018DBD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018DCE4; - extern u8 D_8018DCF8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018DCE4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018DCF8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018DB38[]; -extern u8 D_8018DB4C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018DB38; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018DB4C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018DBF0[])(void); - -void func_80168744(void *a0) { - D_8018DBF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018DBE0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018DBE0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018DBE0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018DBF8[])(void); - -void func_801689D8(void *a0) { - D_8018DBF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018DC00[])(void); - -void func_80168AA8(void *a0) { - D_8018DC00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018DC08[])(void); - -void func_80168D58(void *a0) { - D_8018DC08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018DC10[])(void); - -void func_8016901C(void *a0) { - D_8018DC10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015AE2C", func_80169228); - - -extern void (*D_8018DC18[])(void); - -void func_801693CC(void *a0) { - D_8018DC18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018DC20[])(void); - -void func_80169830(void *a0) { - D_8018DC20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018DCD4[])(void); - -void func_80169B80(void *a0) { - D_8018DCD4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018DC28[]; - extern u8 D_8018DC98[]; - extern u8 D_8018DCC8[]; - extern u8 D_801E8698[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018DCC8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018DC28[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801E8698; - RotMatrixYXZ(rot, D_801E8698); - func_80048D9C(D_801E8698, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018DC98); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018DCDC[])(void); - -void func_80169F00(void *a0) { - D_8018DCDC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018DC8C[]; -extern char D_8018DC4C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018DC8C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018DC4C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018DD14[])(void); - -void func_8016A020(void *a0) { - D_8018DD14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018DCE4; - extern u8 D_8018DCF8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018DCE4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018DCF8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018DD20[])(void); - -void func_8016A700(void *a0) { - D_8018DD20[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018DD68[])(void); - -void func_8016AB30(void *a0) { - D_8018DD68[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c b/src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c new file mode 100644 index 000000000..33b4f0ebe --- /dev/null +++ b/src/ov_SC02_000/ov_SC02_000_jr_8015C32C.c @@ -0,0 +1,5945 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018D134; +extern u8 D_8018D0A4; +extern u8 D_8018D080; +extern u8 D_8018D05C; +extern u8 D_8018D110; +extern u8 D_8018D0EC; +extern u8 D_8018D0C8; +extern u8 D_8018D038; +extern void func_80145934(void); +extern u8 D_8018D1C4; +extern u8 D_8018D1A0; +extern u8 D_8018D17C; +extern u8 D_8018D158; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018C5BC[]; +extern unsigned char D_8018C5EC[]; +extern unsigned char D_8018C63C[]; +extern unsigned char D_8018C66C[]; +extern unsigned char D_8018C69C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018C6EC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018C7B4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018C83C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018C844; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E6E60; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E6E64; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018C874; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018C91C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018C940[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018C930; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018C954[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018C960[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018C970[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018C988[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018C978; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018C99C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018C9B8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018C9A8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018C9CC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018C9E0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018C9F4; +extern void (*D_8018CA1C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018C9FC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018CA68[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018CA6C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018CED0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018CEE0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E6E98; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018CF08[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018CEE8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018CEF8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018CF48[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018CF50[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018CF1C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018CF5C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018CF2C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E6EA0; +extern s32 D_801E6EAC; +extern s32 D_801E6EB0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018CF98[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018CF6C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E6EA8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018D1E8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018D008[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018D28C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018D3E0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018D1FC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018D3E8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018D20C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018D22C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018D3F0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018D418[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018D298[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018D424[])(void); + +void func_8015C714(void *a0) { + D_8018D424[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018D298[])(void*); + extern int D_8018D23C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D23C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018D298[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018D298[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018D298[])(void*); + extern int D_8018D23C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D23C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018D434[])(void); + D_8018D434[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018D298[])(struct Ent_8015CD20 *); + extern u8 D_8018D24C; + extern u8 D_8018D43C; + extern u8 D_8018D44C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018D298[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D24C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D43C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D44C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018D298[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018D46C[])(void); + D_8018D46C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018D45C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018D45C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018D298[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018D4C8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018D4C8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018C5AC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018C5AC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018D4D0[])(void); + D_8018D4D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018D4DC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018D4DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018D4DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018D4DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018D298[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018D4DC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018D25C[]; + extern u8 D_8018D26C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D25C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D26C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018D510[])(void); + D_8018D510[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D298[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018D518[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018D530[])(void); + D_8018D530[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D298[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018D518[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018D550[])(void); + D_8018D550[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018D298[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D298)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018D560; +extern u16 D_8018D562; +extern u16 D_8018D564; +extern s32 D_8018D568; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018D560 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018D562 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018D564 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018D568, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + +extern s32 func_8013C9C4(s32 *a0); +void func_8015E588(void) { + + extern s32 D_8018D570; + func_8013C9C4(&D_8018D570); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018D298[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D298)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018D584[])(void); + D_8018D584[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018D298[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018D298[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018D58C[])(void); + D_8018D58C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018D27C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D27C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018D298[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018D594[])(void); + D_8018D594[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018D298[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018D298[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018D59C[])(void); + D_8018D59C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018D298[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018D5A4; + extern s32 D_8018D5B4; + extern s32 D_8018D5C4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5A4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5B4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5C4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018D5D4[])(void); + D_8018D5D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018D298[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018D298[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018D5E0[])(void); + D_8018D5E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018D298[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018D298[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D298[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018D5F4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018D5F4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018D298[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018D298)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018D298[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D298[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018D670[])(void); + D_8018D670[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018D298[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018D298)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018D680[])(void); + D_8018D680[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018D298[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018D298[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018D298[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018D298[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018D298[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018D298[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018D298[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018D688[])(void); + D_8018D688[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018D298[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018D298)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018D298[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018D694[])(void); + D_8018D694[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D298 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018D298[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018D298[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018D298[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018D6A4[])(void); + +void func_80160EA4(void *a0) { + D_8018D6A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018D298[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018D298[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018D6D4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018D6D4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018D738; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018D738); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E6EB8[]; + extern u8 D_8018D704[]; + extern u8 D_8018D724[]; + extern u8 D_801E6EC4[]; + extern u8 D_801E6EEC[]; + extern u8 D_801E6F04[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E6EB8[0] = p; + func_80024054(&D_8018D704, &D_801E6EC4); + func_8001CE28(p, &D_801E6EC4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E6EB8[1] = p; + func_80024054(&D_8018D724, &D_801E6EEC); + func_8001CE28(p, &D_801E6EEC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E6EB8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E6F04, 0x84); + func_8001CE68(p, &D_801E6F04); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E6F04, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E6EB8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E6EB8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018D738; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018D738; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018D738; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018D738; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E6EB8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E6EB8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018D75C[])(void); + +void func_80162330(void *a0) { + D_8018D75C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E6F10[i] via `extern int D_801E6F10[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018D768[]; + extern s32 D_8018D780; + extern u8 D_801E6F1C[]; + extern u8 D_801E6F44[]; + extern u8 D_801E6F60[]; + extern int D_801E6F10[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E6F10[0] = (s32)item; + func_80024054(D_8018D768, D_801E6F1C); + func_8001CE28(item, D_801E6F1C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E6F10[1] = (s32)item; + func_80024054(((u8 *)&D_8018D780), D_801E6F44); + func_8001CE28(item, D_801E6F44); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E6F10[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E6F60, 0x84); + func_8001CE68(item, D_801E6F60); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E6F60, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E6F10[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E6F10; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_801627E8); + + +extern void (*D_8018D7A4[])(void); + +void func_80162834(void *a0) { + D_8018D7A4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018D794; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018D794, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E63B4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E63B4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E63B4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E63B4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018D7AC[])(void); + +void func_80163A58(void *a0) { + D_8018D7AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E63BC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E63BC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018D800[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018D800[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018D7C8; +extern s16 D_8018D7FC; +extern s16 D_8018D7FA; +extern s16 D_8018D7F8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018D7C8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018D7FC = 0x80; + D_8018D7FA = 0x80; + D_8018D7F8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018D7FC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D7FC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018D7FC - 8; + D_8018D7FC = nv; + D_8018D7FA = nv; + D_8018D7F8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018D80C[])(void); + +void func_80164BA0(void *a0) { + D_8018D80C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E6F70; +extern u8 D_801E6F71; +extern u8 D_801E6F72; +extern u8 D_801E6F73; +extern u8 D_801E6F74; +extern u8 D_801E6F75; +extern u8 D_801E6F76; +extern u8 D_801E6F77; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E6F70; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E6F71 = 0xf0; + *(u8 *)base = 0xf0; + D_801E6F72 = 0xc0; + D_801E6F76 = 0; + D_801E6F75 = 0; + D_801E6F74 = 0; + D_801E6F77 = 0; + D_801E6F73 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E6F70; +extern u8 D_801E6F71; +extern u8 D_801E6F72; + +s32 func_80164E40(void) { + u8 *p = &D_801E6F70; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E6F71 != 0) { + D_801E6F71 -= 0x10; + } + if (D_801E6F72 != 0) { + D_801E6F72 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018D81C[])(void); + +void func_80164EA4(void *a0) { + D_8018D81C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E6FBC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E6FBC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E6FB0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E6FB0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E6FB0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E6FB0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E6FB0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018D830[]; + extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; + extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; + extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; + extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018D830[0x00], p); + ApplyMatrixSV(mat, &D_8018D830[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018D830[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018D830[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018D858; + *(u32 *)(prim + 0x24) = D_8018D850; + *(u32 *)(prim + 0x28) = D_8018D85C; + *(u32 *)(prim + 0x2c) = D_8018D854; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018D860[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018D860[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018D860[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018D860[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018D8DC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018D8DC[a1 & 0x7F]; +} + + + +extern s32 D_8018D8FC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018D8FC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018D978[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018D978[a1 & 0x7F]; +} + + + +extern u8 D_8018D998[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018D998[a1 & 0x7F]; +} + + + +extern u8 D_8018D9B8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018D9B8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018D9D8[])(void); + D_8018D9D8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018DA54[])(void); + +void func_80165AC8(void) { + D_8018DA54[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018DAD0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018DAD0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E63C4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E63C4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018DADC[])(void); + +void func_80166018(void *a0) { + D_8018DADC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018DAE4[])(void); + +void func_801663FC(void *a0) { + D_8018DAE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018DBAC[])(void); + +void func_80166618(void *a0) { + D_8018DBAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018DBBC[])(void); + +void func_80166654(void *a0) { + D_8018DBBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E7030[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E7030[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E7030). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E7030[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E7030)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E7030[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E7030[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018DB00[]; + extern u8 D_8018DAEC[]; + extern u8 D_8018DB14[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018DB00; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018DAEC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018DB14; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80167714); + + +extern void (*D_8018DBCC[])(void); + +void func_801678B4(void *a0) { + D_8018DBCC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018DBD8[])(void); + +void func_80167A9C(void *a0) { + D_8018DBD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018DCE4; + extern u8 D_8018DCF8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018DCE4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018DCF8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018DB38[]; +extern u8 D_8018DB4C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018DB38; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018DB4C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018DBF0[])(void); + +void func_80168744(void *a0) { + D_8018DBF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018DBE0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018DBE0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018DBE0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018DBF8[])(void); + +void func_801689D8(void *a0) { + D_8018DBF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018DC00[])(void); + +void func_80168AA8(void *a0) { + D_8018DC00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018DC08[])(void); + +void func_80168D58(void *a0) { + D_8018DC08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018DC10[])(void); + +void func_8016901C(void *a0) { + D_8018DC10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_000/nonmatchings/ov_SC02_000_jr_8015C32C", func_80169228); + + +extern void (*D_8018DC18[])(void); + +void func_801693CC(void *a0) { + D_8018DC18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018DC20[])(void); + +void func_80169830(void *a0) { + D_8018DC20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018DCD4[])(void); + +void func_80169B80(void *a0) { + D_8018DCD4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018DC28[]; + extern u8 D_8018DC98[]; + extern u8 D_8018DCC8[]; + extern u8 D_801E8698[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018DCC8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018DC28[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801E8698; + RotMatrixYXZ(rot, D_801E8698); + func_80048D9C(D_801E8698, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018DC98); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018DCDC[])(void); + +void func_80169F00(void *a0) { + D_8018DCDC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018DC8C[]; +extern char D_8018DC4C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018DC8C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018DC4C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018DD14[])(void); + +void func_8016A020(void *a0) { + D_8018DD14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018DCE4; + extern u8 D_8018DCF8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018DCE4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018DCF8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018DD20[])(void); + +void func_8016A700(void *a0) { + D_8018DD20[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018DD68[])(void); + +void func_8016AB30(void *a0) { + D_8018DD68[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_003/ov_SC02_003_jr_8015AE2C.c b/src/ov_SC02_003/ov_SC02_003_jr_8015AE2C.c index 758cb3d39..d91821d60 100644 --- a/src/ov_SC02_003/ov_SC02_003_jr_8015AE2C.c +++ b/src/ov_SC02_003/ov_SC02_003_jr_8015AE2C.c @@ -1642,4588 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018D424[])(void); - -void func_8015C714(void *a0) { - D_8018D424[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018D298[])(void*); - extern int D_8018D23C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D23C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018D298[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018D298[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018D298[])(void*); - extern int D_8018D23C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D23C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018D434[])(void); - D_8018D434[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018D298[])(struct Ent_8015CD20 *); - extern u8 D_8018D24C; - extern u8 D_8018D43C; - extern u8 D_8018D44C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018D298[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D24C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D43C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D44C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018D298[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018D46C[])(void); - D_8018D46C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018D45C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018D45C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018D298[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018D4C8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018D4C8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018C5AC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018C5AC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018D4D0[])(void); - D_8018D4D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018D4DC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018D4DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018D4DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018D4DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018D298[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018D4DC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018D25C[]; - extern u8 D_8018D26C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D25C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D26C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018D510[])(void); - D_8018D510[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D298[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018D518[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018D530[])(void); - D_8018D530[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D298[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018D518[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018D550[])(void); - D_8018D550[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018D298[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D298)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018D560; -extern u16 D_8018D562; -extern u16 D_8018D564; -extern s32 D_8018D568; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018D560 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018D562 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018D564 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018D568, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - -extern s32 func_8013C9C4(s32 *a0); -void func_8015E588(void) { - - extern s32 D_8018D570; - func_8013C9C4(&D_8018D570); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018D298[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D298)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018D584[])(void); - D_8018D584[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018D298[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018D298[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018D58C[])(void); - D_8018D58C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018D27C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D27C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018D298[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018D594[])(void); - D_8018D594[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018D298[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018D298[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018D59C[])(void); - D_8018D59C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018D298[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018D5A4; - extern s32 D_8018D5B4; - extern s32 D_8018D5C4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018D298[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5A4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5B4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018D298[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5C4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018D5D4[])(void); - D_8018D5D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018D298[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018D298[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D298[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018D5E0[])(void); - D_8018D5E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018D298[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D298[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018D298[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D298[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018D5F4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018D5F4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018D298[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018D298)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018D298[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D298[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018D670[])(void); - D_8018D670[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018D298[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018D298)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018D680[])(void); - D_8018D680[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018D298[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018D298[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018D298[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018D298[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018D298[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018D298[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018D298[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018D688[])(void); - D_8018D688[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018D298[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018D298)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018D298[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018D298)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018D694[])(void); - D_8018D694[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D298 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018D298[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018D298[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018D298[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018D6A4[])(void); - -void func_80160EA4(void *a0) { - D_8018D6A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018D298[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018D298[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018D6D4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018D6D4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018D738; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018D738); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E6EB8[]; - extern u8 D_8018D704[]; - extern u8 D_8018D724[]; - extern u8 D_801E6EC4[]; - extern u8 D_801E6EEC[]; - extern u8 D_801E6F04[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E6EB8[0] = p; - func_80024054(&D_8018D704, &D_801E6EC4); - func_8001CE28(p, &D_801E6EC4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E6EB8[1] = p; - func_80024054(&D_8018D724, &D_801E6EEC); - func_8001CE28(p, &D_801E6EEC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E6EB8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E6F04, 0x84); - func_8001CE68(p, &D_801E6F04); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E6F04, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E6EB8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E6EB8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018D738; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018D738; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018D738; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018D738; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E6EB8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E6EB8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018D75C[])(void); - -void func_80162330(void *a0) { - D_8018D75C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E6F10[i] via `extern int D_801E6F10[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018D768[]; - extern s32 D_8018D780; - extern u8 D_801E6F1C[]; - extern u8 D_801E6F44[]; - extern u8 D_801E6F60[]; - extern int D_801E6F10[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E6F10[0] = (s32)item; - func_80024054(D_8018D768, D_801E6F1C); - func_8001CE28(item, D_801E6F1C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E6F10[1] = (s32)item; - func_80024054(((u8 *)&D_8018D780), D_801E6F44); - func_8001CE28(item, D_801E6F44); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E6F10[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E6F60, 0x84); - func_8001CE68(item, D_801E6F60); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E6F60, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E6F10[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E6F10; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018D7A4[])(void); - -void func_80162834(void *a0) { - D_8018D7A4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018D794; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018D794, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E63B4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E63B4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E63B4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E63B4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018D7AC[])(void); - -void func_80163A58(void *a0) { - D_8018D7AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E63BC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E63BC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018D800[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018D800[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018D7C8; -extern s16 D_8018D7FC; -extern s16 D_8018D7FA; -extern s16 D_8018D7F8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018D7C8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018D7FC = 0x80; - D_8018D7FA = 0x80; - D_8018D7F8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018D7FC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D7FC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018D7FC - 8; - D_8018D7FC = nv; - D_8018D7FA = nv; - D_8018D7F8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018D80C[])(void); - -void func_80164BA0(void *a0) { - D_8018D80C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E6F70; -extern u8 D_801E6F71; -extern u8 D_801E6F72; -extern u8 D_801E6F73; -extern u8 D_801E6F74; -extern u8 D_801E6F75; -extern u8 D_801E6F76; -extern u8 D_801E6F77; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E6F70; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E6F71 = 0xf0; - *(u8 *)base = 0xf0; - D_801E6F72 = 0xc0; - D_801E6F76 = 0; - D_801E6F75 = 0; - D_801E6F74 = 0; - D_801E6F77 = 0; - D_801E6F73 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E6F70; -extern u8 D_801E6F71; -extern u8 D_801E6F72; - -s32 func_80164E40(void) { - u8 *p = &D_801E6F70; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E6F71 != 0) { - D_801E6F71 -= 0x10; - } - if (D_801E6F72 != 0) { - D_801E6F72 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018D81C[])(void); - -void func_80164EA4(void *a0) { - D_8018D81C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E6FBC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E6FBC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E6FB0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E6FB0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E6FB0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E6FB0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E6FB0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018D830[]; - extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; - extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; - extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; - extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018D830[0x00], p); - ApplyMatrixSV(mat, &D_8018D830[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018D830[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018D830[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018D858; - *(u32 *)(prim + 0x24) = D_8018D850; - *(u32 *)(prim + 0x28) = D_8018D85C; - *(u32 *)(prim + 0x2c) = D_8018D854; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018D860[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018D860[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018D860[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018D860[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018D8DC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018D8DC[a1 & 0x7F]; -} - - - -extern s32 D_8018D8FC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018D8FC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018D978[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018D978[a1 & 0x7F]; -} - - - -extern u8 D_8018D998[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018D998[a1 & 0x7F]; -} - - - -extern u8 D_8018D9B8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018D9B8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018D9D8[])(void); - D_8018D9D8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018DA54[])(void); - -void func_80165AC8(void) { - D_8018DA54[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018DAD0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018DAD0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E63C4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E63C4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018DADC[])(void); - -void func_80166018(void *a0) { - D_8018DADC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018DAE4[])(void); - -void func_801663FC(void *a0) { - D_8018DAE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018DBAC[])(void); - -void func_80166618(void *a0) { - D_8018DBAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018DBBC[])(void); - -void func_80166654(void *a0) { - D_8018DBBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E7030[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E7030[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E7030). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E7030[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E7030)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E7030[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E7030[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018DB00[]; - extern u8 D_8018DAEC[]; - extern u8 D_8018DB14[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018DB00; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018DAEC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018DB14; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80167714); - - -extern void (*D_8018DBCC[])(void); - -void func_801678B4(void *a0) { - D_8018DBCC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018DBD8[])(void); - -void func_80167A9C(void *a0) { - D_8018DBD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018DCE4; - extern u8 D_8018DCF8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018DCE4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018DCF8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018DB38[]; -extern u8 D_8018DB4C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018DB38; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018DB4C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018DBF0[])(void); - -void func_80168744(void *a0) { - D_8018DBF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018DBE0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018DBE0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018DBE0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018DBF8[])(void); - -void func_801689D8(void *a0) { - D_8018DBF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018DC00[])(void); - -void func_80168AA8(void *a0) { - D_8018DC00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018DC08[])(void); - -void func_80168D58(void *a0) { - D_8018DC08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018DC10[])(void); - -void func_8016901C(void *a0) { - D_8018DC10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015AE2C", func_80169228); - - -extern void (*D_8018DC18[])(void); - -void func_801693CC(void *a0) { - D_8018DC18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018DC20[])(void); - -void func_80169830(void *a0) { - D_8018DC20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018DCD4[])(void); - -void func_80169B80(void *a0) { - D_8018DCD4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018DC28[]; - extern u8 D_8018DC98[]; - extern u8 D_8018DCC8[]; - extern u8 D_801E8698[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018DCC8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018DC28[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801E8698; - RotMatrixYXZ(rot, D_801E8698); - func_80048D9C(D_801E8698, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018DC98); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018DCDC[])(void); - -void func_80169F00(void *a0) { - D_8018DCDC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018DC8C[]; -extern char D_8018DC4C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018DC8C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018DC4C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018DD14[])(void); - -void func_8016A020(void *a0) { - D_8018DD14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018DCE4; - extern u8 D_8018DCF8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018DCE4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018DCF8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018DD20[])(void); - -void func_8016A700(void *a0) { - D_8018DD20[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018DD68[])(void); - -void func_8016AB30(void *a0) { - D_8018DD68[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c b/src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c new file mode 100644 index 000000000..b29409f5e --- /dev/null +++ b/src/ov_SC02_003/ov_SC02_003_jr_8015C32C.c @@ -0,0 +1,5945 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018D134; +extern u8 D_8018D0A4; +extern u8 D_8018D080; +extern u8 D_8018D05C; +extern u8 D_8018D110; +extern u8 D_8018D0EC; +extern u8 D_8018D0C8; +extern u8 D_8018D038; +extern void func_80145934(void); +extern u8 D_8018D1C4; +extern u8 D_8018D1A0; +extern u8 D_8018D17C; +extern u8 D_8018D158; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018C5BC[]; +extern unsigned char D_8018C5EC[]; +extern unsigned char D_8018C63C[]; +extern unsigned char D_8018C66C[]; +extern unsigned char D_8018C69C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018C6EC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018C7B4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018C83C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018C844; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E6E60; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E6E64; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018C874; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018C91C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018C940[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018C930; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018C954[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018C960[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018C970[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018C988[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018C978; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018C99C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018C9B8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018C9A8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018C9CC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018C9E0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018C9F4; +extern void (*D_8018CA1C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018C9FC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018CA68[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018CA6C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018CED0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018CEE0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E6E98; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018CF08[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018CEE8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018CEF8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018CF48[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018CF50[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018CF1C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018CF5C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018CF2C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E6EA0; +extern s32 D_801E6EAC; +extern s32 D_801E6EB0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018CF98[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018CF6C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E6EA8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018D1E8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018D008[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018D28C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018D3E0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018D1FC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018D3E8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018D20C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018D22C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018D3F0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018D418[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018D298[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018D424[])(void); + +void func_8015C714(void *a0) { + D_8018D424[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018D298[])(void*); + extern int D_8018D23C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D23C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018D298[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018D298[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018D298[])(void*); + extern int D_8018D23C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D23C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018D434[])(void); + D_8018D434[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018D298[])(struct Ent_8015CD20 *); + extern u8 D_8018D24C; + extern u8 D_8018D43C; + extern u8 D_8018D44C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018D298[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D24C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D43C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D44C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018D298[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018D46C[])(void); + D_8018D46C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018D45C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018D45C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018D298[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018D4C8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018D4C8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018C5AC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018C5AC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018D4D0[])(void); + D_8018D4D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018D4DC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018D4DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018D4DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018D4DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018D298[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018D4DC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018D25C[]; + extern u8 D_8018D26C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D25C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D26C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018D4DC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018D510[])(void); + D_8018D510[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D298[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018D518[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018D530[])(void); + D_8018D530[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D298[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018D518[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018D518[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018D550[])(void); + D_8018D550[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018D298[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D298)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018D560; +extern u16 D_8018D562; +extern u16 D_8018D564; +extern s32 D_8018D568; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018D560 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018D562 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018D564 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018D568, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + +extern s32 func_8013C9C4(s32 *a0); +void func_8015E588(void) { + + extern s32 D_8018D570; + func_8013C9C4(&D_8018D570); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018D298[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D298)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018D584[])(void); + D_8018D584[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018D298[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018D298[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018D58C[])(void); + D_8018D58C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018D27C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D27C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018D298[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018D594[])(void); + D_8018D594[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018D298[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018D298[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018D59C[])(void); + D_8018D59C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018D298[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018D5A4; + extern s32 D_8018D5B4; + extern s32 D_8018D5C4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5A4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5B4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018D298[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D5C4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018D5D4[])(void); + D_8018D5D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018D298[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018D298[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D298[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018D5E0[])(void); + D_8018D5E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018D298[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D298[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018D298[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D298[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018D5F4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018D5F4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018D298[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018D298)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018D298[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D298[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018D670[])(void); + D_8018D670[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018D298[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018D298)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018D680[])(void); + D_8018D680[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018D298[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018D298[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018D298[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018D298[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018D298[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018D298[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018D298[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018D688[])(void); + D_8018D688[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018D298[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018D298)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018D298[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018D298)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018D694[])(void); + D_8018D694[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D298 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018D298[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018D298[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018D298[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018D6A4[])(void); + +void func_80160EA4(void *a0) { + D_8018D6A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018D298[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018D298[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018D6D4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018D6D4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018D738; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018D738); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E6EB8[]; + extern u8 D_8018D704[]; + extern u8 D_8018D724[]; + extern u8 D_801E6EC4[]; + extern u8 D_801E6EEC[]; + extern u8 D_801E6F04[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E6EB8[0] = p; + func_80024054(&D_8018D704, &D_801E6EC4); + func_8001CE28(p, &D_801E6EC4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E6EB8[1] = p; + func_80024054(&D_8018D724, &D_801E6EEC); + func_8001CE28(p, &D_801E6EEC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E6EB8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E6F04, 0x84); + func_8001CE68(p, &D_801E6F04); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E6F04, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E6EB8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E6EB8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018D738; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018D738; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018D738; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018D738; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E6EB8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E6EB8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018D75C[])(void); + +void func_80162330(void *a0) { + D_8018D75C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E6F10[i] via `extern int D_801E6F10[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018D768[]; + extern s32 D_8018D780; + extern u8 D_801E6F1C[]; + extern u8 D_801E6F44[]; + extern u8 D_801E6F60[]; + extern int D_801E6F10[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E6F10[0] = (s32)item; + func_80024054(D_8018D768, D_801E6F1C); + func_8001CE28(item, D_801E6F1C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E6F10[1] = (s32)item; + func_80024054(((u8 *)&D_8018D780), D_801E6F44); + func_8001CE28(item, D_801E6F44); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E6F10[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E6F60, 0x84); + func_8001CE68(item, D_801E6F60); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E6F60, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E6F10[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E6F10; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_801627E8); + + +extern void (*D_8018D7A4[])(void); + +void func_80162834(void *a0) { + D_8018D7A4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018D794; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018D794, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E63B4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E63B4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E63B4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E63B4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018D7AC[])(void); + +void func_80163A58(void *a0) { + D_8018D7AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E63BC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E63BC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018D800[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018D800[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018D7C8; +extern s16 D_8018D7FC; +extern s16 D_8018D7FA; +extern s16 D_8018D7F8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018D7C8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018D7FC = 0x80; + D_8018D7FA = 0x80; + D_8018D7F8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018D7FC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D7FC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018D7FC - 8; + D_8018D7FC = nv; + D_8018D7FA = nv; + D_8018D7F8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018D80C[])(void); + +void func_80164BA0(void *a0) { + D_8018D80C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E6F70; +extern u8 D_801E6F71; +extern u8 D_801E6F72; +extern u8 D_801E6F73; +extern u8 D_801E6F74; +extern u8 D_801E6F75; +extern u8 D_801E6F76; +extern u8 D_801E6F77; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E6F70; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E6F71 = 0xf0; + *(u8 *)base = 0xf0; + D_801E6F72 = 0xc0; + D_801E6F76 = 0; + D_801E6F75 = 0; + D_801E6F74 = 0; + D_801E6F77 = 0; + D_801E6F73 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E6F70; +extern u8 D_801E6F71; +extern u8 D_801E6F72; + +s32 func_80164E40(void) { + u8 *p = &D_801E6F70; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E6F71 != 0) { + D_801E6F71 -= 0x10; + } + if (D_801E6F72 != 0) { + D_801E6F72 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018D81C[])(void); + +void func_80164EA4(void *a0) { + D_8018D81C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E6FBC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E6FBC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E6FB0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E6FB0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E6FB0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E6FB0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E6FB0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018D830[]; + extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; + extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; + extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; + extern u32 D_8018D850, D_8018D854, D_8018D858, D_8018D85C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018D830[0x00], p); + ApplyMatrixSV(mat, &D_8018D830[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018D830[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018D830[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018D858; + *(u32 *)(prim + 0x24) = D_8018D850; + *(u32 *)(prim + 0x28) = D_8018D85C; + *(u32 *)(prim + 0x2c) = D_8018D854; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018D860[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018D860[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018D860[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018D860[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018D8DC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018D8DC[a1 & 0x7F]; +} + + + +extern s32 D_8018D8FC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018D8FC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018D978[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018D978[a1 & 0x7F]; +} + + + +extern u8 D_8018D998[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018D998[a1 & 0x7F]; +} + + + +extern u8 D_8018D9B8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018D9B8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018D9D8[])(void); + D_8018D9D8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018DA54[])(void); + +void func_80165AC8(void) { + D_8018DA54[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018DAD0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018DAD0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E63C4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E63C4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018DADC[])(void); + +void func_80166018(void *a0) { + D_8018DADC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018DAE4[])(void); + +void func_801663FC(void *a0) { + D_8018DAE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018DBAC[])(void); + +void func_80166618(void *a0) { + D_8018DBAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018DBBC[])(void); + +void func_80166654(void *a0) { + D_8018DBBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E7030[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E7030[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E7030). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E7030[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E7030)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E7030[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E7030[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018DB00[]; + extern u8 D_8018DAEC[]; + extern u8 D_8018DB14[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018DB00; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018DAEC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018DB14; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80167714); + + +extern void (*D_8018DBCC[])(void); + +void func_801678B4(void *a0) { + D_8018DBCC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018DBD8[])(void); + +void func_80167A9C(void *a0) { + D_8018DBD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018DCE4; + extern u8 D_8018DCF8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018DCE4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018DCF8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018DB38[]; +extern u8 D_8018DB4C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018DB38; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018DB4C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018DBF0[])(void); + +void func_80168744(void *a0) { + D_8018DBF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018DBE0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018DBE0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018DBE0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018DBF8[])(void); + +void func_801689D8(void *a0) { + D_8018DBF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018DC00[])(void); + +void func_80168AA8(void *a0) { + D_8018DC00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018DC08[])(void); + +void func_80168D58(void *a0) { + D_8018DC08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018DC10[])(void); + +void func_8016901C(void *a0) { + D_8018DC10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_003/nonmatchings/ov_SC02_003_jr_8015C32C", func_80169228); + + +extern void (*D_8018DC18[])(void); + +void func_801693CC(void *a0) { + D_8018DC18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018DC20[])(void); + +void func_80169830(void *a0) { + D_8018DC20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018DCD4[])(void); + +void func_80169B80(void *a0) { + D_8018DCD4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018DC28[]; + extern u8 D_8018DC98[]; + extern u8 D_8018DCC8[]; + extern u8 D_801E8698[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018DCC8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018DC28[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801E8698; + RotMatrixYXZ(rot, D_801E8698); + func_80048D9C(D_801E8698, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018DC98); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018DCDC[])(void); + +void func_80169F00(void *a0) { + D_8018DCDC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018DC8C[]; +extern char D_8018DC4C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018DC8C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018DC4C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018DD14[])(void); + +void func_8016A020(void *a0) { + D_8018DD14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018DCE4; + extern u8 D_8018DCF8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018DCE4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018DCF8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018DD20[])(void); + +void func_8016A700(void *a0) { + D_8018DD20[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018DD68[])(void); + +void func_8016AB30(void *a0) { + D_8018DD68[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_004/ov_SC02_004_jr_8015AE2C.c b/src/ov_SC02_004/ov_SC02_004_jr_8015AE2C.c index c6c558d65..7e01be70e 100644 --- a/src/ov_SC02_004/ov_SC02_004_jr_8015AE2C.c +++ b/src/ov_SC02_004/ov_SC02_004_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80180504[])(void); - -void func_8015C714(void *a0) { - D_80180504[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80180378[])(void*); - extern int D_8018031C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80180378)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80180378)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018031C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80180378[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80180378[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80180378[])(void*); - extern int D_8018031C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80180378)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018031C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80180378)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80180514[])(void); - D_80180514[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80180378[])(struct Ent_8015CD20 *); - extern u8 D_8018032C; - extern u8 D_8018051C; - extern u8 D_8018052C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80180378[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018032C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018051C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018052C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80180378[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018054C[])(void); - D_8018054C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018053C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018053C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80180378[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801805A8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801805A8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8017F68C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8017F68C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801805B0[])(void); - D_801805B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801805BC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801805BC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801805BC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801805BC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80180378[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801805BC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018033C[]; - extern u8 D_8018034C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018033C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018034C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801805BC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801805BC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801805BC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801805F0[])(void); - D_801805F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80180378[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801805F8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80180610[])(void); - D_80180610[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80180378[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801805F8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80180630[])(void); - D_80180630[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80180378[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80180378)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80180640; -extern u16 D_80180642; -extern u16 D_80180644; -extern s32 D_80180648; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80180640 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80180642 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80180644 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180648, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80180650; - -void func_8015E588(void) { - func_8013C9C4(&D_80180650); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80180378[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80180378)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80180664[])(void); - D_80180664[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80180378[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80180378[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018066C[])(void); - D_8018066C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018035C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018035C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80180378[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80180674[])(void); - D_80180674[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80180378[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80180378[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018067C[])(void); - D_8018067C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80180378[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80180684; - extern s32 D_80180694; - extern s32 D_801806A4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80180378[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180684); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180694); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80180378[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801806A4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801806B4[])(void); - D_801806B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80180378[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80180378[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80180378[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80180378[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801806C0[])(void); - D_801806C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80180378[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80180378[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80180378[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80180378[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801806D4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801806D4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80180378[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80180378)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80180378[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80180378[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80180750[])(void); - D_80180750[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80180378[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80180378)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80180760[])(void); - D_80180760[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80180378[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80180378[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80180378[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80180378[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80180378[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80180378[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80180378[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80180768[])(void); - D_80180768[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80180378[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80180378)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80180378[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80180378)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80180774[])(void); - D_80180774[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80180378 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80180378[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80180378[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80180378[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80180784[])(void); - -void func_80160EA4(void *a0) { - D_80180784[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80180378[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80180378[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801807B4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801807B4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80180818; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80180818); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80195108[]; - extern u8 D_801807E4[]; - extern u8 D_80180804[]; - extern u8 D_80195114[]; - extern u8 D_8019513C[]; - extern u8 D_80195154[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80195108[0] = p; - func_80024054(&D_801807E4, &D_80195114); - func_8001CE28(p, &D_80195114); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80195108[1] = p; - func_80024054(&D_80180804, &D_8019513C); - func_8001CE28(p, &D_8019513C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80195108[2] = p; - func_800242D0((s16)func_801620C4(), &D_80195154, 0x84); - func_8001CE68(p, &D_80195154); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80195154, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80195108[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80195108; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80180818; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80180818; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80180818; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80180818; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80195108[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80195108; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018083C[])(void); - -void func_80162330(void *a0) { - D_8018083C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80195160[i] via `extern int D_80195160[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80180848[]; - extern s32 D_80180860; - extern u8 D_8019516C[]; - extern u8 D_80195194[]; - extern u8 D_801951B0[]; - extern int D_80195160[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80195160[0] = (s32)item; - func_80024054(D_80180848, D_8019516C); - func_8001CE28(item, D_8019516C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80195160[1] = (s32)item; - func_80024054(((u8 *)&D_80180860), D_80195194); - func_8001CE28(item, D_80195194); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80195160[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801951B0, 0x84); - func_8001CE68(item, D_801951B0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801951B0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80195160[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80195160; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_801627E8); - - -extern void (*D_80180884[])(void); - -void func_80162834(void *a0) { - D_80180884[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80180874; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80180874, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801949C4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801949C4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801949C4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801949C4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018088C[])(void); - -void func_80163A58(void *a0) { - D_8018088C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801949CC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801949CC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801808E0[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801808E0[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801808A8; -extern s16 D_801808DC; -extern s16 D_801808DA; -extern s16 D_801808D8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801808A8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801808DC = 0x80; - D_801808DA = 0x80; - D_801808D8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801808DC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801808DC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801808DC - 8; - D_801808DC = nv; - D_801808DA = nv; - D_801808D8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801808EC[])(void); - -void func_80164BA0(void *a0) { - D_801808EC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801951C0; -extern u8 D_801951C1; -extern u8 D_801951C2; -extern u8 D_801951C3; -extern u8 D_801951C4; -extern u8 D_801951C5; -extern u8 D_801951C6; -extern u8 D_801951C7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801951C0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801951C1 = 0xf0; - *(u8 *)base = 0xf0; - D_801951C2 = 0xc0; - D_801951C6 = 0; - D_801951C5 = 0; - D_801951C4 = 0; - D_801951C7 = 0; - D_801951C3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801951C0; -extern u8 D_801951C1; -extern u8 D_801951C2; - -s32 func_80164E40(void) { - u8 *p = &D_801951C0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801951C1 != 0) { - D_801951C1 -= 0x10; - } - if (D_801951C2 != 0) { - D_801951C2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801808FC[])(void); - -void func_80164EA4(void *a0) { - D_801808FC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019520C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019520C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80195200[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80195200[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80195200[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80195200; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80195200; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80180910[]; - extern u32 D_80180930, D_80180934, D_80180938, D_8018093C; - extern u32 D_80180930, D_80180934, D_80180938, D_8018093C; - extern u32 D_80180930, D_80180934, D_80180938, D_8018093C; - extern u32 D_80180930, D_80180934, D_80180938, D_8018093C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80180910[0x00], p); - ApplyMatrixSV(mat, &D_80180910[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80180910[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80180910[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80180938; - *(u32 *)(prim + 0x24) = D_80180930; - *(u32 *)(prim + 0x28) = D_8018093C; - *(u32 *)(prim + 0x2c) = D_80180934; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80180940[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80180940[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80180940[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80180940[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801809BC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801809BC[a1 & 0x7F]; -} - - - -extern s32 D_801809DC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801809DC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80180A58[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80180A58[a1 & 0x7F]; -} - - - -extern u8 D_80180A78[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80180A78[a1 & 0x7F]; -} - - - -extern u8 D_80180A98[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80180A98[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80180AB8[])(void); - D_80180AB8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80180B34[])(void); - -void func_80165AC8(void) { - D_80180B34[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80180BB0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80180BB0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801949D4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801949D4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80180BBC[])(void); - -void func_80166018(void *a0) { - D_80180BBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80180BC4[])(void); - -void func_801663FC(void *a0) { - D_80180BC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80180C8C[])(void); - -void func_80166618(void *a0) { - D_80180C8C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80180C9C[])(void); - -void func_80166654(void *a0) { - D_80180C9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80195280[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80195280[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80195280). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80195280[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80195280)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80195280[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80195280[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80180BE0[]; - extern u8 D_80180BCC[]; - extern u8 D_80180BF4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80180BE0; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80180BCC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80180BF4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80167714); - - -extern void (*D_80180CAC[])(void); - -void func_801678B4(void *a0) { - D_80180CAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80180CB8[])(void); - -void func_80167A9C(void *a0) { - D_80180CB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80180DC4; - extern u8 D_80180DD8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80180DC4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80180DD8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80180C18[]; -extern u8 D_80180C2C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80180C18; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80180C2C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80180CD0[])(void); - -void func_80168744(void *a0) { - D_80180CD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80180CC0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80180CC0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80180CC0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80180CD8[])(void); - -void func_801689D8(void *a0) { - D_80180CD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80180CE0[])(void); - -void func_80168AA8(void *a0) { - D_80180CE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80180CE8[])(void); - -void func_80168D58(void *a0) { - D_80180CE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80180CF0[])(void); - -void func_8016901C(void *a0) { - D_80180CF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015AE2C", func_80169228); - - -extern void (*D_80180CF8[])(void); - -void func_801693CC(void *a0) { - D_80180CF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80180D00[])(void); - -void func_80169830(void *a0) { - D_80180D00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80180DB4[])(void); - -void func_80169B80(void *a0) { - D_80180DB4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80180D08[]; - extern u8 D_80180D78[]; - extern u8 D_80180DA8[]; - extern u8 D_80196280[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80180DA8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80180D08[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80196280; - RotMatrixYXZ(rot, D_80196280); - func_80048D9C(D_80196280, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80180D78); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80180DBC[])(void); - -void func_80169F00(void *a0) { - D_80180DBC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80180D6C[]; -extern char D_80180D2C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80180D6C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80180D2C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80180DF4[])(void); - -void func_8016A020(void *a0) { - D_80180DF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80180DC4; - extern u8 D_80180DD8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80180DC4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80180DD8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80180E00[])(void); - -void func_8016A700(void *a0) { - D_80180E00[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80180E48[])(void); - -void func_8016AB30(void *a0) { - D_80180E48[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c b/src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c new file mode 100644 index 000000000..c187f41ff --- /dev/null +++ b/src/ov_SC02_004/ov_SC02_004_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180214; +extern u8 D_80180184; +extern u8 D_80180160; +extern u8 D_8018013C; +extern u8 D_801801F0; +extern u8 D_801801CC; +extern u8 D_801801A8; +extern u8 D_80180118; +extern void func_80145934(void); +extern u8 D_801802A4; +extern u8 D_80180280; +extern u8 D_8018025C; +extern u8 D_80180238; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8017F69C[]; +extern unsigned char D_8017F6CC[]; +extern unsigned char D_8017F71C[]; +extern unsigned char D_8017F74C[]; +extern unsigned char D_8017F77C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8017F7CC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8017F894[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8017F91C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8017F924; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801950B0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801950B4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8017F954; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8017F9FC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8017FA20[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8017FA10; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8017FA34[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8017FA40[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8017FA50[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8017FA68[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8017FA58; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8017FA7C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8017FA98[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8017FA88; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8017FAAC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8017FAC0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8017FAD4; +extern void (*D_8017FAFC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8017FADC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8017FB48[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8017FB4C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8017FFB0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8017FFC0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801950E8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8017FFE8[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8017FFC8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8017FFD8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180028[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180030[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8017FFFC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018003C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018000C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801950F0; +extern s32 D_801950FC; +extern s32 D_80195100; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180078[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018004C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801950F8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801802C8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801800E8[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018036C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801804C0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801802DC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801804C8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801802EC; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018030C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801804D0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801804F8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80180378[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80180378[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80180378[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80180378[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80180378[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80180378[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80180378[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80180378[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80180504[])(void); + +void func_8015C714(void *a0) { + D_80180504[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80180378[])(void*); + extern int D_8018031C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80180378)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80180378)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018031C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80180378[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80180378[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80180378[])(void*); + extern int D_8018031C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80180378)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018031C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80180378)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80180514[])(void); + D_80180514[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80180378[])(struct Ent_8015CD20 *); + extern u8 D_8018032C; + extern u8 D_8018051C; + extern u8 D_8018052C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80180378[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018032C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018051C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018052C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80180378[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018054C[])(void); + D_8018054C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018053C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018053C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80180378[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801805A8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801805A8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8017F68C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8017F68C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801805B0[])(void); + D_801805B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801805BC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801805BC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801805BC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801805BC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80180378[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801805BC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018033C[]; + extern u8 D_8018034C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018033C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018034C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801805BC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801805BC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801805BC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801805F0[])(void); + D_801805F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80180378[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801805F8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80180610[])(void); + D_80180610[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80180378[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801805F8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801805F8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80180630[])(void); + D_80180630[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80180378[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80180378)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80180640; +extern u16 D_80180642; +extern u16 D_80180644; +extern s32 D_80180648; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80180640 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80180642 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80180644 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180648, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80180650; + +void func_8015E588(void) { + func_8013C9C4(&D_80180650); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80180378[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80180378)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80180664[])(void); + D_80180664[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80180378[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80180378[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018066C[])(void); + D_8018066C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018035C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018035C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80180378[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80180674[])(void); + D_80180674[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80180378[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80180378[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018067C[])(void); + D_8018067C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80180378[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80180684; + extern s32 D_80180694; + extern s32 D_801806A4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80180378[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180684); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180694); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80180378[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801806A4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801806B4[])(void); + D_801806B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80180378[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80180378[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80180378[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80180378[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801806C0[])(void); + D_801806C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80180378[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80180378[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80180378[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80180378[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801806D4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801806D4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80180378[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80180378)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80180378[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80180378[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80180750[])(void); + D_80180750[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80180378[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80180378)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80180760[])(void); + D_80180760[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80180378[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80180378[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80180378[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80180378[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80180378[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80180378[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80180378[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80180768[])(void); + D_80180768[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80180378[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80180378)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80180378[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80180378)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80180774[])(void); + D_80180774[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80180378 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80180378[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80180378[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80180378[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80180784[])(void); + +void func_80160EA4(void *a0) { + D_80180784[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80180378[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80180378[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801807B4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801807B4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80180818; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80180818); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80195108[]; + extern u8 D_801807E4[]; + extern u8 D_80180804[]; + extern u8 D_80195114[]; + extern u8 D_8019513C[]; + extern u8 D_80195154[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80195108[0] = p; + func_80024054(&D_801807E4, &D_80195114); + func_8001CE28(p, &D_80195114); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80195108[1] = p; + func_80024054(&D_80180804, &D_8019513C); + func_8001CE28(p, &D_8019513C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80195108[2] = p; + func_800242D0((s16)func_801620C4(), &D_80195154, 0x84); + func_8001CE68(p, &D_80195154); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80195154, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80195108[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80195108; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80180818; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80180818; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80180818; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80180818; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80195108[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80195108; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018083C[])(void); + +void func_80162330(void *a0) { + D_8018083C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80195160[i] via `extern int D_80195160[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80180848[]; + extern s32 D_80180860; + extern u8 D_8019516C[]; + extern u8 D_80195194[]; + extern u8 D_801951B0[]; + extern int D_80195160[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80195160[0] = (s32)item; + func_80024054(D_80180848, D_8019516C); + func_8001CE28(item, D_8019516C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80195160[1] = (s32)item; + func_80024054(((u8 *)&D_80180860), D_80195194); + func_8001CE28(item, D_80195194); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80195160[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801951B0, 0x84); + func_8001CE68(item, D_801951B0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801951B0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80195160[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80195160; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_801627E8); + + +extern void (*D_80180884[])(void); + +void func_80162834(void *a0) { + D_80180884[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80180874; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80180874, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801949C4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801949C4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801949C4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801949C4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018088C[])(void); + +void func_80163A58(void *a0) { + D_8018088C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801949CC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801949CC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801808E0[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801808E0[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801808A8; +extern s16 D_801808DC; +extern s16 D_801808DA; +extern s16 D_801808D8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801808A8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801808DC = 0x80; + D_801808DA = 0x80; + D_801808D8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801808DC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801808DC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801808DC - 8; + D_801808DC = nv; + D_801808DA = nv; + D_801808D8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801808EC[])(void); + +void func_80164BA0(void *a0) { + D_801808EC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801951C0; +extern u8 D_801951C1; +extern u8 D_801951C2; +extern u8 D_801951C3; +extern u8 D_801951C4; +extern u8 D_801951C5; +extern u8 D_801951C6; +extern u8 D_801951C7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801951C0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801951C1 = 0xf0; + *(u8 *)base = 0xf0; + D_801951C2 = 0xc0; + D_801951C6 = 0; + D_801951C5 = 0; + D_801951C4 = 0; + D_801951C7 = 0; + D_801951C3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801951C0; +extern u8 D_801951C1; +extern u8 D_801951C2; + +s32 func_80164E40(void) { + u8 *p = &D_801951C0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801951C1 != 0) { + D_801951C1 -= 0x10; + } + if (D_801951C2 != 0) { + D_801951C2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801808FC[])(void); + +void func_80164EA4(void *a0) { + D_801808FC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019520C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019520C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80195200[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80195200[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80195200[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80195200; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80195200; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80180910[]; + extern u32 D_80180930, D_80180934, D_80180938, D_8018093C; + extern u32 D_80180930, D_80180934, D_80180938, D_8018093C; + extern u32 D_80180930, D_80180934, D_80180938, D_8018093C; + extern u32 D_80180930, D_80180934, D_80180938, D_8018093C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80180910[0x00], p); + ApplyMatrixSV(mat, &D_80180910[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80180910[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80180910[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80180938; + *(u32 *)(prim + 0x24) = D_80180930; + *(u32 *)(prim + 0x28) = D_8018093C; + *(u32 *)(prim + 0x2c) = D_80180934; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80180940[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80180940[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80180940[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80180940[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801809BC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801809BC[a1 & 0x7F]; +} + + + +extern s32 D_801809DC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801809DC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80180A58[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80180A58[a1 & 0x7F]; +} + + + +extern u8 D_80180A78[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80180A78[a1 & 0x7F]; +} + + + +extern u8 D_80180A98[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80180A98[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80180AB8[])(void); + D_80180AB8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80180B34[])(void); + +void func_80165AC8(void) { + D_80180B34[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80180BB0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80180BB0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801949D4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801949D4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80180BBC[])(void); + +void func_80166018(void *a0) { + D_80180BBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80180BC4[])(void); + +void func_801663FC(void *a0) { + D_80180BC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80180C8C[])(void); + +void func_80166618(void *a0) { + D_80180C8C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80180C9C[])(void); + +void func_80166654(void *a0) { + D_80180C9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80195280[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80195280[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80195280). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80195280[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80195280)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80195280[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80195280[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80180BE0[]; + extern u8 D_80180BCC[]; + extern u8 D_80180BF4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80180BE0; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80180BCC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80180BF4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80167714); + + +extern void (*D_80180CAC[])(void); + +void func_801678B4(void *a0) { + D_80180CAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80180CB8[])(void); + +void func_80167A9C(void *a0) { + D_80180CB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80180DC4; + extern u8 D_80180DD8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80180DC4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80180DD8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80180C18[]; +extern u8 D_80180C2C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80180C18; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80180C2C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80180CD0[])(void); + +void func_80168744(void *a0) { + D_80180CD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80180CC0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80180CC0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80180CC0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80180CD8[])(void); + +void func_801689D8(void *a0) { + D_80180CD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80180CE0[])(void); + +void func_80168AA8(void *a0) { + D_80180CE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80180CE8[])(void); + +void func_80168D58(void *a0) { + D_80180CE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80180CF0[])(void); + +void func_8016901C(void *a0) { + D_80180CF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_004/nonmatchings/ov_SC02_004_jr_8015C32C", func_80169228); + + +extern void (*D_80180CF8[])(void); + +void func_801693CC(void *a0) { + D_80180CF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80180D00[])(void); + +void func_80169830(void *a0) { + D_80180D00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80180DB4[])(void); + +void func_80169B80(void *a0) { + D_80180DB4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80180D08[]; + extern u8 D_80180D78[]; + extern u8 D_80180DA8[]; + extern u8 D_80196280[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80180DA8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80180D08[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80196280; + RotMatrixYXZ(rot, D_80196280); + func_80048D9C(D_80196280, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80180D78); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80180DBC[])(void); + +void func_80169F00(void *a0) { + D_80180DBC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80180D6C[]; +extern char D_80180D2C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80180D6C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80180D2C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80180DF4[])(void); + +void func_8016A020(void *a0) { + D_80180DF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80180DC4; + extern u8 D_80180DD8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80180DC4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80180DD8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80180E00[])(void); + +void func_8016A700(void *a0) { + D_80180E00[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80180E48[])(void); + +void func_8016AB30(void *a0) { + D_80180E48[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_005/ov_SC02_005_jr_8015AE2C.c b/src/ov_SC02_005/ov_SC02_005_jr_8015AE2C.c index db05cde16..70206c551 100644 --- a/src/ov_SC02_005/ov_SC02_005_jr_8015AE2C.c +++ b/src/ov_SC02_005/ov_SC02_005_jr_8015AE2C.c @@ -1642,4588 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80193108[])(void); - -void func_8015C714(void *a0) { - D_80193108[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80192F7C[])(void*); - extern int D_80192F20; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80192F7C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80192F7C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80192F20); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80192F7C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80192F7C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80192F7C[])(void*); - extern int D_80192F20; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80192F7C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80192F20); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80192F7C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80193118[])(void); - D_80193118[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80192F7C[])(struct Ent_8015CD20 *); - extern u8 D_80192F30; - extern u8 D_80193120; - extern u8 D_80193130; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80192F7C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80192F30); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193120); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193130); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80192F7C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80193150[])(void); - D_80193150[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80193140; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80193140 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80192F7C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801931AC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801931AC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80192290[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80192290; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801931B4[])(void); - D_801931B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801931C0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801931C0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801931C0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801931C0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80192F7C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801931C0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80192F40[]; - extern u8 D_80192F50[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80192F40); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80192F50); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801931C0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801931C0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801931C0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801931F4[])(void); - D_801931F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80192F7C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801931FC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80193214[])(void); - D_80193214[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80192F7C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801931FC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80193234[])(void); - D_80193234[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80192F7C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80192F7C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80193244; -extern u16 D_80193246; -extern u16 D_80193248; -extern s32 D_8019324C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80193244 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80193246 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80193248 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8019324C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80193254; - -void func_8015E588(void) { - func_8013C9C4(&D_80193254); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80192F7C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80192F7C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80193268[])(void); - D_80193268[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80192F7C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80192F7C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80193270[])(void); - D_80193270[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80192F60; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80192F60); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void*); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); -extern void (*D_80192F7C[])(void*); - -void func_8015EEE0(void* arg0) { - ((void (*)(void*, u32))func_80148038)(arg0, 0x10000); - ((void (*)(void*))func_80147460)(arg0); - ((void (*)(void*, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void*))func_801473EC)(arg0); - - if (*(u16*)((u8*)arg0 + 0xB8) & 0x8000) { - D_80192F7C[*(u16*)arg0](arg0); - ((void (*)(void*, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (!((s32 (*)(void*))func_80161418)(arg0)) { - ((void (*)(void*))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80193278[])(void); - D_80193278[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80192F7C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80192F7C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80193280[])(void); - D_80193280[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80192F7C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80193288; - extern s32 D_80193298; - extern s32 D_801932A8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80192F7C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80193288); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80193298); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80192F7C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801932A8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801932B8[])(void); - D_801932B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80192F7C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80192F7C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80192F7C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80192F7C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801932C4[])(void); - D_801932C4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80192F7C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80192F7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80192F7C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80192F7C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801932D8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801932D8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80192F7C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80192F7C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80192F7C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80192F7C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80193354[])(void); - D_80193354[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80192F7C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80192F7C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80193364[])(void); - D_80193364[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80192F7C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80192F7C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80192F7C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80192F7C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80192F7C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80192F7C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80192F7C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8019336C[])(void); - D_8019336C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80192F7C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80192F7C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80192F7C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80192F7C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80193378[])(void); - D_80193378[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80192F7C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80192F7C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80192F7C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80192F7C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80193388[])(void); - -void func_80160EA4(void *a0) { - D_80193388[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80192F7C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80192F7C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801933B8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801933B8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8019341C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8019341C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E3180[]; - extern u8 D_801933E8[]; - extern u8 D_80193408[]; - extern u8 D_801E318C[]; - extern u8 D_801E31B4[]; - extern u8 D_801E31CC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E3180[0] = p; - func_80024054(&D_801933E8, &D_801E318C); - func_8001CE28(p, &D_801E318C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E3180[1] = p; - func_80024054(&D_80193408, &D_801E31B4); - func_8001CE28(p, &D_801E31B4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E3180[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E31CC, 0x84); - func_8001CE68(p, &D_801E31CC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E31CC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E3180[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E3180; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8019341C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8019341C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8019341C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8019341C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E3180[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E3180; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80193440[])(void); - -void func_80162330(void *a0) { - D_80193440[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E31D8[i] via `extern int D_801E31D8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8019344C[]; - extern s32 D_80193464; - extern u8 D_801E31E4[]; - extern u8 D_801E320C[]; - extern u8 D_801E3228[]; - extern int D_801E31D8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E31D8[0] = (s32)item; - func_80024054(D_8019344C, D_801E31E4); - func_8001CE28(item, D_801E31E4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E31D8[1] = (s32)item; - func_80024054(((u8 *)&D_80193464), D_801E320C); - func_8001CE28(item, D_801E320C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E31D8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E3228, 0x84); - func_8001CE68(item, D_801E3228); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E3228, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E31D8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E31D8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_801627E8); - - -extern void (*D_80193488[])(void); - -void func_80162834(void *a0) { - D_80193488[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80193478; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80193478, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E26F8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E26F8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E26F8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E26F8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80193490[])(void); - -void func_80163A58(void *a0) { - D_80193490[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E2700; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E2700; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801934E4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801934E4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801934AC; -extern s16 D_801934E0; -extern s16 D_801934DE; -extern s16 D_801934DC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801934AC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801934E0 = 0x80; - D_801934DE = 0x80; - D_801934DC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801934E0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801934E0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801934E0 - 8; - D_801934E0 = nv; - D_801934DE = nv; - D_801934DC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801934F0[])(void); - -void func_80164BA0(void *a0) { - D_801934F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E3238; -extern u8 D_801E3239; -extern u8 D_801E323A; -extern u8 D_801E323B; -extern u8 D_801E323C; -extern u8 D_801E323D; -extern u8 D_801E323E; -extern u8 D_801E323F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E3238; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E3239 = 0xf0; - *(u8 *)base = 0xf0; - D_801E323A = 0xc0; - D_801E323E = 0; - D_801E323D = 0; - D_801E323C = 0; - D_801E323F = 0; - D_801E323B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E3238; -extern u8 D_801E3239; -extern u8 D_801E323A; - -s32 func_80164E40(void) { - u8 *p = &D_801E3238; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E3239 != 0) { - D_801E3239 -= 0x10; - } - if (D_801E323A != 0) { - D_801E323A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80193500[])(void); - -void func_80164EA4(void *a0) { - D_80193500[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E3284[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E3284[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E3278[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E3278[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E3278[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E3278; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E3278; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80193514[]; - extern u32 D_80193534, D_80193538, D_8019353C, D_80193540; - extern u32 D_80193534, D_80193538, D_8019353C, D_80193540; - extern u32 D_80193534, D_80193538, D_8019353C, D_80193540; - extern u32 D_80193534, D_80193538, D_8019353C, D_80193540; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80193514[0x00], p); - ApplyMatrixSV(mat, &D_80193514[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80193514[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80193514[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8019353C; - *(u32 *)(prim + 0x24) = D_80193534; - *(u32 *)(prim + 0x28) = D_80193540; - *(u32 *)(prim + 0x2c) = D_80193538; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80193544[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80193544[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80193544[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80193544[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801935C0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801935C0[a1 & 0x7F]; -} - - - -extern s32 D_801935E0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801935E0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8019365C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8019365C[a1 & 0x7F]; -} - - - -extern u8 D_8019367C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8019367C[a1 & 0x7F]; -} - - - -extern u8 D_8019369C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8019369C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801936BC[])(void); - D_801936BC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80193738[])(void); - -void func_80165AC8(void) { - D_80193738[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801937B4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801937B4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E2708; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E2708, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801937C0[])(void); - -void func_80166018(void *a0) { - D_801937C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801937C8[])(void); - -void func_801663FC(void *a0) { - D_801937C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80193890[])(void); - -void func_80166618(void *a0) { - D_80193890[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801938A0[])(void); - -void func_80166654(void *a0) { - D_801938A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E32F8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E32F8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E32F8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E32F8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E32F8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E32F8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E32F8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801937E4[]; - extern u8 D_801937D0[]; - extern u8 D_801937F8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801937E4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801937D0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801937F8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80167714); - - -extern void (*D_801938B0[])(void); - -void func_801678B4(void *a0) { - D_801938B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801938BC[])(void); - -void func_80167A9C(void *a0) { - D_801938BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801939C8; - extern u8 D_801939DC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801939C8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801939DC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8019381C[]; -extern u8 D_80193830[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8019381C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80193830; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801938D4[])(void); - -void func_80168744(void *a0) { - D_801938D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801938C4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801938C4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801938C4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801938DC[])(void); - -void func_801689D8(void *a0) { - D_801938DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801938E4[])(void); - -void func_80168AA8(void *a0) { - D_801938E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801938EC[])(void); - -void func_80168D58(void *a0) { - D_801938EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801938F4[])(void); - -void func_8016901C(void *a0) { - D_801938F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015AE2C", func_80169228); - - -extern void (*D_801938FC[])(void); - -void func_801693CC(void *a0) { - D_801938FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80193904[])(void); - -void func_80169830(void *a0) { - D_80193904[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801939B8[])(void); - -void func_80169B80(void *a0) { - D_801939B8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8019390C[]; - extern u8 D_8019397C[]; - extern u8 D_801939AC[]; - extern u8 D_801E4B08[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801939AC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8019390C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801E4B08; - RotMatrixYXZ(rot, D_801E4B08); - func_80048D9C(D_801E4B08, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8019397C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801939C0[])(void); - -void func_80169F00(void *a0) { - D_801939C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80193970[]; -extern char D_80193930[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80193970, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80193930); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801939F8[])(void); - -void func_8016A020(void *a0) { - D_801939F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801939C8; - extern u8 D_801939DC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801939C8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801939DC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80193A04[])(void); - -void func_8016A700(void *a0) { - D_80193A04[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80193A4C[])(void); - -void func_8016AB30(void *a0) { - D_80193A4C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c b/src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c new file mode 100644 index 000000000..ed67b8f45 --- /dev/null +++ b/src/ov_SC02_005/ov_SC02_005_jr_8015C32C.c @@ -0,0 +1,5945 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80192E18; +extern u8 D_80192D88; +extern u8 D_80192D64; +extern u8 D_80192D40; +extern u8 D_80192DF4; +extern u8 D_80192DD0; +extern u8 D_80192DAC; +extern u8 D_80192D1C; +extern void func_80145934(void); +extern u8 D_80192EA8; +extern u8 D_80192E84; +extern u8 D_80192E60; +extern u8 D_80192E3C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801922A0[]; +extern unsigned char D_801922D0[]; +extern unsigned char D_80192320[]; +extern unsigned char D_80192350[]; +extern unsigned char D_80192380[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801923D0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80192498[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80192520[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80192528; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E3128; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E312C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80192558; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80192600[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80192624[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80192614; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80192638[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80192644[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80192654[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8019266C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8019265C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80192680[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8019269C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8019268C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801926B0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801926C4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801926D8; +extern void (*D_80192700[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801926E0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8019274C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80192750[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80192BB4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80192BC4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E3160; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80192BEC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80192BCC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80192BDC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80192C2C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80192C34[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80192C00; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80192C40[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80192C10; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E3168; +extern s32 D_801E3174; +extern s32 D_801E3178; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80192C7C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80192C50[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E3170; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80192ECC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80192CEC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80192F70[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801930C4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80192EE0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801930CC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80192EF0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80192F10; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801930D4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801930FC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80192F7C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80193108[])(void); + +void func_8015C714(void *a0) { + D_80193108[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80192F7C[])(void*); + extern int D_80192F20; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80192F7C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80192F7C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80192F20); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80192F7C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80192F7C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80192F7C[])(void*); + extern int D_80192F20; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80192F7C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80192F20); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80192F7C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80193118[])(void); + D_80193118[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80192F7C[])(struct Ent_8015CD20 *); + extern u8 D_80192F30; + extern u8 D_80193120; + extern u8 D_80193130; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80192F7C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80192F30); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193120); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193130); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80192F7C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80193150[])(void); + D_80193150[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80193140; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80193140 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80192F7C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801931AC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801931AC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80192290[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80192290; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801931B4[])(void); + D_801931B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801931C0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801931C0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801931C0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801931C0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80192F7C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801931C0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80192F40[]; + extern u8 D_80192F50[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80192F40); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80192F50); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801931C0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801931C0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801931C0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801931F4[])(void); + D_801931F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80192F7C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801931FC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80193214[])(void); + D_80193214[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80192F7C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801931FC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801931FC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80193234[])(void); + D_80193234[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80192F7C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80192F7C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80193244; +extern u16 D_80193246; +extern u16 D_80193248; +extern s32 D_8019324C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80193244 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80193246 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80193248 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8019324C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80193254; + +void func_8015E588(void) { + func_8013C9C4(&D_80193254); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80192F7C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80192F7C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80193268[])(void); + D_80193268[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80192F7C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80192F7C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80193270[])(void); + D_80193270[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80192F60; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80192F60); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void*); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); +extern void (*D_80192F7C[])(void*); + +void func_8015EEE0(void* arg0) { + ((void (*)(void*, u32))func_80148038)(arg0, 0x10000); + ((void (*)(void*))func_80147460)(arg0); + ((void (*)(void*, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void*))func_801473EC)(arg0); + + if (*(u16*)((u8*)arg0 + 0xB8) & 0x8000) { + D_80192F7C[*(u16*)arg0](arg0); + ((void (*)(void*, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (!((s32 (*)(void*))func_80161418)(arg0)) { + ((void (*)(void*))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80193278[])(void); + D_80193278[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80192F7C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80192F7C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80193280[])(void); + D_80193280[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80192F7C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80193288; + extern s32 D_80193298; + extern s32 D_801932A8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80193288); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80193298); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80192F7C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801932A8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801932B8[])(void); + D_801932B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80192F7C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80192F7C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80192F7C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80192F7C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801932C4[])(void); + D_801932C4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80192F7C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80192F7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80192F7C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80192F7C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801932D8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801932D8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80192F7C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80192F7C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80192F7C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80192F7C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80193354[])(void); + D_80193354[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80192F7C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80192F7C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80193364[])(void); + D_80193364[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80192F7C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80192F7C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80192F7C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80192F7C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80192F7C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80192F7C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80192F7C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8019336C[])(void); + D_8019336C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80192F7C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80192F7C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80192F7C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80192F7C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80193378[])(void); + D_80193378[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80192F7C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80192F7C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80192F7C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80192F7C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80193388[])(void); + +void func_80160EA4(void *a0) { + D_80193388[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80192F7C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80192F7C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801933B8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801933B8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8019341C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8019341C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E3180[]; + extern u8 D_801933E8[]; + extern u8 D_80193408[]; + extern u8 D_801E318C[]; + extern u8 D_801E31B4[]; + extern u8 D_801E31CC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E3180[0] = p; + func_80024054(&D_801933E8, &D_801E318C); + func_8001CE28(p, &D_801E318C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E3180[1] = p; + func_80024054(&D_80193408, &D_801E31B4); + func_8001CE28(p, &D_801E31B4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E3180[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E31CC, 0x84); + func_8001CE68(p, &D_801E31CC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E31CC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E3180[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E3180; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8019341C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8019341C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8019341C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8019341C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E3180[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E3180; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80193440[])(void); + +void func_80162330(void *a0) { + D_80193440[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E31D8[i] via `extern int D_801E31D8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8019344C[]; + extern s32 D_80193464; + extern u8 D_801E31E4[]; + extern u8 D_801E320C[]; + extern u8 D_801E3228[]; + extern int D_801E31D8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E31D8[0] = (s32)item; + func_80024054(D_8019344C, D_801E31E4); + func_8001CE28(item, D_801E31E4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E31D8[1] = (s32)item; + func_80024054(((u8 *)&D_80193464), D_801E320C); + func_8001CE28(item, D_801E320C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E31D8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E3228, 0x84); + func_8001CE68(item, D_801E3228); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E3228, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E31D8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E31D8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_801627E8); + + +extern void (*D_80193488[])(void); + +void func_80162834(void *a0) { + D_80193488[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80193478; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80193478, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E26F8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E26F8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E26F8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E26F8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80193490[])(void); + +void func_80163A58(void *a0) { + D_80193490[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E2700; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E2700; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801934E4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801934E4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801934AC; +extern s16 D_801934E0; +extern s16 D_801934DE; +extern s16 D_801934DC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801934AC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801934E0 = 0x80; + D_801934DE = 0x80; + D_801934DC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801934E0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801934E0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801934E0 - 8; + D_801934E0 = nv; + D_801934DE = nv; + D_801934DC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801934F0[])(void); + +void func_80164BA0(void *a0) { + D_801934F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E3238; +extern u8 D_801E3239; +extern u8 D_801E323A; +extern u8 D_801E323B; +extern u8 D_801E323C; +extern u8 D_801E323D; +extern u8 D_801E323E; +extern u8 D_801E323F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E3238; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E3239 = 0xf0; + *(u8 *)base = 0xf0; + D_801E323A = 0xc0; + D_801E323E = 0; + D_801E323D = 0; + D_801E323C = 0; + D_801E323F = 0; + D_801E323B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E3238; +extern u8 D_801E3239; +extern u8 D_801E323A; + +s32 func_80164E40(void) { + u8 *p = &D_801E3238; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E3239 != 0) { + D_801E3239 -= 0x10; + } + if (D_801E323A != 0) { + D_801E323A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80193500[])(void); + +void func_80164EA4(void *a0) { + D_80193500[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E3284[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E3284[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E3278[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E3278[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E3278[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E3278; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E3278; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80193514[]; + extern u32 D_80193534, D_80193538, D_8019353C, D_80193540; + extern u32 D_80193534, D_80193538, D_8019353C, D_80193540; + extern u32 D_80193534, D_80193538, D_8019353C, D_80193540; + extern u32 D_80193534, D_80193538, D_8019353C, D_80193540; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80193514[0x00], p); + ApplyMatrixSV(mat, &D_80193514[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80193514[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80193514[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8019353C; + *(u32 *)(prim + 0x24) = D_80193534; + *(u32 *)(prim + 0x28) = D_80193540; + *(u32 *)(prim + 0x2c) = D_80193538; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80193544[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80193544[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80193544[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80193544[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801935C0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801935C0[a1 & 0x7F]; +} + + + +extern s32 D_801935E0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801935E0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8019365C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8019365C[a1 & 0x7F]; +} + + + +extern u8 D_8019367C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8019367C[a1 & 0x7F]; +} + + + +extern u8 D_8019369C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8019369C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801936BC[])(void); + D_801936BC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80193738[])(void); + +void func_80165AC8(void) { + D_80193738[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801937B4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801937B4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E2708; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E2708, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801937C0[])(void); + +void func_80166018(void *a0) { + D_801937C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801937C8[])(void); + +void func_801663FC(void *a0) { + D_801937C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80193890[])(void); + +void func_80166618(void *a0) { + D_80193890[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801938A0[])(void); + +void func_80166654(void *a0) { + D_801938A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E32F8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E32F8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E32F8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E32F8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E32F8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E32F8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E32F8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801937E4[]; + extern u8 D_801937D0[]; + extern u8 D_801937F8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801937E4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801937D0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801937F8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80167714); + + +extern void (*D_801938B0[])(void); + +void func_801678B4(void *a0) { + D_801938B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801938BC[])(void); + +void func_80167A9C(void *a0) { + D_801938BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801939C8; + extern u8 D_801939DC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801939C8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801939DC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8019381C[]; +extern u8 D_80193830[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8019381C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80193830; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801938D4[])(void); + +void func_80168744(void *a0) { + D_801938D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801938C4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801938C4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801938C4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801938DC[])(void); + +void func_801689D8(void *a0) { + D_801938DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801938E4[])(void); + +void func_80168AA8(void *a0) { + D_801938E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801938EC[])(void); + +void func_80168D58(void *a0) { + D_801938EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801938F4[])(void); + +void func_8016901C(void *a0) { + D_801938F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_005/nonmatchings/ov_SC02_005_jr_8015C32C", func_80169228); + + +extern void (*D_801938FC[])(void); + +void func_801693CC(void *a0) { + D_801938FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80193904[])(void); + +void func_80169830(void *a0) { + D_80193904[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801939B8[])(void); + +void func_80169B80(void *a0) { + D_801939B8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8019390C[]; + extern u8 D_8019397C[]; + extern u8 D_801939AC[]; + extern u8 D_801E4B08[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801939AC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8019390C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801E4B08; + RotMatrixYXZ(rot, D_801E4B08); + func_80048D9C(D_801E4B08, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8019397C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801939C0[])(void); + +void func_80169F00(void *a0) { + D_801939C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80193970[]; +extern char D_80193930[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80193970, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80193930); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801939F8[])(void); + +void func_8016A020(void *a0) { + D_801939F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801939C8; + extern u8 D_801939DC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801939C8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801939DC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80193A04[])(void); + +void func_8016A700(void *a0) { + D_80193A04[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80193A4C[])(void); + +void func_8016AB30(void *a0) { + D_80193A4C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_011/ov_SC02_011_jr_8015AE2C.c b/src/ov_SC02_011/ov_SC02_011_jr_8015AE2C.c index 8ebf73247..7f71a11f3 100644 --- a/src/ov_SC02_011/ov_SC02_011_jr_8015AE2C.c +++ b/src/ov_SC02_011/ov_SC02_011_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80193558[])(void); - -void func_8015C714(void *a0) { - D_80193558[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801933CC[])(void*); - extern int D_80193370; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801933CC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801933CC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80193370); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801933CC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801933CC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801933CC[])(void*); - extern int D_80193370; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801933CC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80193370); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801933CC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80193568[])(void); - D_80193568[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801933CC[])(struct Ent_8015CD20 *); - extern u8 D_80193380; - extern u8 D_80193570; - extern u8 D_80193580; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801933CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193380); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193570); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193580); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801933CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801935A0[])(void); - D_801935A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80193590; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80193590 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801933CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801935FC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801935FC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801926E0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801926E0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80193604[])(void); - D_80193604[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80193610[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80193610[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80193610[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80193610[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801933CC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80193610[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80193390[]; - extern u8 D_801933A0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80193390); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801933A0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80193610[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80193610[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80193610[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80193644[])(void); - D_80193644[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801933CC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8019364C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80193664[])(void); - D_80193664[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801933CC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8019364C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80193684[])(void); - D_80193684[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801933CC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801933CC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80193694; -extern u16 D_80193696; -extern u16 D_80193698; -extern s32 D_8019369C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80193694 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80193696 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80193698 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8019369C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801936A4; - -void func_8015E588(void) { - func_8013C9C4(&D_801936A4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801933CC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801933CC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801936B8[])(void); - D_801936B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801933CC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801933CC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801936C0[])(void); - D_801936C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801933B0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801933B0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801933CC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801936C8[])(void); - D_801936C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801933CC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801933CC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801936D0[])(void); - D_801936D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801933CC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801936D8; - extern s32 D_801936E8; - extern s32 D_801936F8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801933CC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801936D8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801936E8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801933CC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801936F8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80193708[])(void); - D_80193708[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801933CC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801933CC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801933CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801933CC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80193714[])(void); - D_80193714[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801933CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801933CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801933CC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801933CC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80193728[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80193728[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801933CC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801933CC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801933CC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801933CC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801937A4[])(void); - D_801937A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801933CC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801933CC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801937B4[])(void); - D_801937B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801933CC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801933CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801933CC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801933CC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801933CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801933CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801933CC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801937BC[])(void); - D_801937BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801933CC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801933CC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801933CC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801933CC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801937C8[])(void); - D_801937C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801933CC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801933CC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801933CC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801933CC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801937D8[])(void); - -void func_80160EA4(void *a0) { - D_801937D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801933CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801933CC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80193808[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80193808[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8019386C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8019386C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801EA060[]; - extern u8 D_80193838[]; - extern u8 D_80193858[]; - extern u8 D_801EA06C[]; - extern u8 D_801EA094[]; - extern u8 D_801EA0AC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801EA060[0] = p; - func_80024054(&D_80193838, &D_801EA06C); - func_8001CE28(p, &D_801EA06C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801EA060[1] = p; - func_80024054(&D_80193858, &D_801EA094); - func_8001CE28(p, &D_801EA094); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801EA060[2] = p; - func_800242D0((s16)func_801620C4(), &D_801EA0AC, 0x84); - func_8001CE68(p, &D_801EA0AC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801EA0AC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EA060[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801EA060; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8019386C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8019386C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8019386C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8019386C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801EA060[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801EA060; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80193890[])(void); - -void func_80162330(void *a0) { - D_80193890[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801EA0B8[i] via `extern int D_801EA0B8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8019389C[]; - extern s32 D_801938B4; - extern u8 D_801EA0C4[]; - extern u8 D_801EA0EC[]; - extern u8 D_801EA108[]; - extern int D_801EA0B8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801EA0B8[0] = (s32)item; - func_80024054(D_8019389C, D_801EA0C4); - func_8001CE28(item, D_801EA0C4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801EA0B8[1] = (s32)item; - func_80024054(((u8 *)&D_801938B4), D_801EA0EC); - func_8001CE28(item, D_801EA0EC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801EA0B8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801EA108, 0x84); - func_8001CE68(item, D_801EA108); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801EA108, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EA0B8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801EA0B8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_801627E8); - - -extern void (*D_801938D8[])(void); - -void func_80162834(void *a0) { - D_801938D8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801938C8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801938C8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E9854[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E9854, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E9854[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E9854, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801938E0[])(void); - -void func_80163A58(void *a0) { - D_801938E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E985C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E985C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80193934[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80193934[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801938FC; -extern s16 D_80193930; -extern s16 D_8019392E; -extern s16 D_8019392C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801938FC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80193930 = 0x80; - D_8019392E = 0x80; - D_8019392C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80193930 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80193930` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80193930 - 8; - D_80193930 = nv; - D_8019392E = nv; - D_8019392C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80193940[])(void); - -void func_80164BA0(void *a0) { - D_80193940[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801EA118; -extern u8 D_801EA119; -extern u8 D_801EA11A; -extern u8 D_801EA11B; -extern u8 D_801EA11C; -extern u8 D_801EA11D; -extern u8 D_801EA11E; -extern u8 D_801EA11F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801EA118; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801EA119 = 0xf0; - *(u8 *)base = 0xf0; - D_801EA11A = 0xc0; - D_801EA11E = 0; - D_801EA11D = 0; - D_801EA11C = 0; - D_801EA11F = 0; - D_801EA11B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801EA118; -extern u8 D_801EA119; -extern u8 D_801EA11A; - -s32 func_80164E40(void) { - u8 *p = &D_801EA118; - if (*p != 0) { - *p -= 0x10; - } - if (D_801EA119 != 0) { - D_801EA119 -= 0x10; - } - if (D_801EA11A != 0) { - D_801EA11A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80193950[])(void); - -void func_80164EA4(void *a0) { - D_80193950[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801EA164[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801EA164[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801EA158[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801EA158[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801EA158[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801EA158; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801EA158; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80193964[]; - extern u32 D_80193984, D_80193988, D_8019398C, D_80193990; - extern u32 D_80193984, D_80193988, D_8019398C, D_80193990; - extern u32 D_80193984, D_80193988, D_8019398C, D_80193990; - extern u32 D_80193984, D_80193988, D_8019398C, D_80193990; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80193964[0x00], p); - ApplyMatrixSV(mat, &D_80193964[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80193964[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80193964[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8019398C; - *(u32 *)(prim + 0x24) = D_80193984; - *(u32 *)(prim + 0x28) = D_80193990; - *(u32 *)(prim + 0x2c) = D_80193988; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80193994[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80193994[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80193994[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80193994[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80193A10[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80193A10[a1 & 0x7F]; -} - - - -extern s32 D_80193A30[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80193A30[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80193AAC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80193AAC[a1 & 0x7F]; -} - - - -extern u8 D_80193ACC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80193ACC[a1 & 0x7F]; -} - - - -extern u8 D_80193AEC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80193AEC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80193B0C[])(void); - D_80193B0C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80193B88[])(void); - -void func_80165AC8(void) { - D_80193B88[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80193C04[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80193C04[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E9864; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E9864, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80193C10[])(void); - -void func_80166018(void *a0) { - D_80193C10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80193C18[])(void); - -void func_801663FC(void *a0) { - D_80193C18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80193CE0[])(void); - -void func_80166618(void *a0) { - D_80193CE0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80193CF0[])(void); - -void func_80166654(void *a0) { - D_80193CF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801EA1D8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801EA1D8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EA1D8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801EA1D8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801EA1D8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801EA1D8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801EA1D8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80193C34[]; - extern u8 D_80193C20[]; - extern u8 D_80193C48[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80193C34; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80193C20; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80193C48; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80167714); - - -extern void (*D_80193D00[])(void); - -void func_801678B4(void *a0) { - D_80193D00[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80193D0C[])(void); - -void func_80167A9C(void *a0) { - D_80193D0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80193E18; - extern u8 D_80193E2C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80193E18); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80193E2C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80193C6C[]; -extern u8 D_80193C80[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80193C6C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80193C80; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80193D24[])(void); - -void func_80168744(void *a0) { - D_80193D24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80193D14 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80193D14[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80193D14; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80193D2C[])(void); - -void func_801689D8(void *a0) { - D_80193D2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80193D34[])(void); - -void func_80168AA8(void *a0) { - D_80193D34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80193D3C[])(void); - -void func_80168D58(void *a0) { - D_80193D3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80193D44[])(void); - -void func_8016901C(void *a0) { - D_80193D44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015AE2C", func_80169228); - - -extern void (*D_80193D4C[])(void); - -void func_801693CC(void *a0) { - D_80193D4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80193D54[])(void); - -void func_80169830(void *a0) { - D_80193D54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80193E08[])(void); - -void func_80169B80(void *a0) { - D_80193E08[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80193D5C[]; - extern u8 D_80193DCC[]; - extern u8 D_80193DFC[]; - extern u8 D_801EB938[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80193DFC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80193D5C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801EB938; - RotMatrixYXZ(rot, D_801EB938); - func_80048D9C(D_801EB938, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80193DCC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80193E10[])(void); - -void func_80169F00(void *a0) { - D_80193E10[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80193DC0[]; -extern char D_80193D80[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80193DC0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80193D80); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80193E48[])(void); - -void func_8016A020(void *a0) { - D_80193E48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80193E18; - extern u8 D_80193E2C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80193E18); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80193E2C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80193E54[])(void); - -void func_8016A700(void *a0) { - D_80193E54[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80193E9C[])(void); - -void func_8016AB30(void *a0) { - D_80193E9C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c b/src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c new file mode 100644 index 000000000..3c401bf50 --- /dev/null +++ b/src/ov_SC02_011/ov_SC02_011_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80193268; +extern u8 D_801931D8; +extern u8 D_801931B4; +extern u8 D_80193190; +extern u8 D_80193244; +extern u8 D_80193220; +extern u8 D_801931FC; +extern u8 D_8019316C; +extern void func_80145934(void); +extern u8 D_801932F8; +extern u8 D_801932D4; +extern u8 D_801932B0; +extern u8 D_8019328C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801926F0[]; +extern unsigned char D_80192720[]; +extern unsigned char D_80192770[]; +extern unsigned char D_801927A0[]; +extern unsigned char D_801927D0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80192820[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801928E8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80192970[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80192978; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801EA008; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801EA00C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801929A8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80192A50[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80192A74[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80192A64; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80192A88[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80192A94[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80192AA4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80192ABC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80192AAC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80192AD0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80192AEC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80192ADC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80192B00[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80192B14[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80192B28; +extern void (*D_80192B50[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80192B30; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80192B9C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80192BA0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80193004[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80193014[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801EA040; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8019303C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8019301C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8019302C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8019307C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80193084[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80193050; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80193090[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80193060; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801EA048; +extern s32 D_801EA054; +extern s32 D_801EA058; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801930CC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801930A0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801EA050; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8019331C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8019313C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801933C0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80193514[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80193330; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8019351C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80193340; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80193360; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80193524[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8019354C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801933CC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80193558[])(void); + +void func_8015C714(void *a0) { + D_80193558[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801933CC[])(void*); + extern int D_80193370; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801933CC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801933CC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80193370); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801933CC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801933CC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801933CC[])(void*); + extern int D_80193370; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801933CC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80193370); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801933CC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80193568[])(void); + D_80193568[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801933CC[])(struct Ent_8015CD20 *); + extern u8 D_80193380; + extern u8 D_80193570; + extern u8 D_80193580; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801933CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193380); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193570); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80193580); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801933CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801935A0[])(void); + D_801935A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80193590; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80193590 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801933CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801935FC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801935FC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801926E0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801926E0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80193604[])(void); + D_80193604[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80193610[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80193610[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80193610[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80193610[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801933CC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80193610[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80193390[]; + extern u8 D_801933A0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80193390); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801933A0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80193610[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80193610[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80193610[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80193644[])(void); + D_80193644[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801933CC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8019364C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80193664[])(void); + D_80193664[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801933CC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8019364C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8019364C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80193684[])(void); + D_80193684[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801933CC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801933CC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80193694; +extern u16 D_80193696; +extern u16 D_80193698; +extern s32 D_8019369C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80193694 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80193696 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80193698 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8019369C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801936A4; + +void func_8015E588(void) { + func_8013C9C4(&D_801936A4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801933CC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801933CC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801936B8[])(void); + D_801936B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801933CC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801933CC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801936C0[])(void); + D_801936C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801933B0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801933B0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801933CC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801936C8[])(void); + D_801936C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801933CC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801933CC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801936D0[])(void); + D_801936D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801933CC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801936D8; + extern s32 D_801936E8; + extern s32 D_801936F8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801936D8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801936E8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801933CC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801936F8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80193708[])(void); + D_80193708[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801933CC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801933CC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801933CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801933CC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80193714[])(void); + D_80193714[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801933CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801933CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801933CC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801933CC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80193728[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80193728[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801933CC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801933CC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801933CC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801933CC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801937A4[])(void); + D_801937A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801933CC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801933CC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801937B4[])(void); + D_801937B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801933CC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801933CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801933CC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801933CC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801933CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801933CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801933CC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801937BC[])(void); + D_801937BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801933CC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801933CC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801933CC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801933CC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801937C8[])(void); + D_801937C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801933CC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801933CC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801933CC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801933CC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801937D8[])(void); + +void func_80160EA4(void *a0) { + D_801937D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801933CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801933CC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80193808[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80193808[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8019386C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8019386C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801EA060[]; + extern u8 D_80193838[]; + extern u8 D_80193858[]; + extern u8 D_801EA06C[]; + extern u8 D_801EA094[]; + extern u8 D_801EA0AC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801EA060[0] = p; + func_80024054(&D_80193838, &D_801EA06C); + func_8001CE28(p, &D_801EA06C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801EA060[1] = p; + func_80024054(&D_80193858, &D_801EA094); + func_8001CE28(p, &D_801EA094); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801EA060[2] = p; + func_800242D0((s16)func_801620C4(), &D_801EA0AC, 0x84); + func_8001CE68(p, &D_801EA0AC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801EA0AC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EA060[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801EA060; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8019386C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8019386C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8019386C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8019386C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801EA060[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801EA060; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80193890[])(void); + +void func_80162330(void *a0) { + D_80193890[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801EA0B8[i] via `extern int D_801EA0B8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8019389C[]; + extern s32 D_801938B4; + extern u8 D_801EA0C4[]; + extern u8 D_801EA0EC[]; + extern u8 D_801EA108[]; + extern int D_801EA0B8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801EA0B8[0] = (s32)item; + func_80024054(D_8019389C, D_801EA0C4); + func_8001CE28(item, D_801EA0C4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801EA0B8[1] = (s32)item; + func_80024054(((u8 *)&D_801938B4), D_801EA0EC); + func_8001CE28(item, D_801EA0EC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801EA0B8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801EA108, 0x84); + func_8001CE68(item, D_801EA108); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801EA108, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EA0B8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801EA0B8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_801627E8); + + +extern void (*D_801938D8[])(void); + +void func_80162834(void *a0) { + D_801938D8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801938C8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801938C8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E9854[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E9854, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E9854[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E9854, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801938E0[])(void); + +void func_80163A58(void *a0) { + D_801938E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E985C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E985C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80193934[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80193934[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801938FC; +extern s16 D_80193930; +extern s16 D_8019392E; +extern s16 D_8019392C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801938FC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80193930 = 0x80; + D_8019392E = 0x80; + D_8019392C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80193930 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80193930` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80193930 - 8; + D_80193930 = nv; + D_8019392E = nv; + D_8019392C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80193940[])(void); + +void func_80164BA0(void *a0) { + D_80193940[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801EA118; +extern u8 D_801EA119; +extern u8 D_801EA11A; +extern u8 D_801EA11B; +extern u8 D_801EA11C; +extern u8 D_801EA11D; +extern u8 D_801EA11E; +extern u8 D_801EA11F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801EA118; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801EA119 = 0xf0; + *(u8 *)base = 0xf0; + D_801EA11A = 0xc0; + D_801EA11E = 0; + D_801EA11D = 0; + D_801EA11C = 0; + D_801EA11F = 0; + D_801EA11B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801EA118; +extern u8 D_801EA119; +extern u8 D_801EA11A; + +s32 func_80164E40(void) { + u8 *p = &D_801EA118; + if (*p != 0) { + *p -= 0x10; + } + if (D_801EA119 != 0) { + D_801EA119 -= 0x10; + } + if (D_801EA11A != 0) { + D_801EA11A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80193950[])(void); + +void func_80164EA4(void *a0) { + D_80193950[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801EA164[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801EA164[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801EA158[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801EA158[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801EA158[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801EA158; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801EA158; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80193964[]; + extern u32 D_80193984, D_80193988, D_8019398C, D_80193990; + extern u32 D_80193984, D_80193988, D_8019398C, D_80193990; + extern u32 D_80193984, D_80193988, D_8019398C, D_80193990; + extern u32 D_80193984, D_80193988, D_8019398C, D_80193990; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80193964[0x00], p); + ApplyMatrixSV(mat, &D_80193964[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80193964[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80193964[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8019398C; + *(u32 *)(prim + 0x24) = D_80193984; + *(u32 *)(prim + 0x28) = D_80193990; + *(u32 *)(prim + 0x2c) = D_80193988; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80193994[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80193994[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80193994[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80193994[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80193A10[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80193A10[a1 & 0x7F]; +} + + + +extern s32 D_80193A30[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80193A30[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80193AAC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80193AAC[a1 & 0x7F]; +} + + + +extern u8 D_80193ACC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80193ACC[a1 & 0x7F]; +} + + + +extern u8 D_80193AEC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80193AEC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80193B0C[])(void); + D_80193B0C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80193B88[])(void); + +void func_80165AC8(void) { + D_80193B88[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80193C04[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80193C04[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E9864; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E9864, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80193C10[])(void); + +void func_80166018(void *a0) { + D_80193C10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80193C18[])(void); + +void func_801663FC(void *a0) { + D_80193C18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80193CE0[])(void); + +void func_80166618(void *a0) { + D_80193CE0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80193CF0[])(void); + +void func_80166654(void *a0) { + D_80193CF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801EA1D8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801EA1D8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EA1D8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801EA1D8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801EA1D8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801EA1D8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801EA1D8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80193C34[]; + extern u8 D_80193C20[]; + extern u8 D_80193C48[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80193C34; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80193C20; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80193C48; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80167714); + + +extern void (*D_80193D00[])(void); + +void func_801678B4(void *a0) { + D_80193D00[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80193D0C[])(void); + +void func_80167A9C(void *a0) { + D_80193D0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80193E18; + extern u8 D_80193E2C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80193E18); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80193E2C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80193C6C[]; +extern u8 D_80193C80[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80193C6C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80193C80; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80193D24[])(void); + +void func_80168744(void *a0) { + D_80193D24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80193D14 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80193D14[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80193D14; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80193D2C[])(void); + +void func_801689D8(void *a0) { + D_80193D2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80193D34[])(void); + +void func_80168AA8(void *a0) { + D_80193D34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80193D3C[])(void); + +void func_80168D58(void *a0) { + D_80193D3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80193D44[])(void); + +void func_8016901C(void *a0) { + D_80193D44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_011/nonmatchings/ov_SC02_011_jr_8015C32C", func_80169228); + + +extern void (*D_80193D4C[])(void); + +void func_801693CC(void *a0) { + D_80193D4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80193D54[])(void); + +void func_80169830(void *a0) { + D_80193D54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80193E08[])(void); + +void func_80169B80(void *a0) { + D_80193E08[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80193D5C[]; + extern u8 D_80193DCC[]; + extern u8 D_80193DFC[]; + extern u8 D_801EB938[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80193DFC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80193D5C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801EB938; + RotMatrixYXZ(rot, D_801EB938); + func_80048D9C(D_801EB938, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80193DCC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80193E10[])(void); + +void func_80169F00(void *a0) { + D_80193E10[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80193DC0[]; +extern char D_80193D80[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80193DC0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80193D80); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80193E48[])(void); + +void func_8016A020(void *a0) { + D_80193E48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80193E18; + extern u8 D_80193E2C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80193E18); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80193E2C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80193E54[])(void); + +void func_8016A700(void *a0) { + D_80193E54[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80193E9C[])(void); + +void func_8016AB30(void *a0) { + D_80193E9C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_015/ov_SC02_015_jr_8015AE2C.c b/src/ov_SC02_015/ov_SC02_015_jr_8015AE2C.c index 152bd00ba..348c6f046 100644 --- a/src/ov_SC02_015/ov_SC02_015_jr_8015AE2C.c +++ b/src/ov_SC02_015/ov_SC02_015_jr_8015AE2C.c @@ -1640,4590 +1640,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80180A6C[])(void); - -void func_8015C714(void *a0) { - D_80180A6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801808E0[])(void*); - extern int D_80180884; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801808E0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801808E0)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180884); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801808E0[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801808E0[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801808E0[])(void*); - extern int D_80180884; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801808E0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180884); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801808E0)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80180A7C[])(void); - D_80180A7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801808E0[])(struct Ent_8015CD20 *); - extern u8 D_80180894; - extern u8 D_80180A84; - extern u8 D_80180A94; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801808E0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180894); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180A84); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180A94); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801808E0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80180AB4[])(void); - D_80180AB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80180AA4; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80180AA4 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801808E0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80180B10; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80180B10, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8017FBF4[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8017FBF4; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80180B18[])(void); - D_80180B18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80180B24[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80180B24[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80180B24[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80180B24[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801808E0[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80180B24[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801808A4[]; - extern u8 D_801808B4[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801808A4); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801808B4); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80180B24[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180B24[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180B24[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80180B58[])(void); - D_80180B58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801808E0[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180B60[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80180B78[])(void); - D_80180B78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801808E0[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180B60[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80180B98[])(void); - D_80180B98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801808E0[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801808E0)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80180BA8; -extern u16 D_80180BAA; -extern u16 D_80180BAC; -extern s32 D_80180BB0; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80180BA8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80180BAA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80180BAC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180BB0, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80180BB8; - -void func_8015E588(void) { - func_8013C9C4(&D_80180BB8); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801808E0[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801808E0)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80180BCC[])(void); - D_80180BCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801808E0[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801808E0[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80180BD4[])(void); - D_80180BD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801808C4; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801808C4); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801808E0[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80180BDC[])(void); - D_80180BDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801808E0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801808E0[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80180BE4[])(void); - D_80180BE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801808E0[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80180BEC; - extern s32 D_80180BFC; - extern s32 D_80180C0C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801808E0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180BEC); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180BFC); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801808E0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180C0C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80180C1C[])(void); - D_80180C1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801808E0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801808E0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801808E0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801808E0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80180C28[])(void); - D_80180C28[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801808E0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801808E0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801808E0[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801808E0[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80180C3C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80180C3C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801808E0[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801808E0)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801808E0[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801808E0[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80180CB8[])(void); - D_80180CB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801808E0[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801808E0)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80180CC8[])(void); - D_80180CC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801808E0[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801808E0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801808E0[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801808E0[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801808E0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801808E0[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801808E0[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80180CD0[])(void); - D_80180CD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801808E0[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801808E0)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801808E0[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801808E0)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80180CDC[])(void); - D_80180CDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801808E0 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801808E0[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801808E0[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801808E0[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80180CEC[])(void); - -void func_80160EA4(void *a0) { - D_80180CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801808E0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801808E0[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80180D1C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80180D1C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80180D80; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80180D80); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8018F1E0[]; - extern u8 D_80180D4C[]; - extern u8 D_80180D6C[]; - extern u8 D_8018F1EC[]; - extern u8 D_8018F214[]; - extern u8 D_8018F22C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8018F1E0[0] = p; - func_80024054(&D_80180D4C, &D_8018F1EC); - func_8001CE28(p, &D_8018F1EC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8018F1E0[1] = p; - func_80024054(&D_80180D6C, &D_8018F214); - func_8001CE28(p, &D_8018F214); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8018F1E0[2] = p; - func_800242D0((s16)func_801620C4(), &D_8018F22C, 0x84); - func_8001CE68(p, &D_8018F22C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8018F22C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018F1E0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8018F1E0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80180D80; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80180D80; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80180D80; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80180D80; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8018F1E0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8018F1E0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80180DA4[])(void); - -void func_80162330(void *a0) { - D_80180DA4[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8018F238[i] via `extern int D_8018F238[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80180DB0[]; - extern s32 D_80180DC8; - extern u8 D_8018F244[]; - extern u8 D_8018F26C[]; - extern u8 D_8018F288[]; - extern int D_8018F238[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8018F238[0] = (s32)item; - func_80024054(D_80180DB0, D_8018F244); - func_8001CE28(item, D_8018F244); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8018F238[1] = (s32)item; - func_80024054(((u8 *)&D_80180DC8), D_8018F26C); - func_8001CE28(item, D_8018F26C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8018F238[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8018F288, 0x84); - func_8001CE68(item, D_8018F288); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8018F288, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018F238[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8018F238; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_801627E8); - - -extern void (*D_80180DEC[])(void); - -void func_80162834(void *a0) { - D_80180DEC[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80180DDC; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80180DDC, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8018EAAC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8018EAAC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8018EAAC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8018EAAC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80180DF4[])(void); - -void func_80163A58(void *a0) { - D_80180DF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8018EAB4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8018EAB4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80180E48[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80180E48[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80180E10; -extern s16 D_80180E44; -extern s16 D_80180E42; -extern s16 D_80180E40; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80180E10; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80180E44 = 0x80; - D_80180E42 = 0x80; - D_80180E40 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80180E44 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180E44` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80180E44 - 8; - D_80180E44 = nv; - D_80180E42 = nv; - D_80180E40 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80180E54[])(void); - -void func_80164BA0(void *a0) { - D_80180E54[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8018F298; -extern u8 D_8018F299; -extern u8 D_8018F29A; -extern u8 D_8018F29B; -extern u8 D_8018F29C; -extern u8 D_8018F29D; -extern u8 D_8018F29E; -extern u8 D_8018F29F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8018F298; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8018F299 = 0xf0; - *(u8 *)base = 0xf0; - D_8018F29A = 0xc0; - D_8018F29E = 0; - D_8018F29D = 0; - D_8018F29C = 0; - D_8018F29F = 0; - D_8018F29B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8018F298; -extern u8 D_8018F299; -extern u8 D_8018F29A; - -s32 func_80164E40(void) { - u8 *p = &D_8018F298; - if (*p != 0) { - *p -= 0x10; - } - if (D_8018F299 != 0) { - D_8018F299 -= 0x10; - } - if (D_8018F29A != 0) { - D_8018F29A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80180E64[])(void); - -void func_80164EA4(void *a0) { - D_80180E64[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8018F2E4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8018F2E4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8018F2D8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8018F2D8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8018F2D8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8018F2D8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8018F2D8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80180E78[]; - extern u32 D_80180E98, D_80180E9C, D_80180EA0, D_80180EA4; - extern u32 D_80180E98, D_80180E9C, D_80180EA0, D_80180EA4; - extern u32 D_80180E98, D_80180E9C, D_80180EA0, D_80180EA4; - extern u32 D_80180E98, D_80180E9C, D_80180EA0, D_80180EA4; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80180E78[0x00], p); - ApplyMatrixSV(mat, &D_80180E78[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80180E78[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80180E78[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80180EA0; - *(u32 *)(prim + 0x24) = D_80180E98; - *(u32 *)(prim + 0x28) = D_80180EA4; - *(u32 *)(prim + 0x2c) = D_80180E9C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80180EA8[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80180EA8[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80180EA8[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80180EA8[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80180F24[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80180F24[a1 & 0x7F]; -} - - - -extern s32 D_80180F44[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80180F44[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80180FC0[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80180FC0[a1 & 0x7F]; -} - - - -extern u8 D_80180FE0[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80180FE0[a1 & 0x7F]; -} - - - -extern u8 D_80181000[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181000[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80181020[])(void); - D_80181020[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018109C[])(void); - -void func_80165AC8(void) { - D_8018109C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181118[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181118[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8018EABC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8018EABC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80181124[])(void); - -void func_80166018(void *a0) { - D_80181124[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018112C[])(void); - -void func_801663FC(void *a0) { - D_8018112C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801811F4[])(void); - -void func_80166618(void *a0) { - D_801811F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181204[])(void); - -void func_80166654(void *a0) { - D_80181204[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8018F358[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8018F358[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018F358). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8018F358[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8018F358)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8018F358[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8018F358[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80181148[]; - extern u8 D_80181134[]; - extern u8 D_8018115C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80181148; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80181134; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018115C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80167714); - - -extern void (*D_80181214[])(void); - -void func_801678B4(void *a0) { - D_80181214[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181220[])(void); - -void func_80167A9C(void *a0) { - D_80181220[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018132C; - extern u8 D_80181340[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018132C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181340; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80181180[]; -extern u8 D_80181194[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80181180; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181194; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181238[])(void); - -void func_80168744(void *a0) { - D_80181238[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181228 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181228[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181228; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181240[])(void); - -void func_801689D8(void *a0) { - D_80181240[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181248[])(void); - -void func_80168AA8(void *a0) { - D_80181248[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181250[])(void); - -void func_80168D58(void *a0) { - D_80181250[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181258[])(void); - -void func_8016901C(void *a0) { - D_80181258[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015AE2C", func_80169228); - - -extern void (*D_80181260[])(void); - -void func_801693CC(void *a0) { - D_80181260[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181268[])(void); - -void func_80169830(void *a0) { - D_80181268[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018131C[])(void); - -void func_80169B80(void *a0) { - D_8018131C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181270[]; - extern u8 D_801812E0[]; - extern u8 D_80181310[]; - extern u8 D_80190558[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181310, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181270[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80190558; - RotMatrixYXZ(rot, D_80190558); - func_80048D9C(D_80190558, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801812E0); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181324[])(void); - -void func_80169F00(void *a0) { - D_80181324[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801812D4[]; -extern char D_80181294[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801812D4, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181294); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018135C[])(void); - -void func_8016A020(void *a0) { - D_8018135C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018132C; - extern u8 D_80181340[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018132C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181340; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181368[])(void); - -void func_8016A700(void *a0) { - D_80181368[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801813B0[])(void); - -void func_8016AB30(void *a0) { - D_801813B0[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c b/src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c new file mode 100644 index 000000000..ee51a4d51 --- /dev/null +++ b/src/ov_SC02_015/ov_SC02_015_jr_8015C32C.c @@ -0,0 +1,5945 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018077C; +extern u8 D_801806EC; +extern u8 D_801806C8; +extern u8 D_801806A4; +extern u8 D_80180758; +extern u8 D_80180734; +extern u8 D_80180710; +extern u8 D_80180680; +extern void func_80145934(void); +extern u8 D_8018080C; +extern u8 D_801807E8; +extern u8 D_801807C4; +extern u8 D_801807A0; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8017FC04[]; +extern unsigned char D_8017FC34[]; +extern unsigned char D_8017FC84[]; +extern unsigned char D_8017FCB4[]; +extern unsigned char D_8017FCE4[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8017FD34[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8017FDFC[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8017FE84[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8017FE8C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8018F188; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8018F18C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8017FEBC; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8017FF64[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8017FF88[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8017FF78; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8017FF9C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8017FFA8[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8017FFB8[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8017FFD0[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8017FFC0; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8017FFE4[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8017FFF0; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80180014[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80180028[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018003C; +extern void (*D_80180064[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80180044; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801800B0[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801800B4[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180518[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180528[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8018F1C0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180550[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180530; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180540; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180590[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180598[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180564; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801805A4[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180574; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8018F1C8; +extern s32 D_8018F1D4; +extern s32 D_8018F1D8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801805E0[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801805B4[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8018F1D0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80180830[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180650[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801808D4[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80180A28[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80180844; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80180A30[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80180854; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80180874; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80180A38[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80180A60[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801808E0[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80180A6C[])(void); + +void func_8015C714(void *a0) { + D_80180A6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801808E0[])(void*); + extern int D_80180884; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801808E0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801808E0)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180884); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801808E0[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801808E0[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801808E0[])(void*); + extern int D_80180884; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801808E0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180884); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801808E0)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80180A7C[])(void); + D_80180A7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801808E0[])(struct Ent_8015CD20 *); + extern u8 D_80180894; + extern u8 D_80180A84; + extern u8 D_80180A94; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801808E0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180894); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180A84); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180A94); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801808E0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80180AB4[])(void); + D_80180AB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80180AA4; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80180AA4 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801808E0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80180B10; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80180B10, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8017FBF4[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8017FBF4; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80180B18[])(void); + D_80180B18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80180B24[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80180B24[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80180B24[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80180B24[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801808E0[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80180B24[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801808A4[]; + extern u8 D_801808B4[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801808A4); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801808B4); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80180B24[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180B24[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180B24[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80180B58[])(void); + D_80180B58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801808E0[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180B60[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80180B78[])(void); + D_80180B78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801808E0[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180B60[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180B60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80180B98[])(void); + D_80180B98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801808E0[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801808E0)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80180BA8; +extern u16 D_80180BAA; +extern u16 D_80180BAC; +extern s32 D_80180BB0; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80180BA8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80180BAA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80180BAC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180BB0, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80180BB8; + +void func_8015E588(void) { + func_8013C9C4(&D_80180BB8); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801808E0[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801808E0)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80180BCC[])(void); + D_80180BCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801808E0[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801808E0[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80180BD4[])(void); + D_80180BD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801808C4; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801808C4); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801808E0[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80180BDC[])(void); + D_80180BDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801808E0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801808E0[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80180BE4[])(void); + D_80180BE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801808E0[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80180BEC; + extern s32 D_80180BFC; + extern s32 D_80180C0C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180BEC); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180BFC); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801808E0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180C0C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80180C1C[])(void); + D_80180C1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801808E0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801808E0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801808E0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801808E0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80180C28[])(void); + D_80180C28[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801808E0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801808E0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801808E0[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801808E0[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80180C3C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80180C3C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801808E0[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801808E0)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801808E0[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801808E0[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80180CB8[])(void); + D_80180CB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801808E0[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801808E0)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80180CC8[])(void); + D_80180CC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801808E0[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801808E0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801808E0[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801808E0[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801808E0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801808E0[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801808E0[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80180CD0[])(void); + D_80180CD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801808E0[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801808E0)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801808E0[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801808E0)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80180CDC[])(void); + D_80180CDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801808E0 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801808E0[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801808E0[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801808E0[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80180CEC[])(void); + +void func_80160EA4(void *a0) { + D_80180CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801808E0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801808E0[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80180D1C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80180D1C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80180D80; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80180D80); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8018F1E0[]; + extern u8 D_80180D4C[]; + extern u8 D_80180D6C[]; + extern u8 D_8018F1EC[]; + extern u8 D_8018F214[]; + extern u8 D_8018F22C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8018F1E0[0] = p; + func_80024054(&D_80180D4C, &D_8018F1EC); + func_8001CE28(p, &D_8018F1EC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8018F1E0[1] = p; + func_80024054(&D_80180D6C, &D_8018F214); + func_8001CE28(p, &D_8018F214); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8018F1E0[2] = p; + func_800242D0((s16)func_801620C4(), &D_8018F22C, 0x84); + func_8001CE68(p, &D_8018F22C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8018F22C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018F1E0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8018F1E0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80180D80; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80180D80; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80180D80; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80180D80; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8018F1E0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8018F1E0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80180DA4[])(void); + +void func_80162330(void *a0) { + D_80180DA4[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8018F238[i] via `extern int D_8018F238[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80180DB0[]; + extern s32 D_80180DC8; + extern u8 D_8018F244[]; + extern u8 D_8018F26C[]; + extern u8 D_8018F288[]; + extern int D_8018F238[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8018F238[0] = (s32)item; + func_80024054(D_80180DB0, D_8018F244); + func_8001CE28(item, D_8018F244); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8018F238[1] = (s32)item; + func_80024054(((u8 *)&D_80180DC8), D_8018F26C); + func_8001CE28(item, D_8018F26C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8018F238[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8018F288, 0x84); + func_8001CE68(item, D_8018F288); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8018F288, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018F238[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8018F238; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_801627E8); + + +extern void (*D_80180DEC[])(void); + +void func_80162834(void *a0) { + D_80180DEC[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80180DDC; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80180DDC, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8018EAAC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8018EAAC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8018EAAC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8018EAAC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80180DF4[])(void); + +void func_80163A58(void *a0) { + D_80180DF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8018EAB4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8018EAB4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80180E48[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80180E48[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80180E10; +extern s16 D_80180E44; +extern s16 D_80180E42; +extern s16 D_80180E40; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80180E10; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80180E44 = 0x80; + D_80180E42 = 0x80; + D_80180E40 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80180E44 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180E44` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80180E44 - 8; + D_80180E44 = nv; + D_80180E42 = nv; + D_80180E40 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80180E54[])(void); + +void func_80164BA0(void *a0) { + D_80180E54[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8018F298; +extern u8 D_8018F299; +extern u8 D_8018F29A; +extern u8 D_8018F29B; +extern u8 D_8018F29C; +extern u8 D_8018F29D; +extern u8 D_8018F29E; +extern u8 D_8018F29F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8018F298; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8018F299 = 0xf0; + *(u8 *)base = 0xf0; + D_8018F29A = 0xc0; + D_8018F29E = 0; + D_8018F29D = 0; + D_8018F29C = 0; + D_8018F29F = 0; + D_8018F29B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8018F298; +extern u8 D_8018F299; +extern u8 D_8018F29A; + +s32 func_80164E40(void) { + u8 *p = &D_8018F298; + if (*p != 0) { + *p -= 0x10; + } + if (D_8018F299 != 0) { + D_8018F299 -= 0x10; + } + if (D_8018F29A != 0) { + D_8018F29A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80180E64[])(void); + +void func_80164EA4(void *a0) { + D_80180E64[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8018F2E4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8018F2E4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8018F2D8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8018F2D8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8018F2D8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8018F2D8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8018F2D8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80180E78[]; + extern u32 D_80180E98, D_80180E9C, D_80180EA0, D_80180EA4; + extern u32 D_80180E98, D_80180E9C, D_80180EA0, D_80180EA4; + extern u32 D_80180E98, D_80180E9C, D_80180EA0, D_80180EA4; + extern u32 D_80180E98, D_80180E9C, D_80180EA0, D_80180EA4; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80180E78[0x00], p); + ApplyMatrixSV(mat, &D_80180E78[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80180E78[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80180E78[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80180EA0; + *(u32 *)(prim + 0x24) = D_80180E98; + *(u32 *)(prim + 0x28) = D_80180EA4; + *(u32 *)(prim + 0x2c) = D_80180E9C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80180EA8[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80180EA8[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80180EA8[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80180EA8[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80180F24[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80180F24[a1 & 0x7F]; +} + + + +extern s32 D_80180F44[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80180F44[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80180FC0[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80180FC0[a1 & 0x7F]; +} + + + +extern u8 D_80180FE0[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80180FE0[a1 & 0x7F]; +} + + + +extern u8 D_80181000[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181000[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80181020[])(void); + D_80181020[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018109C[])(void); + +void func_80165AC8(void) { + D_8018109C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181118[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181118[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8018EABC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8018EABC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80181124[])(void); + +void func_80166018(void *a0) { + D_80181124[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018112C[])(void); + +void func_801663FC(void *a0) { + D_8018112C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801811F4[])(void); + +void func_80166618(void *a0) { + D_801811F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181204[])(void); + +void func_80166654(void *a0) { + D_80181204[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8018F358[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8018F358[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018F358). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8018F358[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8018F358)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8018F358[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8018F358[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80181148[]; + extern u8 D_80181134[]; + extern u8 D_8018115C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80181148; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80181134; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018115C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80167714); + + +extern void (*D_80181214[])(void); + +void func_801678B4(void *a0) { + D_80181214[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181220[])(void); + +void func_80167A9C(void *a0) { + D_80181220[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018132C; + extern u8 D_80181340[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018132C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181340; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80181180[]; +extern u8 D_80181194[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80181180; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181194; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181238[])(void); + +void func_80168744(void *a0) { + D_80181238[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181228 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181228[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181228; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181240[])(void); + +void func_801689D8(void *a0) { + D_80181240[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181248[])(void); + +void func_80168AA8(void *a0) { + D_80181248[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181250[])(void); + +void func_80168D58(void *a0) { + D_80181250[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181258[])(void); + +void func_8016901C(void *a0) { + D_80181258[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_015/nonmatchings/ov_SC02_015_jr_8015C32C", func_80169228); + + +extern void (*D_80181260[])(void); + +void func_801693CC(void *a0) { + D_80181260[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181268[])(void); + +void func_80169830(void *a0) { + D_80181268[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018131C[])(void); + +void func_80169B80(void *a0) { + D_8018131C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181270[]; + extern u8 D_801812E0[]; + extern u8 D_80181310[]; + extern u8 D_80190558[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181310, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181270[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80190558; + RotMatrixYXZ(rot, D_80190558); + func_80048D9C(D_80190558, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801812E0); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181324[])(void); + +void func_80169F00(void *a0) { + D_80181324[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801812D4[]; +extern char D_80181294[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801812D4, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181294); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018135C[])(void); + +void func_8016A020(void *a0) { + D_8018135C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018132C; + extern u8 D_80181340[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018132C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181340; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181368[])(void); + +void func_8016A700(void *a0) { + D_80181368[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801813B0[])(void); + +void func_8016AB30(void *a0) { + D_801813B0[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_016/ov_SC02_016_jr_8015AE2C.c b/src/ov_SC02_016/ov_SC02_016_jr_8015AE2C.c index 185f0485a..0212bb287 100644 --- a/src/ov_SC02_016/ov_SC02_016_jr_8015AE2C.c +++ b/src/ov_SC02_016/ov_SC02_016_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80186CA4[])(void); - -void func_8015C714(void *a0) { - D_80186CA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80186B18[])(void*); - extern int D_80186ABC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80186B18)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80186B18)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186ABC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80186B18[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80186B18[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80186B18[])(void*); - extern int D_80186ABC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80186B18)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186ABC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80186B18)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80186CB4[])(void); - D_80186CB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80186B18[])(struct Ent_8015CD20 *); - extern u8 D_80186ACC; - extern u8 D_80186CBC; - extern u8 D_80186CCC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80186B18[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186ACC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186CBC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186CCC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80186B18[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80186CEC[])(void); - D_80186CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80186CDC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80186CDC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80186B18[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80186D48; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80186D48, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80185E2C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80185E2C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80186D50[])(void); - D_80186D50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80186D5C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80186D5C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80186D5C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80186D5C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80186B18[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80186D5C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80186ADC[]; - extern u8 D_80186AEC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186ADC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186AEC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80186D5C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186D5C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186D5C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80186D90[])(void); - D_80186D90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186B18[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186D98[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80186DB0[])(void); - D_80186DB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186B18[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186D98[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80186DD0[])(void); - D_80186DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80186B18[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186B18)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80186DE0; -extern u16 D_80186DE2; -extern u16 D_80186DE4; -extern s32 D_80186DE8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80186DE0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80186DE2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80186DE4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186DE8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80186DF0; - -void func_8015E588(void) { - func_8013C9C4(&D_80186DF0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80186B18[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186B18)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80186E04[])(void); - D_80186E04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80186B18[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80186B18[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80186E0C[])(void); - D_80186E0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80186AFC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186AFC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80186B18[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80186E14[])(void); - D_80186E14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80186B18[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80186B18[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80186E1C[])(void); - D_80186E1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80186B18[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80186E24; - extern s32 D_80186E34; - extern s32 D_80186E44; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80186B18[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E24); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E34); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80186B18[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E44); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80186E54[])(void); - D_80186E54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80186B18[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80186B18[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80186B18[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186B18[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80186E60[])(void); - D_80186E60[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80186B18[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186B18[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80186B18[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186B18[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80186E74[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80186E74[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80186B18[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80186B18)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80186B18[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186B18[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80186EF0[])(void); - D_80186EF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80186B18[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80186B18)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80186F00[])(void); - D_80186F00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80186B18[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80186B18[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80186B18[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80186B18[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80186B18[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80186B18[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80186B18[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80186F08[])(void); - D_80186F08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80186B18[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80186B18)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80186B18[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80186B18)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80186F14[])(void); - D_80186F14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186B18 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80186B18[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80186B18[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80186B18[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80186F24[])(void); - -void func_80160EA4(void *a0) { - D_80186F24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80186B18[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80186B18[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80186F54[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80186F54[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80186FB8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80186FB8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B2DF8[]; - extern u8 D_80186F84[]; - extern u8 D_80186FA4[]; - extern u8 D_801B2E04[]; - extern u8 D_801B2E2C[]; - extern u8 D_801B2E44[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B2DF8[0] = p; - func_80024054(&D_80186F84, &D_801B2E04); - func_8001CE28(p, &D_801B2E04); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B2DF8[1] = p; - func_80024054(&D_80186FA4, &D_801B2E2C); - func_8001CE28(p, &D_801B2E2C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B2DF8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B2E44, 0x84); - func_8001CE68(p, &D_801B2E44); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B2E44, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B2DF8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B2DF8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80186FB8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80186FB8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80186FB8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80186FB8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B2DF8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B2DF8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80186FDC[])(void); - -void func_80162330(void *a0) { - D_80186FDC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B2E50[i] via `extern int D_801B2E50[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80186FE8[]; - extern s32 D_80187000; - extern u8 D_801B2E5C[]; - extern u8 D_801B2E84[]; - extern u8 D_801B2EA0[]; - extern int D_801B2E50[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B2E50[0] = (s32)item; - func_80024054(D_80186FE8, D_801B2E5C); - func_8001CE28(item, D_801B2E5C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B2E50[1] = (s32)item; - func_80024054(((u8 *)&D_80187000), D_801B2E84); - func_8001CE28(item, D_801B2E84); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B2E50[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B2EA0, 0x84); - func_8001CE68(item, D_801B2EA0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B2EA0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B2E50[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B2E50; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187024[])(void); - -void func_80162834(void *a0) { - D_80187024[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187014; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187014, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B268C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B268C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B268C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B268C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018702C[])(void); - -void func_80163A58(void *a0) { - D_8018702C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B2694; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B2694; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80187080[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80187080[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80187048; -extern s16 D_8018707C; -extern s16 D_8018707A; -extern s16 D_80187078; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80187048; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018707C = 0x80; - D_8018707A = 0x80; - D_80187078 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018707C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018707C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018707C - 8; - D_8018707C = nv; - D_8018707A = nv; - D_80187078 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018708C[])(void); - -void func_80164BA0(void *a0) { - D_8018708C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B2EB0; -extern u8 D_801B2EB1; -extern u8 D_801B2EB2; -extern u8 D_801B2EB3; -extern u8 D_801B2EB4; -extern u8 D_801B2EB5; -extern u8 D_801B2EB6; -extern u8 D_801B2EB7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B2EB0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B2EB1 = 0xf0; - *(u8 *)base = 0xf0; - D_801B2EB2 = 0xc0; - D_801B2EB6 = 0; - D_801B2EB5 = 0; - D_801B2EB4 = 0; - D_801B2EB7 = 0; - D_801B2EB3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B2EB0; -extern u8 D_801B2EB1; -extern u8 D_801B2EB2; - -s32 func_80164E40(void) { - u8 *p = &D_801B2EB0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B2EB1 != 0) { - D_801B2EB1 -= 0x10; - } - if (D_801B2EB2 != 0) { - D_801B2EB2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018709C[])(void); - -void func_80164EA4(void *a0) { - D_8018709C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B2EFC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B2EFC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B2EF0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B2EF0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B2EF0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B2EF0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B2EF0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801870B0[]; - extern u32 D_801870D0, D_801870D4, D_801870D8, D_801870DC; - extern u32 D_801870D0, D_801870D4, D_801870D8, D_801870DC; - extern u32 D_801870D0, D_801870D4, D_801870D8, D_801870DC; - extern u32 D_801870D0, D_801870D4, D_801870D8, D_801870DC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801870B0[0x00], p); - ApplyMatrixSV(mat, &D_801870B0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801870B0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801870B0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801870D8; - *(u32 *)(prim + 0x24) = D_801870D0; - *(u32 *)(prim + 0x28) = D_801870DC; - *(u32 *)(prim + 0x2c) = D_801870D4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801870E0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801870E0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801870E0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801870E0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018715C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018715C[a1 & 0x7F]; -} - - - -extern s32 D_8018717C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018717C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801871F8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801871F8[a1 & 0x7F]; -} - - - -extern u8 D_80187218[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80187218[a1 & 0x7F]; -} - - - -extern u8 D_80187238[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80187238[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80187258[])(void); - D_80187258[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801872D4[])(void); - -void func_80165AC8(void) { - D_801872D4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80187350[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80187350[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B269C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B269C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018735C[])(void); - -void func_80166018(void *a0) { - D_8018735C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80187364[])(void); - -void func_801663FC(void *a0) { - D_80187364[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018742C[])(void); - -void func_80166618(void *a0) { - D_8018742C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018743C[])(void); - -void func_80166654(void *a0) { - D_8018743C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B2F70[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B2F70[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B2F70). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B2F70[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B2F70)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B2F70[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B2F70[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80187380[]; - extern u8 D_8018736C[]; - extern u8 D_80187394[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80187380; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018736C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187394; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80167714); - - -extern void (*D_8018744C[])(void); - -void func_801678B4(void *a0) { - D_8018744C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80187458[])(void); - -void func_80167A9C(void *a0) { - D_80187458[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80187564; - extern u8 D_80187578[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80187564); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187578; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801873B8[]; -extern u8 D_801873CC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801873B8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801873CC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80187470[])(void); - -void func_80168744(void *a0) { - D_80187470[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80187460 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80187460[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80187460; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80187478[])(void); - -void func_801689D8(void *a0) { - D_80187478[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80187480[])(void); - -void func_80168AA8(void *a0) { - D_80187480[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80187488[])(void); - -void func_80168D58(void *a0) { - D_80187488[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80187490[])(void); - -void func_8016901C(void *a0) { - D_80187490[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015AE2C", func_80169228); - - -extern void (*D_80187498[])(void); - -void func_801693CC(void *a0) { - D_80187498[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801874A0[])(void); - -void func_80169830(void *a0) { - D_801874A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187554[])(void); - -void func_80169B80(void *a0) { - D_80187554[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801874A8[]; - extern u8 D_80187518[]; - extern u8 D_80187548[]; - extern u8 D_801B4990[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80187548, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801874A8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B4990; - RotMatrixYXZ(rot, D_801B4990); - func_80048D9C(D_801B4990, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80187518); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018755C[])(void); - -void func_80169F00(void *a0) { - D_8018755C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018750C[]; -extern char D_801874CC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018750C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801874CC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187594[])(void); - -void func_8016A020(void *a0) { - D_80187594[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80187564; - extern u8 D_80187578[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80187564); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187578; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801875A0[])(void); - -void func_8016A700(void *a0) { - D_801875A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801875E8[])(void); - -void func_8016AB30(void *a0) { - D_801875E8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c b/src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c new file mode 100644 index 000000000..612604c93 --- /dev/null +++ b/src/ov_SC02_016/ov_SC02_016_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801869B4; +extern u8 D_80186924; +extern u8 D_80186900; +extern u8 D_801868DC; +extern u8 D_80186990; +extern u8 D_8018696C; +extern u8 D_80186948; +extern u8 D_801868B8; +extern void func_80145934(void); +extern u8 D_80186A44; +extern u8 D_80186A20; +extern u8 D_801869FC; +extern u8 D_801869D8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80185E3C[]; +extern unsigned char D_80185E6C[]; +extern unsigned char D_80185EBC[]; +extern unsigned char D_80185EEC[]; +extern unsigned char D_80185F1C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80185F6C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80186034[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801860BC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801860C4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B2DA0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B2DA4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801860F4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018619C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801861C0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801861B0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801861D4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801861E0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801861F0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80186208[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801861F8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018621C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80186238[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80186228; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018624C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80186260[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80186274; +extern void (*D_8018629C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018627C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801862E8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801862EC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186750[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80186760[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B2DD8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80186788[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80186768; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80186778; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801867C8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801867D0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018679C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801867DC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801867AC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B2DE0; +extern s32 D_801B2DEC; +extern s32 D_801B2DF0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80186818[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801867EC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B2DE8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80186A68[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80186888[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80186B0C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80186C60[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186A7C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80186C68[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186A8C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80186AAC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80186C70[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80186C98[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80186B18[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80186CA4[])(void); + +void func_8015C714(void *a0) { + D_80186CA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80186B18[])(void*); + extern int D_80186ABC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80186B18)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80186B18)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186ABC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80186B18[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80186B18[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80186B18[])(void*); + extern int D_80186ABC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80186B18)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186ABC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80186B18)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80186CB4[])(void); + D_80186CB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80186B18[])(struct Ent_8015CD20 *); + extern u8 D_80186ACC; + extern u8 D_80186CBC; + extern u8 D_80186CCC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80186B18[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186ACC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186CBC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186CCC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80186B18[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80186CEC[])(void); + D_80186CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80186CDC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80186CDC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80186B18[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80186D48; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80186D48, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80185E2C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80185E2C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80186D50[])(void); + D_80186D50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80186D5C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80186D5C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80186D5C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80186D5C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80186B18[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80186D5C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80186ADC[]; + extern u8 D_80186AEC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186ADC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186AEC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80186D5C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186D5C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186D5C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80186D90[])(void); + D_80186D90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186B18[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186D98[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80186DB0[])(void); + D_80186DB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186B18[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186D98[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186D98[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80186DD0[])(void); + D_80186DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80186B18[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186B18)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80186DE0; +extern u16 D_80186DE2; +extern u16 D_80186DE4; +extern s32 D_80186DE8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80186DE0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80186DE2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80186DE4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186DE8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80186DF0; + +void func_8015E588(void) { + func_8013C9C4(&D_80186DF0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80186B18[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186B18)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80186E04[])(void); + D_80186E04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80186B18[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80186B18[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80186E0C[])(void); + D_80186E0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80186AFC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186AFC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80186B18[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80186E14[])(void); + D_80186E14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80186B18[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80186B18[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80186E1C[])(void); + D_80186E1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80186B18[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80186E24; + extern s32 D_80186E34; + extern s32 D_80186E44; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E24); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E34); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80186B18[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E44); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80186E54[])(void); + D_80186E54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80186B18[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80186B18[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80186B18[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186B18[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80186E60[])(void); + D_80186E60[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80186B18[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186B18[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80186B18[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186B18[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80186E74[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80186E74[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80186B18[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80186B18)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80186B18[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186B18[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80186EF0[])(void); + D_80186EF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80186B18[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80186B18)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80186F00[])(void); + D_80186F00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80186B18[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80186B18[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80186B18[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80186B18[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80186B18[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80186B18[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80186B18[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80186F08[])(void); + D_80186F08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80186B18[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80186B18)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80186B18[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80186B18)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80186F14[])(void); + D_80186F14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186B18 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80186B18[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80186B18[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80186B18[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80186F24[])(void); + +void func_80160EA4(void *a0) { + D_80186F24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80186B18[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80186B18[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80186F54[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80186F54[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80186FB8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80186FB8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B2DF8[]; + extern u8 D_80186F84[]; + extern u8 D_80186FA4[]; + extern u8 D_801B2E04[]; + extern u8 D_801B2E2C[]; + extern u8 D_801B2E44[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B2DF8[0] = p; + func_80024054(&D_80186F84, &D_801B2E04); + func_8001CE28(p, &D_801B2E04); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B2DF8[1] = p; + func_80024054(&D_80186FA4, &D_801B2E2C); + func_8001CE28(p, &D_801B2E2C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B2DF8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B2E44, 0x84); + func_8001CE68(p, &D_801B2E44); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B2E44, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B2DF8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B2DF8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80186FB8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80186FB8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80186FB8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80186FB8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B2DF8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B2DF8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80186FDC[])(void); + +void func_80162330(void *a0) { + D_80186FDC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B2E50[i] via `extern int D_801B2E50[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80186FE8[]; + extern s32 D_80187000; + extern u8 D_801B2E5C[]; + extern u8 D_801B2E84[]; + extern u8 D_801B2EA0[]; + extern int D_801B2E50[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B2E50[0] = (s32)item; + func_80024054(D_80186FE8, D_801B2E5C); + func_8001CE28(item, D_801B2E5C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B2E50[1] = (s32)item; + func_80024054(((u8 *)&D_80187000), D_801B2E84); + func_8001CE28(item, D_801B2E84); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B2E50[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B2EA0, 0x84); + func_8001CE68(item, D_801B2EA0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B2EA0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B2E50[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B2E50; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_801627E8); + + +extern void (*D_80187024[])(void); + +void func_80162834(void *a0) { + D_80187024[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187014; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187014, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B268C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B268C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B268C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B268C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018702C[])(void); + +void func_80163A58(void *a0) { + D_8018702C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B2694; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B2694; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80187080[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80187080[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80187048; +extern s16 D_8018707C; +extern s16 D_8018707A; +extern s16 D_80187078; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80187048; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018707C = 0x80; + D_8018707A = 0x80; + D_80187078 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018707C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018707C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018707C - 8; + D_8018707C = nv; + D_8018707A = nv; + D_80187078 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018708C[])(void); + +void func_80164BA0(void *a0) { + D_8018708C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B2EB0; +extern u8 D_801B2EB1; +extern u8 D_801B2EB2; +extern u8 D_801B2EB3; +extern u8 D_801B2EB4; +extern u8 D_801B2EB5; +extern u8 D_801B2EB6; +extern u8 D_801B2EB7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B2EB0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B2EB1 = 0xf0; + *(u8 *)base = 0xf0; + D_801B2EB2 = 0xc0; + D_801B2EB6 = 0; + D_801B2EB5 = 0; + D_801B2EB4 = 0; + D_801B2EB7 = 0; + D_801B2EB3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B2EB0; +extern u8 D_801B2EB1; +extern u8 D_801B2EB2; + +s32 func_80164E40(void) { + u8 *p = &D_801B2EB0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B2EB1 != 0) { + D_801B2EB1 -= 0x10; + } + if (D_801B2EB2 != 0) { + D_801B2EB2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018709C[])(void); + +void func_80164EA4(void *a0) { + D_8018709C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B2EFC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B2EFC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B2EF0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B2EF0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B2EF0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B2EF0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B2EF0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801870B0[]; + extern u32 D_801870D0, D_801870D4, D_801870D8, D_801870DC; + extern u32 D_801870D0, D_801870D4, D_801870D8, D_801870DC; + extern u32 D_801870D0, D_801870D4, D_801870D8, D_801870DC; + extern u32 D_801870D0, D_801870D4, D_801870D8, D_801870DC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801870B0[0x00], p); + ApplyMatrixSV(mat, &D_801870B0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801870B0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801870B0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801870D8; + *(u32 *)(prim + 0x24) = D_801870D0; + *(u32 *)(prim + 0x28) = D_801870DC; + *(u32 *)(prim + 0x2c) = D_801870D4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801870E0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801870E0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801870E0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801870E0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018715C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018715C[a1 & 0x7F]; +} + + + +extern s32 D_8018717C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018717C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801871F8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801871F8[a1 & 0x7F]; +} + + + +extern u8 D_80187218[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80187218[a1 & 0x7F]; +} + + + +extern u8 D_80187238[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80187238[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80187258[])(void); + D_80187258[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801872D4[])(void); + +void func_80165AC8(void) { + D_801872D4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80187350[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80187350[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B269C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B269C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018735C[])(void); + +void func_80166018(void *a0) { + D_8018735C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80187364[])(void); + +void func_801663FC(void *a0) { + D_80187364[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018742C[])(void); + +void func_80166618(void *a0) { + D_8018742C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018743C[])(void); + +void func_80166654(void *a0) { + D_8018743C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B2F70[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B2F70[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B2F70). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B2F70[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B2F70)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B2F70[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B2F70[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80187380[]; + extern u8 D_8018736C[]; + extern u8 D_80187394[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80187380; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018736C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187394; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80167714); + + +extern void (*D_8018744C[])(void); + +void func_801678B4(void *a0) { + D_8018744C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80187458[])(void); + +void func_80167A9C(void *a0) { + D_80187458[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80187564; + extern u8 D_80187578[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80187564); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187578; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801873B8[]; +extern u8 D_801873CC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801873B8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801873CC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80187470[])(void); + +void func_80168744(void *a0) { + D_80187470[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80187460 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80187460[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80187460; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80187478[])(void); + +void func_801689D8(void *a0) { + D_80187478[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80187480[])(void); + +void func_80168AA8(void *a0) { + D_80187480[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80187488[])(void); + +void func_80168D58(void *a0) { + D_80187488[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80187490[])(void); + +void func_8016901C(void *a0) { + D_80187490[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_016/nonmatchings/ov_SC02_016_jr_8015C32C", func_80169228); + + +extern void (*D_80187498[])(void); + +void func_801693CC(void *a0) { + D_80187498[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801874A0[])(void); + +void func_80169830(void *a0) { + D_801874A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187554[])(void); + +void func_80169B80(void *a0) { + D_80187554[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801874A8[]; + extern u8 D_80187518[]; + extern u8 D_80187548[]; + extern u8 D_801B4990[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80187548, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801874A8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B4990; + RotMatrixYXZ(rot, D_801B4990); + func_80048D9C(D_801B4990, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80187518); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018755C[])(void); + +void func_80169F00(void *a0) { + D_8018755C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018750C[]; +extern char D_801874CC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018750C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801874CC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187594[])(void); + +void func_8016A020(void *a0) { + D_80187594[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80187564; + extern u8 D_80187578[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80187564); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187578; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801875A0[])(void); + +void func_8016A700(void *a0) { + D_801875A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801875E8[])(void); + +void func_8016AB30(void *a0) { + D_801875E8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_017/ov_SC02_017_jr_8015AE2C.c b/src/ov_SC02_017/ov_SC02_017_jr_8015AE2C.c index 8379b4f54..792cecee2 100644 --- a/src/ov_SC02_017/ov_SC02_017_jr_8015AE2C.c +++ b/src/ov_SC02_017/ov_SC02_017_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018CCFC[])(void); - -void func_8015C714(void *a0) { - D_8018CCFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018CB70[])(void*); - extern int D_8018CB14; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018CB70)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018CB70)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018CB14); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018CB70[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018CB70[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018CB70[])(void*); - extern int D_8018CB14; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018CB70)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018CB14); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018CB70)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018CD0C[])(void); - D_8018CD0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018CB70[])(struct Ent_8015CD20 *); - extern u8 D_8018CB24; - extern u8 D_8018CD14; - extern u8 D_8018CD24; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018CB70[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CB24); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CD14); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CD24); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018CB70[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018CD44[])(void); - D_8018CD44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018CD34; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018CD34 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018CB70[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018CDA0; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018CDA0, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018BE84[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018BE84; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018CDA8[])(void); - D_8018CDA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018CDB4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018CDB4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018CDB4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018CDB4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018CB70[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018CDB4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018CB34[]; - extern u8 D_8018CB44[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018CB34); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018CB44); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018CDB4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018CDB4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018CDB4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018CDE8[])(void); - D_8018CDE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018CB70[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018CDF0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018CE08[])(void); - D_8018CE08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018CB70[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018CDF0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018CE28[])(void); - D_8018CE28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018CB70[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018CB70)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018CE38; -extern u16 D_8018CE3A; -extern u16 D_8018CE3C; -extern s32 D_8018CE40; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018CE38 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018CE3A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018CE3C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018CE40, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018CE48; - -void func_8015E588(void) { - func_8013C9C4(&D_8018CE48); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018CB70[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018CB70)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018CE5C[])(void); - D_8018CE5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018CB70[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018CB70[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018CE64[])(void); - D_8018CE64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018CB54; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018CB54); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018CB70[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018CE6C[])(void); - D_8018CE6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018CB70[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018CB70[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018CE74[])(void); - D_8018CE74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018CB70[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018CE7C; - extern s32 D_8018CE8C; - extern s32 D_8018CE9C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018CB70[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CE7C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CE8C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018CB70[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CE9C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018CEAC[])(void); - D_8018CEAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018CB70[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018CB70[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018CB70[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018CB70[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018CEB8[])(void); - D_8018CEB8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018CB70[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018CB70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018CB70[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018CB70[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018CECC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018CECC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018CB70[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018CB70)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018CB70[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018CB70[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018CF48[])(void); - D_8018CF48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018CB70[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018CB70)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018CF58[])(void); - D_8018CF58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018CB70[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018CB70[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018CB70[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018CB70[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018CB70[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018CB70[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018CB70[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018CF60[])(void); - D_8018CF60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018CB70[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018CB70)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018CB70[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018CB70)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018CF6C[])(void); - D_8018CF6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018CB70 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018CB70[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018CB70[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018CB70[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018CF7C[])(void); - -void func_80160EA4(void *a0) { - D_8018CF7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018CB70[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018CB70[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018CFAC[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018CFAC[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018D010; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018D010); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801EE620[]; - extern u8 D_8018CFDC[]; - extern u8 D_8018CFFC[]; - extern u8 D_801EE62C[]; - extern u8 D_801EE654[]; - extern u8 D_801EE66C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801EE620[0] = p; - func_80024054(&D_8018CFDC, &D_801EE62C); - func_8001CE28(p, &D_801EE62C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801EE620[1] = p; - func_80024054(&D_8018CFFC, &D_801EE654); - func_8001CE28(p, &D_801EE654); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801EE620[2] = p; - func_800242D0((s16)func_801620C4(), &D_801EE66C, 0x84); - func_8001CE68(p, &D_801EE66C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801EE66C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EE620[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801EE620; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018D010; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018D010; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018D010; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018D010; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801EE620[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801EE620; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018D034[])(void); - -void func_80162330(void *a0) { - D_8018D034[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801EE678[i] via `extern int D_801EE678[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018D040[]; - extern s32 D_8018D058; - extern u8 D_801EE684[]; - extern u8 D_801EE6AC[]; - extern u8 D_801EE6C8[]; - extern int D_801EE678[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801EE678[0] = (s32)item; - func_80024054(D_8018D040, D_801EE684); - func_8001CE28(item, D_801EE684); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801EE678[1] = (s32)item; - func_80024054(((u8 *)&D_8018D058), D_801EE6AC); - func_8001CE28(item, D_801EE6AC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801EE678[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801EE6C8, 0x84); - func_8001CE68(item, D_801EE6C8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801EE6C8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EE678[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801EE678; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018D07C[])(void); - -void func_80162834(void *a0) { - D_8018D07C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018D06C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018D06C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801EDEAC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801EDEAC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801EDEAC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801EDEAC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018D084[])(void); - -void func_80163A58(void *a0) { - D_8018D084[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801EDEB4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801EDEB4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018D0D8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018D0D8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018D0A0; -extern s16 D_8018D0D4; -extern s16 D_8018D0D2; -extern s16 D_8018D0D0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018D0A0; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018D0D4 = 0x80; - D_8018D0D2 = 0x80; - D_8018D0D0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018D0D4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D0D4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018D0D4 - 8; - D_8018D0D4 = nv; - D_8018D0D2 = nv; - D_8018D0D0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018D0E4[])(void); - -void func_80164BA0(void *a0) { - D_8018D0E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801EE6D8; -extern u8 D_801EE6D9; -extern u8 D_801EE6DA; -extern u8 D_801EE6DB; -extern u8 D_801EE6DC; -extern u8 D_801EE6DD; -extern u8 D_801EE6DE; -extern u8 D_801EE6DF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801EE6D8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801EE6D9 = 0xf0; - *(u8 *)base = 0xf0; - D_801EE6DA = 0xc0; - D_801EE6DE = 0; - D_801EE6DD = 0; - D_801EE6DC = 0; - D_801EE6DF = 0; - D_801EE6DB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801EE6D8; -extern u8 D_801EE6D9; -extern u8 D_801EE6DA; - -s32 func_80164E40(void) { - u8 *p = &D_801EE6D8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801EE6D9 != 0) { - D_801EE6D9 -= 0x10; - } - if (D_801EE6DA != 0) { - D_801EE6DA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018D0F4[])(void); - -void func_80164EA4(void *a0) { - D_8018D0F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801EE724[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801EE724[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801EE718[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801EE718[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801EE718[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801EE718; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801EE718; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018D108[]; - extern u32 D_8018D128, D_8018D12C, D_8018D130, D_8018D134; - extern u32 D_8018D128, D_8018D12C, D_8018D130, D_8018D134; - extern u32 D_8018D128, D_8018D12C, D_8018D130, D_8018D134; - extern u32 D_8018D128, D_8018D12C, D_8018D130, D_8018D134; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018D108[0x00], p); - ApplyMatrixSV(mat, &D_8018D108[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018D108[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018D108[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018D130; - *(u32 *)(prim + 0x24) = D_8018D128; - *(u32 *)(prim + 0x28) = D_8018D134; - *(u32 *)(prim + 0x2c) = D_8018D12C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018D138[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018D138[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018D138[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018D138[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018D1B4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018D1B4[a1 & 0x7F]; -} - - - -extern s32 D_8018D1D4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018D1D4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018D250[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018D250[a1 & 0x7F]; -} - - - -extern u8 D_8018D270[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018D270[a1 & 0x7F]; -} - - - -extern u8 D_8018D290[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018D290[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018D2B0[])(void); - D_8018D2B0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018D32C[])(void); - -void func_80165AC8(void) { - D_8018D32C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018D3A8[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018D3A8[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801EDEBC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801EDEBC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018D3B4[])(void); - -void func_80166018(void *a0) { - D_8018D3B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018D3BC[])(void); - -void func_801663FC(void *a0) { - D_8018D3BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018D484[])(void); - -void func_80166618(void *a0) { - D_8018D484[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018D494[])(void); - -void func_80166654(void *a0) { - D_8018D494[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801EE798[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801EE798[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EE798). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801EE798[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801EE798)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801EE798[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801EE798[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018D3D8[]; - extern u8 D_8018D3C4[]; - extern u8 D_8018D3EC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018D3D8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018D3C4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018D3EC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80167714); - - -extern void (*D_8018D4A4[])(void); - -void func_801678B4(void *a0) { - D_8018D4A4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018D4B0[])(void); - -void func_80167A9C(void *a0) { - D_8018D4B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018D5BC; - extern u8 D_8018D5D0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018D5BC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018D5D0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018D410[]; -extern u8 D_8018D424[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018D410; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018D424; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018D4C8[])(void); - -void func_80168744(void *a0) { - D_8018D4C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018D4B8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018D4B8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018D4B8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018D4D0[])(void); - -void func_801689D8(void *a0) { - D_8018D4D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018D4D8[])(void); - -void func_80168AA8(void *a0) { - D_8018D4D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018D4E0[])(void); - -void func_80168D58(void *a0) { - D_8018D4E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018D4E8[])(void); - -void func_8016901C(void *a0) { - D_8018D4E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015AE2C", func_80169228); - - -extern void (*D_8018D4F0[])(void); - -void func_801693CC(void *a0) { - D_8018D4F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018D4F8[])(void); - -void func_80169830(void *a0) { - D_8018D4F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018D5AC[])(void); - -void func_80169B80(void *a0) { - D_8018D5AC[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018D500[]; - extern u8 D_8018D570[]; - extern u8 D_8018D5A0[]; - extern u8 D_801EFBF0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018D5A0, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018D500[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801EFBF0; - RotMatrixYXZ(rot, D_801EFBF0); - func_80048D9C(D_801EFBF0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018D570); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018D5B4[])(void); - -void func_80169F00(void *a0) { - D_8018D5B4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018D564[]; -extern char D_8018D524[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018D564, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018D524); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018D5EC[])(void); - -void func_8016A020(void *a0) { - D_8018D5EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018D5BC; - extern u8 D_8018D5D0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018D5BC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018D5D0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018D5F8[])(void); - -void func_8016A700(void *a0) { - D_8018D5F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018D640[])(void); - -void func_8016AB30(void *a0) { - D_8018D640[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c b/src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c new file mode 100644 index 000000000..5c12b4873 --- /dev/null +++ b/src/ov_SC02_017/ov_SC02_017_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018CA0C; +extern u8 D_8018C97C; +extern u8 D_8018C958; +extern u8 D_8018C934; +extern u8 D_8018C9E8; +extern u8 D_8018C9C4; +extern u8 D_8018C9A0; +extern u8 D_8018C910; +extern void func_80145934(void); +extern u8 D_8018CA9C; +extern u8 D_8018CA78; +extern u8 D_8018CA54; +extern u8 D_8018CA30; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018BE94[]; +extern unsigned char D_8018BEC4[]; +extern unsigned char D_8018BF14[]; +extern unsigned char D_8018BF44[]; +extern unsigned char D_8018BF74[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018BFC4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018C08C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018C114[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018C11C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801EE5C8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801EE5CC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018C14C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018C1F4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018C218[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018C208; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018C22C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018C238[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018C248[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018C260[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018C250; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018C274[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018C290[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018C280; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018C2A4[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018C2B8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018C2CC; +extern void (*D_8018C2F4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018C2D4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018C340[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018C344[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018C7A8[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018C7B8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801EE600; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018C7E0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018C7C0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018C7D0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018C820[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018C828[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018C7F4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018C834[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018C804; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801EE608; +extern s32 D_801EE614; +extern s32 D_801EE618; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018C870[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018C844[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801EE610; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018CAC0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018C8E0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018CB64[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018CCB8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018CAD4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018CCC0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018CAE4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018CB04; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018CCC8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018CCF0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018CB70[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018CCFC[])(void); + +void func_8015C714(void *a0) { + D_8018CCFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018CB70[])(void*); + extern int D_8018CB14; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018CB70)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018CB70)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018CB14); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018CB70[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018CB70[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018CB70[])(void*); + extern int D_8018CB14; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018CB70)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018CB14); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018CB70)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018CD0C[])(void); + D_8018CD0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018CB70[])(struct Ent_8015CD20 *); + extern u8 D_8018CB24; + extern u8 D_8018CD14; + extern u8 D_8018CD24; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018CB70[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CB24); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CD14); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CD24); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018CB70[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018CD44[])(void); + D_8018CD44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018CD34; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018CD34 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018CB70[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018CDA0; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018CDA0, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018BE84[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018BE84; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018CDA8[])(void); + D_8018CDA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018CDB4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018CDB4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018CDB4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018CDB4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018CB70[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018CDB4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018CB34[]; + extern u8 D_8018CB44[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018CB34); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018CB44); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018CDB4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018CDB4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018CDB4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018CDE8[])(void); + D_8018CDE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018CB70[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018CDF0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018CE08[])(void); + D_8018CE08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018CB70[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018CDF0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018CDF0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018CE28[])(void); + D_8018CE28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018CB70[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018CB70)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018CE38; +extern u16 D_8018CE3A; +extern u16 D_8018CE3C; +extern s32 D_8018CE40; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018CE38 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018CE3A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018CE3C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018CE40, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018CE48; + +void func_8015E588(void) { + func_8013C9C4(&D_8018CE48); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018CB70[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018CB70)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018CE5C[])(void); + D_8018CE5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018CB70[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018CB70[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018CE64[])(void); + D_8018CE64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018CB54; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018CB54); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018CB70[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018CE6C[])(void); + D_8018CE6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018CB70[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018CB70[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018CE74[])(void); + D_8018CE74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018CB70[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018CE7C; + extern s32 D_8018CE8C; + extern s32 D_8018CE9C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CE7C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CE8C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018CB70[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CE9C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018CEAC[])(void); + D_8018CEAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018CB70[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018CB70[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018CB70[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018CB70[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018CEB8[])(void); + D_8018CEB8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018CB70[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018CB70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018CB70[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018CB70[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018CECC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018CECC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018CB70[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018CB70)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018CB70[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018CB70[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018CF48[])(void); + D_8018CF48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018CB70[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018CB70)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018CF58[])(void); + D_8018CF58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018CB70[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018CB70[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018CB70[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018CB70[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018CB70[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018CB70[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018CB70[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018CF60[])(void); + D_8018CF60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018CB70[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018CB70)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018CB70[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018CB70)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018CF6C[])(void); + D_8018CF6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018CB70 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018CB70[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018CB70[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018CB70[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018CF7C[])(void); + +void func_80160EA4(void *a0) { + D_8018CF7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018CB70[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018CB70[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018CFAC[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018CFAC[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018D010; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018D010); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801EE620[]; + extern u8 D_8018CFDC[]; + extern u8 D_8018CFFC[]; + extern u8 D_801EE62C[]; + extern u8 D_801EE654[]; + extern u8 D_801EE66C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801EE620[0] = p; + func_80024054(&D_8018CFDC, &D_801EE62C); + func_8001CE28(p, &D_801EE62C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801EE620[1] = p; + func_80024054(&D_8018CFFC, &D_801EE654); + func_8001CE28(p, &D_801EE654); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801EE620[2] = p; + func_800242D0((s16)func_801620C4(), &D_801EE66C, 0x84); + func_8001CE68(p, &D_801EE66C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801EE66C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EE620[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801EE620; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018D010; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018D010; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018D010; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018D010; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801EE620[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801EE620; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018D034[])(void); + +void func_80162330(void *a0) { + D_8018D034[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801EE678[i] via `extern int D_801EE678[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018D040[]; + extern s32 D_8018D058; + extern u8 D_801EE684[]; + extern u8 D_801EE6AC[]; + extern u8 D_801EE6C8[]; + extern int D_801EE678[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801EE678[0] = (s32)item; + func_80024054(D_8018D040, D_801EE684); + func_8001CE28(item, D_801EE684); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801EE678[1] = (s32)item; + func_80024054(((u8 *)&D_8018D058), D_801EE6AC); + func_8001CE28(item, D_801EE6AC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801EE678[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801EE6C8, 0x84); + func_8001CE68(item, D_801EE6C8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801EE6C8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EE678[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801EE678; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_801627E8); + + +extern void (*D_8018D07C[])(void); + +void func_80162834(void *a0) { + D_8018D07C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018D06C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018D06C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801EDEAC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801EDEAC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801EDEAC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801EDEAC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018D084[])(void); + +void func_80163A58(void *a0) { + D_8018D084[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801EDEB4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801EDEB4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018D0D8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018D0D8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018D0A0; +extern s16 D_8018D0D4; +extern s16 D_8018D0D2; +extern s16 D_8018D0D0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018D0A0; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018D0D4 = 0x80; + D_8018D0D2 = 0x80; + D_8018D0D0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018D0D4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D0D4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018D0D4 - 8; + D_8018D0D4 = nv; + D_8018D0D2 = nv; + D_8018D0D0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018D0E4[])(void); + +void func_80164BA0(void *a0) { + D_8018D0E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801EE6D8; +extern u8 D_801EE6D9; +extern u8 D_801EE6DA; +extern u8 D_801EE6DB; +extern u8 D_801EE6DC; +extern u8 D_801EE6DD; +extern u8 D_801EE6DE; +extern u8 D_801EE6DF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801EE6D8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801EE6D9 = 0xf0; + *(u8 *)base = 0xf0; + D_801EE6DA = 0xc0; + D_801EE6DE = 0; + D_801EE6DD = 0; + D_801EE6DC = 0; + D_801EE6DF = 0; + D_801EE6DB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801EE6D8; +extern u8 D_801EE6D9; +extern u8 D_801EE6DA; + +s32 func_80164E40(void) { + u8 *p = &D_801EE6D8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801EE6D9 != 0) { + D_801EE6D9 -= 0x10; + } + if (D_801EE6DA != 0) { + D_801EE6DA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018D0F4[])(void); + +void func_80164EA4(void *a0) { + D_8018D0F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801EE724[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801EE724[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801EE718[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801EE718[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801EE718[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801EE718; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801EE718; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018D108[]; + extern u32 D_8018D128, D_8018D12C, D_8018D130, D_8018D134; + extern u32 D_8018D128, D_8018D12C, D_8018D130, D_8018D134; + extern u32 D_8018D128, D_8018D12C, D_8018D130, D_8018D134; + extern u32 D_8018D128, D_8018D12C, D_8018D130, D_8018D134; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018D108[0x00], p); + ApplyMatrixSV(mat, &D_8018D108[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018D108[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018D108[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018D130; + *(u32 *)(prim + 0x24) = D_8018D128; + *(u32 *)(prim + 0x28) = D_8018D134; + *(u32 *)(prim + 0x2c) = D_8018D12C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018D138[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018D138[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018D138[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018D138[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018D1B4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018D1B4[a1 & 0x7F]; +} + + + +extern s32 D_8018D1D4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018D1D4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018D250[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018D250[a1 & 0x7F]; +} + + + +extern u8 D_8018D270[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018D270[a1 & 0x7F]; +} + + + +extern u8 D_8018D290[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018D290[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018D2B0[])(void); + D_8018D2B0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018D32C[])(void); + +void func_80165AC8(void) { + D_8018D32C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018D3A8[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018D3A8[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801EDEBC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801EDEBC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018D3B4[])(void); + +void func_80166018(void *a0) { + D_8018D3B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018D3BC[])(void); + +void func_801663FC(void *a0) { + D_8018D3BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018D484[])(void); + +void func_80166618(void *a0) { + D_8018D484[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018D494[])(void); + +void func_80166654(void *a0) { + D_8018D494[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801EE798[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801EE798[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EE798). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801EE798[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801EE798)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801EE798[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801EE798[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018D3D8[]; + extern u8 D_8018D3C4[]; + extern u8 D_8018D3EC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018D3D8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018D3C4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018D3EC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80167714); + + +extern void (*D_8018D4A4[])(void); + +void func_801678B4(void *a0) { + D_8018D4A4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018D4B0[])(void); + +void func_80167A9C(void *a0) { + D_8018D4B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018D5BC; + extern u8 D_8018D5D0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018D5BC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018D5D0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018D410[]; +extern u8 D_8018D424[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018D410; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018D424; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018D4C8[])(void); + +void func_80168744(void *a0) { + D_8018D4C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018D4B8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018D4B8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018D4B8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018D4D0[])(void); + +void func_801689D8(void *a0) { + D_8018D4D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018D4D8[])(void); + +void func_80168AA8(void *a0) { + D_8018D4D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018D4E0[])(void); + +void func_80168D58(void *a0) { + D_8018D4E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018D4E8[])(void); + +void func_8016901C(void *a0) { + D_8018D4E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_017/nonmatchings/ov_SC02_017_jr_8015C32C", func_80169228); + + +extern void (*D_8018D4F0[])(void); + +void func_801693CC(void *a0) { + D_8018D4F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018D4F8[])(void); + +void func_80169830(void *a0) { + D_8018D4F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018D5AC[])(void); + +void func_80169B80(void *a0) { + D_8018D5AC[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018D500[]; + extern u8 D_8018D570[]; + extern u8 D_8018D5A0[]; + extern u8 D_801EFBF0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018D5A0, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018D500[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801EFBF0; + RotMatrixYXZ(rot, D_801EFBF0); + func_80048D9C(D_801EFBF0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018D570); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018D5B4[])(void); + +void func_80169F00(void *a0) { + D_8018D5B4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018D564[]; +extern char D_8018D524[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018D564, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018D524); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018D5EC[])(void); + +void func_8016A020(void *a0) { + D_8018D5EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018D5BC; + extern u8 D_8018D5D0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018D5BC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018D5D0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018D5F8[])(void); + +void func_8016A700(void *a0) { + D_8018D5F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018D640[])(void); + +void func_8016AB30(void *a0) { + D_8018D640[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_021/ov_SC02_021_jr_8015AE2C.c b/src/ov_SC02_021/ov_SC02_021_jr_8015AE2C.c index 0a8ae274c..e5d095d93 100644 --- a/src/ov_SC02_021/ov_SC02_021_jr_8015AE2C.c +++ b/src/ov_SC02_021/ov_SC02_021_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801822F0[])(void); - -void func_8015C714(void *a0) { - D_801822F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80182164[])(void*); - extern int D_80182108; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80182164)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80182164)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182108); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80182164[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80182164[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80182164[])(void*); - extern int D_80182108; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80182164)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182108); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80182164)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80182300[])(void); - D_80182300[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80182164[])(struct Ent_8015CD20 *); - extern u8 D_80182118; - extern u8 D_80182308; - extern u8 D_80182318; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80182164[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182118); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182308); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182318); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80182164[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80182338[])(void); - D_80182338[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80182328; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80182328 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80182164[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80182394; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80182394, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80181478[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80181478; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018239C[])(void); - D_8018239C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801823A8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801823A8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801823A8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801823A8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80182164[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801823A8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80182128[]; - extern u8 D_80182138[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182128); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182138); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801823A8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801823A8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801823A8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801823DC[])(void); - D_801823DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182164[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801823E4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801823FC[])(void); - D_801823FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182164[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801823E4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018241C[])(void); - D_8018241C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80182164[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182164)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018242C; -extern u16 D_8018242E; -extern u16 D_80182430; -extern s32 D_80182434; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018242C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018242E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80182430 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182434, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018243C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018243C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80182164[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182164)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80182450[])(void); - D_80182450[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80182164[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80182164[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80182458[])(void); - D_80182458[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80182148; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182148); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80182164[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80182460[])(void); - D_80182460[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80182164[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80182164[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80182468[])(void); - D_80182468[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80182164[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80182470; - extern s32 D_80182480; - extern s32 D_80182490; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80182164[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182470); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182480); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80182164[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182490); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801824A0[])(void); - D_801824A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80182164[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80182164[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80182164[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182164[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801824AC[])(void); - D_801824AC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80182164[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182164[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80182164[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182164[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801824C0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801824C0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80182164[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80182164)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80182164[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182164[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018253C[])(void); - D_8018253C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80182164[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80182164)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018254C[])(void); - D_8018254C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80182164[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80182164[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80182164[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80182164[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80182164[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80182164[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80182164[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80182554[])(void); - D_80182554[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80182164[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80182164)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80182164[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80182164)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80182560[])(void); - D_80182560[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182164 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80182164[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80182164[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80182164[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80182570[])(void); - -void func_80160EA4(void *a0) { - D_80182570[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80182164[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80182164[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801825A0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801825A0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80182604; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80182604); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80191B90[]; - extern u8 D_801825D0[]; - extern u8 D_801825F0[]; - extern u8 D_80191B9C[]; - extern u8 D_80191BC4[]; - extern u8 D_80191BDC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80191B90[0] = p; - func_80024054(&D_801825D0, &D_80191B9C); - func_8001CE28(p, &D_80191B9C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80191B90[1] = p; - func_80024054(&D_801825F0, &D_80191BC4); - func_8001CE28(p, &D_80191BC4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80191B90[2] = p; - func_800242D0((s16)func_801620C4(), &D_80191BDC, 0x84); - func_8001CE68(p, &D_80191BDC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80191BDC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80191B90[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80191B90; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80182604; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80182604; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80182604; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80182604; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80191B90[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80191B90; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80182628[])(void); - -void func_80162330(void *a0) { - D_80182628[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80191BE8[i] via `extern int D_80191BE8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80182634[]; - extern s32 D_8018264C; - extern u8 D_80191BF4[]; - extern u8 D_80191C1C[]; - extern u8 D_80191C38[]; - extern int D_80191BE8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80191BE8[0] = (s32)item; - func_80024054(D_80182634, D_80191BF4); - func_8001CE28(item, D_80191BF4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80191BE8[1] = (s32)item; - func_80024054(((u8 *)&D_8018264C), D_80191C1C); - func_8001CE28(item, D_80191C1C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80191BE8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80191C38, 0x84); - func_8001CE68(item, D_80191C38); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80191C38, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80191BE8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80191BE8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_801627E8); - - -extern void (*D_80182670[])(void); - -void func_80162834(void *a0) { - D_80182670[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80182660; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80182660, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80191428[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80191428, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80191428[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80191428, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80182678[])(void); - -void func_80163A58(void *a0) { - D_80182678[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80191430; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80191430; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801826CC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801826CC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80182694; -extern s16 D_801826C8; -extern s16 D_801826C6; -extern s16 D_801826C4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80182694; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801826C8 = 0x80; - D_801826C6 = 0x80; - D_801826C4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801826C8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801826C8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801826C8 - 8; - D_801826C8 = nv; - D_801826C6 = nv; - D_801826C4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801826D8[])(void); - -void func_80164BA0(void *a0) { - D_801826D8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80191C48; -extern u8 D_80191C49; -extern u8 D_80191C4A; -extern u8 D_80191C4B; -extern u8 D_80191C4C; -extern u8 D_80191C4D; -extern u8 D_80191C4E; -extern u8 D_80191C4F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80191C48; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80191C49 = 0xf0; - *(u8 *)base = 0xf0; - D_80191C4A = 0xc0; - D_80191C4E = 0; - D_80191C4D = 0; - D_80191C4C = 0; - D_80191C4F = 0; - D_80191C4B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80191C48; -extern u8 D_80191C49; -extern u8 D_80191C4A; - -s32 func_80164E40(void) { - u8 *p = &D_80191C48; - if (*p != 0) { - *p -= 0x10; - } - if (D_80191C49 != 0) { - D_80191C49 -= 0x10; - } - if (D_80191C4A != 0) { - D_80191C4A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801826E8[])(void); - -void func_80164EA4(void *a0) { - D_801826E8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80191C94[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80191C94[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80191C88[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80191C88[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80191C88[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80191C88; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80191C88; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801826FC[]; - extern u32 D_8018271C, D_80182720, D_80182724, D_80182728; - extern u32 D_8018271C, D_80182720, D_80182724, D_80182728; - extern u32 D_8018271C, D_80182720, D_80182724, D_80182728; - extern u32 D_8018271C, D_80182720, D_80182724, D_80182728; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801826FC[0x00], p); - ApplyMatrixSV(mat, &D_801826FC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801826FC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801826FC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80182724; - *(u32 *)(prim + 0x24) = D_8018271C; - *(u32 *)(prim + 0x28) = D_80182728; - *(u32 *)(prim + 0x2c) = D_80182720; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018272C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018272C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018272C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018272C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801827A8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801827A8[a1 & 0x7F]; -} - - - -extern s32 D_801827C8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801827C8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80182844[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80182844[a1 & 0x7F]; -} - - - -extern u8 D_80182864[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182864[a1 & 0x7F]; -} - - - -extern u8 D_80182884[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182884[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801828A4[])(void); - D_801828A4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80182920[])(void); - -void func_80165AC8(void) { - D_80182920[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018299C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018299C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80191438; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80191438, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801829A8[])(void); - -void func_80166018(void *a0) { - D_801829A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801829B0[])(void); - -void func_801663FC(void *a0) { - D_801829B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182A78[])(void); - -void func_80166618(void *a0) { - D_80182A78[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182A88[])(void); - -void func_80166654(void *a0) { - D_80182A88[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80191D08[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80191D08[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80191D08). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80191D08[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80191D08)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80191D08[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80191D08[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801829CC[]; - extern u8 D_801829B8[]; - extern u8 D_801829E0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801829CC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801829B8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801829E0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80167714); - - -extern void (*D_80182A98[])(void); - -void func_801678B4(void *a0) { - D_80182A98[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80182AA4[])(void); - -void func_80167A9C(void *a0) { - D_80182AA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80182BB0; - extern u8 D_80182BC4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80182BB0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182BC4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80182A04[]; -extern u8 D_80182A18[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80182A04; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80182A18; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80182ABC[])(void); - -void func_80168744(void *a0) { - D_80182ABC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80182AAC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80182AAC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80182AAC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80182AC4[])(void); - -void func_801689D8(void *a0) { - D_80182AC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80182ACC[])(void); - -void func_80168AA8(void *a0) { - D_80182ACC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80182AD4[])(void); - -void func_80168D58(void *a0) { - D_80182AD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80182ADC[])(void); - -void func_8016901C(void *a0) { - D_80182ADC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015AE2C", func_80169228); - - -extern void (*D_80182AE4[])(void); - -void func_801693CC(void *a0) { - D_80182AE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80182AEC[])(void); - -void func_80169830(void *a0) { - D_80182AEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80182BA0[])(void); - -void func_80169B80(void *a0) { - D_80182BA0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80182AF4[]; - extern u8 D_80182B64[]; - extern u8 D_80182B94[]; - extern u8 D_80193758[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80182B94, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80182AF4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80193758; - RotMatrixYXZ(rot, D_80193758); - func_80048D9C(D_80193758, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182B64); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80182BA8[])(void); - -void func_80169F00(void *a0) { - D_80182BA8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80182B58[]; -extern char D_80182B18[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80182B58, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182B18); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80182BE0[])(void); - -void func_8016A020(void *a0) { - D_80182BE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80182BB0; - extern u8 D_80182BC4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80182BB0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182BC4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80182BEC[])(void); - -void func_8016A700(void *a0) { - D_80182BEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80182C34[])(void); - -void func_8016AB30(void *a0) { - D_80182C34[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c b/src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c new file mode 100644 index 000000000..6fcd32959 --- /dev/null +++ b/src/ov_SC02_021/ov_SC02_021_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80182000; +extern u8 D_80181F70; +extern u8 D_80181F4C; +extern u8 D_80181F28; +extern u8 D_80181FDC; +extern u8 D_80181FB8; +extern u8 D_80181F94; +extern u8 D_80181F04; +extern void func_80145934(void); +extern u8 D_80182090; +extern u8 D_8018206C; +extern u8 D_80182048; +extern u8 D_80182024; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80181488[]; +extern unsigned char D_801814B8[]; +extern unsigned char D_80181508[]; +extern unsigned char D_80181538[]; +extern unsigned char D_80181568[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801815B8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80181680[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80181708[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80181710; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80191B38; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_80191B3C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80181740; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801817E8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018180C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801817FC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80181820[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018182C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018183C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181854[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80181844; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181868[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181884[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181874; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181898[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801818AC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801818C0; +extern void (*D_801818E8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801818C8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80181934[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80181938[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80181D9C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80181DAC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80191B70; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80181DD4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80181DB4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80181DC4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80181E14[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80181E1C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80181DE8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80181E28[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80181DF8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80191B78; +extern s32 D_80191B84; +extern s32 D_80191B88; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80181E64[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80181E38[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80191B80; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801820B4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80181ED4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80182158[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801822AC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801820C8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801822B4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801820D8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801820F8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801822BC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801822E4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80182164[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80182164[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80182164[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80182164[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80182164[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80182164[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80182164[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80182164[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801822F0[])(void); + +void func_8015C714(void *a0) { + D_801822F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80182164[])(void*); + extern int D_80182108; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80182164)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80182164)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182108); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80182164[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80182164[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80182164[])(void*); + extern int D_80182108; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80182164)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182108); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80182164)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80182300[])(void); + D_80182300[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80182164[])(struct Ent_8015CD20 *); + extern u8 D_80182118; + extern u8 D_80182308; + extern u8 D_80182318; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80182164[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182118); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182308); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182318); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80182164[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80182338[])(void); + D_80182338[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80182328; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80182328 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80182164[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80182394; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80182394, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80181478[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80181478; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018239C[])(void); + D_8018239C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801823A8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801823A8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801823A8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801823A8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80182164[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801823A8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80182128[]; + extern u8 D_80182138[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182128); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182138); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801823A8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801823A8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801823A8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801823DC[])(void); + D_801823DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182164[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801823E4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801823FC[])(void); + D_801823FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182164[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801823E4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801823E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018241C[])(void); + D_8018241C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80182164[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182164)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018242C; +extern u16 D_8018242E; +extern u16 D_80182430; +extern s32 D_80182434; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018242C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018242E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80182430 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182434, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018243C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018243C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80182164[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182164)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80182450[])(void); + D_80182450[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80182164[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80182164[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80182458[])(void); + D_80182458[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80182148; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182148); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80182164[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80182460[])(void); + D_80182460[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80182164[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80182164[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80182468[])(void); + D_80182468[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80182164[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80182470; + extern s32 D_80182480; + extern s32 D_80182490; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80182164[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182470); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182480); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80182164[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182490); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801824A0[])(void); + D_801824A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80182164[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80182164[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80182164[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182164[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801824AC[])(void); + D_801824AC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80182164[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182164[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80182164[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182164[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801824C0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801824C0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80182164[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80182164)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80182164[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182164[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018253C[])(void); + D_8018253C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80182164[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80182164)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018254C[])(void); + D_8018254C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80182164[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80182164[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80182164[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80182164[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80182164[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80182164[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80182164[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80182554[])(void); + D_80182554[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80182164[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80182164)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80182164[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80182164)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80182560[])(void); + D_80182560[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182164 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80182164[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80182164[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80182164[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80182570[])(void); + +void func_80160EA4(void *a0) { + D_80182570[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80182164[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80182164[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801825A0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801825A0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80182604; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80182604); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80191B90[]; + extern u8 D_801825D0[]; + extern u8 D_801825F0[]; + extern u8 D_80191B9C[]; + extern u8 D_80191BC4[]; + extern u8 D_80191BDC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80191B90[0] = p; + func_80024054(&D_801825D0, &D_80191B9C); + func_8001CE28(p, &D_80191B9C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80191B90[1] = p; + func_80024054(&D_801825F0, &D_80191BC4); + func_8001CE28(p, &D_80191BC4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80191B90[2] = p; + func_800242D0((s16)func_801620C4(), &D_80191BDC, 0x84); + func_8001CE68(p, &D_80191BDC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80191BDC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80191B90[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80191B90; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80182604; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80182604; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80182604; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80182604; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80191B90[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80191B90; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80182628[])(void); + +void func_80162330(void *a0) { + D_80182628[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80191BE8[i] via `extern int D_80191BE8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80182634[]; + extern s32 D_8018264C; + extern u8 D_80191BF4[]; + extern u8 D_80191C1C[]; + extern u8 D_80191C38[]; + extern int D_80191BE8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80191BE8[0] = (s32)item; + func_80024054(D_80182634, D_80191BF4); + func_8001CE28(item, D_80191BF4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80191BE8[1] = (s32)item; + func_80024054(((u8 *)&D_8018264C), D_80191C1C); + func_8001CE28(item, D_80191C1C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80191BE8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80191C38, 0x84); + func_8001CE68(item, D_80191C38); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80191C38, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80191BE8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80191BE8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_801627E8); + + +extern void (*D_80182670[])(void); + +void func_80162834(void *a0) { + D_80182670[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80182660; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80182660, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80191428[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80191428, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80191428[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80191428, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80182678[])(void); + +void func_80163A58(void *a0) { + D_80182678[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80191430; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80191430; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801826CC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801826CC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80182694; +extern s16 D_801826C8; +extern s16 D_801826C6; +extern s16 D_801826C4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80182694; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801826C8 = 0x80; + D_801826C6 = 0x80; + D_801826C4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801826C8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801826C8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801826C8 - 8; + D_801826C8 = nv; + D_801826C6 = nv; + D_801826C4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801826D8[])(void); + +void func_80164BA0(void *a0) { + D_801826D8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80191C48; +extern u8 D_80191C49; +extern u8 D_80191C4A; +extern u8 D_80191C4B; +extern u8 D_80191C4C; +extern u8 D_80191C4D; +extern u8 D_80191C4E; +extern u8 D_80191C4F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80191C48; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80191C49 = 0xf0; + *(u8 *)base = 0xf0; + D_80191C4A = 0xc0; + D_80191C4E = 0; + D_80191C4D = 0; + D_80191C4C = 0; + D_80191C4F = 0; + D_80191C4B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80191C48; +extern u8 D_80191C49; +extern u8 D_80191C4A; + +s32 func_80164E40(void) { + u8 *p = &D_80191C48; + if (*p != 0) { + *p -= 0x10; + } + if (D_80191C49 != 0) { + D_80191C49 -= 0x10; + } + if (D_80191C4A != 0) { + D_80191C4A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801826E8[])(void); + +void func_80164EA4(void *a0) { + D_801826E8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80191C94[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80191C94[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80191C88[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80191C88[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80191C88[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80191C88; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80191C88; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801826FC[]; + extern u32 D_8018271C, D_80182720, D_80182724, D_80182728; + extern u32 D_8018271C, D_80182720, D_80182724, D_80182728; + extern u32 D_8018271C, D_80182720, D_80182724, D_80182728; + extern u32 D_8018271C, D_80182720, D_80182724, D_80182728; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801826FC[0x00], p); + ApplyMatrixSV(mat, &D_801826FC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801826FC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801826FC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80182724; + *(u32 *)(prim + 0x24) = D_8018271C; + *(u32 *)(prim + 0x28) = D_80182728; + *(u32 *)(prim + 0x2c) = D_80182720; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018272C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018272C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018272C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018272C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801827A8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801827A8[a1 & 0x7F]; +} + + + +extern s32 D_801827C8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801827C8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80182844[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80182844[a1 & 0x7F]; +} + + + +extern u8 D_80182864[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182864[a1 & 0x7F]; +} + + + +extern u8 D_80182884[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182884[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801828A4[])(void); + D_801828A4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80182920[])(void); + +void func_80165AC8(void) { + D_80182920[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018299C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018299C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80191438; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80191438, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801829A8[])(void); + +void func_80166018(void *a0) { + D_801829A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801829B0[])(void); + +void func_801663FC(void *a0) { + D_801829B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182A78[])(void); + +void func_80166618(void *a0) { + D_80182A78[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182A88[])(void); + +void func_80166654(void *a0) { + D_80182A88[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80191D08[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80191D08[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80191D08). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80191D08[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80191D08)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80191D08[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80191D08[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801829CC[]; + extern u8 D_801829B8[]; + extern u8 D_801829E0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801829CC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801829B8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801829E0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80167714); + + +extern void (*D_80182A98[])(void); + +void func_801678B4(void *a0) { + D_80182A98[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80182AA4[])(void); + +void func_80167A9C(void *a0) { + D_80182AA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80182BB0; + extern u8 D_80182BC4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80182BB0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182BC4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80182A04[]; +extern u8 D_80182A18[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80182A04; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80182A18; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80182ABC[])(void); + +void func_80168744(void *a0) { + D_80182ABC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80182AAC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80182AAC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80182AAC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80182AC4[])(void); + +void func_801689D8(void *a0) { + D_80182AC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80182ACC[])(void); + +void func_80168AA8(void *a0) { + D_80182ACC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80182AD4[])(void); + +void func_80168D58(void *a0) { + D_80182AD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80182ADC[])(void); + +void func_8016901C(void *a0) { + D_80182ADC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_021/nonmatchings/ov_SC02_021_jr_8015C32C", func_80169228); + + +extern void (*D_80182AE4[])(void); + +void func_801693CC(void *a0) { + D_80182AE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80182AEC[])(void); + +void func_80169830(void *a0) { + D_80182AEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80182BA0[])(void); + +void func_80169B80(void *a0) { + D_80182BA0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80182AF4[]; + extern u8 D_80182B64[]; + extern u8 D_80182B94[]; + extern u8 D_80193758[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80182B94, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80182AF4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80193758; + RotMatrixYXZ(rot, D_80193758); + func_80048D9C(D_80193758, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182B64); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80182BA8[])(void); + +void func_80169F00(void *a0) { + D_80182BA8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80182B58[]; +extern char D_80182B18[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80182B58, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182B18); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80182BE0[])(void); + +void func_8016A020(void *a0) { + D_80182BE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80182BB0; + extern u8 D_80182BC4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80182BB0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182BC4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80182BEC[])(void); + +void func_8016A700(void *a0) { + D_80182BEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80182C34[])(void); + +void func_8016AB30(void *a0) { + D_80182C34[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_026/ov_SC02_026_jr_8015AE2C.c b/src/ov_SC02_026/ov_SC02_026_jr_8015AE2C.c index d1ff00fe8..6b28b40ca 100644 --- a/src/ov_SC02_026/ov_SC02_026_jr_8015AE2C.c +++ b/src/ov_SC02_026/ov_SC02_026_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80188944[])(void); - -void func_8015C714(void *a0) { - D_80188944[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801887B8[])(void*); - extern int D_8018875C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801887B8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801887B8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018875C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801887B8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801887B8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801887B8[])(void*); - extern int D_8018875C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801887B8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018875C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801887B8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80188954[])(void); - D_80188954[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801887B8[])(struct Ent_8015CD20 *); - extern u8 D_8018876C; - extern u8 D_8018895C; - extern u8 D_8018896C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801887B8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018876C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018895C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018896C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801887B8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018898C[])(void); - D_8018898C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018897C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018897C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801887B8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801889E8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801889E8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80187ACC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80187ACC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801889F0[])(void); - D_801889F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801889FC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801889FC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801889FC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801889FC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801887B8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801889FC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018877C[]; - extern u8 D_8018878C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018877C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018878C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801889FC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801889FC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801889FC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80188A30[])(void); - D_80188A30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801887B8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188A38[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80188A50[])(void); - D_80188A50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801887B8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188A38[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80188A70[])(void); - D_80188A70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801887B8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801887B8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80188A80; -extern u16 D_80188A82; -extern u16 D_80188A84; -extern s32 D_80188A88; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80188A80 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80188A82 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80188A84 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188A88, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80188A90; - -void func_8015E588(void) { - func_8013C9C4(&D_80188A90); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801887B8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801887B8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80188AA4[])(void); - D_80188AA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801887B8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801887B8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80188AAC[])(void); - D_80188AAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018879C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018879C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801887B8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80188AB4[])(void); - D_80188AB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801887B8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801887B8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80188ABC[])(void); - D_80188ABC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801887B8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80188AC4; - extern s32 D_80188AD4; - extern s32 D_80188AE4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801887B8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188AC4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188AD4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801887B8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188AE4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80188AF4[])(void); - D_80188AF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801887B8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801887B8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801887B8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801887B8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80188B00[])(void); - D_80188B00[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801887B8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801887B8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801887B8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801887B8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80188B14[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80188B14[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801887B8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801887B8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801887B8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801887B8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80188B90[])(void); - D_80188B90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801887B8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801887B8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80188BA0[])(void); - D_80188BA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801887B8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801887B8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801887B8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801887B8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801887B8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801887B8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801887B8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80188BA8[])(void); - D_80188BA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801887B8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801887B8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801887B8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801887B8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80188BB4[])(void); - D_80188BB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801887B8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801887B8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801887B8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801887B8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80188BC4[])(void); - -void func_80160EA4(void *a0) { - D_80188BC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801887B8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801887B8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80188BF4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80188BF4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80188C58; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80188C58); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801CEFD0[]; - extern u8 D_80188C24[]; - extern u8 D_80188C44[]; - extern u8 D_801CEFDC[]; - extern u8 D_801CF004[]; - extern u8 D_801CF01C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801CEFD0[0] = p; - func_80024054(&D_80188C24, &D_801CEFDC); - func_8001CE28(p, &D_801CEFDC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801CEFD0[1] = p; - func_80024054(&D_80188C44, &D_801CF004); - func_8001CE28(p, &D_801CF004); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801CEFD0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801CF01C, 0x84); - func_8001CE68(p, &D_801CF01C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801CF01C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CEFD0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801CEFD0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80188C58; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80188C58; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80188C58; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80188C58; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801CEFD0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801CEFD0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80188C7C[])(void); - -void func_80162330(void *a0) { - D_80188C7C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801CF028[i] via `extern int D_801CF028[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80188C88[]; - extern s32 D_80188CA0; - extern u8 D_801CF034[]; - extern u8 D_801CF05C[]; - extern u8 D_801CF078[]; - extern int D_801CF028[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801CF028[0] = (s32)item; - func_80024054(D_80188C88, D_801CF034); - func_8001CE28(item, D_801CF034); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801CF028[1] = (s32)item; - func_80024054(((u8 *)&D_80188CA0), D_801CF05C); - func_8001CE28(item, D_801CF05C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801CF028[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801CF078, 0x84); - func_8001CE68(item, D_801CF078); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801CF078, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CF028[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801CF028; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_801627E8); - - -extern void (*D_80188CC4[])(void); - -void func_80162834(void *a0) { - D_80188CC4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80188CB4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80188CB4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801CE85C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801CE85C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801CE85C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801CE85C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80188CCC[])(void); - -void func_80163A58(void *a0) { - D_80188CCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801CE864; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801CE864; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80188D20[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80188D20[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80188CE8; -extern s16 D_80188D1C; -extern s16 D_80188D1A; -extern s16 D_80188D18; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80188CE8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80188D1C = 0x80; - D_80188D1A = 0x80; - D_80188D18 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80188D1C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188D1C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80188D1C - 8; - D_80188D1C = nv; - D_80188D1A = nv; - D_80188D18 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80188D2C[])(void); - -void func_80164BA0(void *a0) { - D_80188D2C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801CF088; -extern u8 D_801CF089; -extern u8 D_801CF08A; -extern u8 D_801CF08B; -extern u8 D_801CF08C; -extern u8 D_801CF08D; -extern u8 D_801CF08E; -extern u8 D_801CF08F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801CF088; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801CF089 = 0xf0; - *(u8 *)base = 0xf0; - D_801CF08A = 0xc0; - D_801CF08E = 0; - D_801CF08D = 0; - D_801CF08C = 0; - D_801CF08F = 0; - D_801CF08B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801CF088; -extern u8 D_801CF089; -extern u8 D_801CF08A; - -s32 func_80164E40(void) { - u8 *p = &D_801CF088; - if (*p != 0) { - *p -= 0x10; - } - if (D_801CF089 != 0) { - D_801CF089 -= 0x10; - } - if (D_801CF08A != 0) { - D_801CF08A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80188D3C[])(void); - -void func_80164EA4(void *a0) { - D_80188D3C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801CF0D4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801CF0D4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801CF0C8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801CF0C8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801CF0C8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801CF0C8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801CF0C8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80188D50[]; - extern u32 D_80188D70, D_80188D74, D_80188D78, D_80188D7C; - extern u32 D_80188D70, D_80188D74, D_80188D78, D_80188D7C; - extern u32 D_80188D70, D_80188D74, D_80188D78, D_80188D7C; - extern u32 D_80188D70, D_80188D74, D_80188D78, D_80188D7C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80188D50[0x00], p); - ApplyMatrixSV(mat, &D_80188D50[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80188D50[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80188D50[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80188D78; - *(u32 *)(prim + 0x24) = D_80188D70; - *(u32 *)(prim + 0x28) = D_80188D7C; - *(u32 *)(prim + 0x2c) = D_80188D74; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80188D80[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80188D80[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80188D80[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80188D80[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80188DFC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80188DFC[a1 & 0x7F]; -} - - - -extern s32 D_80188E1C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80188E1C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80188E98[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80188E98[a1 & 0x7F]; -} - - - -extern u8 D_80188EB8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80188EB8[a1 & 0x7F]; -} - - - -extern u8 D_80188ED8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80188ED8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80188EF8[])(void); - D_80188EF8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80188F74[])(void); - -void func_80165AC8(void) { - D_80188F74[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80188FF0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80188FF0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801CE86C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801CE86C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80188FFC[])(void); - -void func_80166018(void *a0) { - D_80188FFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80189004[])(void); - -void func_801663FC(void *a0) { - D_80189004[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801890CC[])(void); - -void func_80166618(void *a0) { - D_801890CC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801890DC[])(void); - -void func_80166654(void *a0) { - D_801890DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801CF148[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801CF148[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CF148). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801CF148[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801CF148)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801CF148[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801CF148[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80189020[]; - extern u8 D_8018900C[]; - extern u8 D_80189034[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80189020; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018900C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80189034; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80167714); - - -extern void (*D_801890EC[])(void); - -void func_801678B4(void *a0) { - D_801890EC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801890F8[])(void); - -void func_80167A9C(void *a0) { - D_801890F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80189204; - extern u8 D_80189218[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80189204); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80189218; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80189058[]; -extern u8 D_8018906C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80189058; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018906C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80189110[])(void); - -void func_80168744(void *a0) { - D_80189110[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80189100 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80189100[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80189100; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80189118[])(void); - -void func_801689D8(void *a0) { - D_80189118[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80189120[])(void); - -void func_80168AA8(void *a0) { - D_80189120[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80189128[])(void); - -void func_80168D58(void *a0) { - D_80189128[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80189130[])(void); - -void func_8016901C(void *a0) { - D_80189130[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015AE2C", func_80169228); - - -extern void (*D_80189138[])(void); - -void func_801693CC(void *a0) { - D_80189138[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80189140[])(void); - -void func_80169830(void *a0) { - D_80189140[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801891F4[])(void); - -void func_80169B80(void *a0) { - D_801891F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80189148[]; - extern u8 D_801891B8[]; - extern u8 D_801891E8[]; - extern u8 D_801D0178[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801891E8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80189148[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801D0178; - RotMatrixYXZ(rot, D_801D0178); - func_80048D9C(D_801D0178, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801891B8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801891FC[])(void); - -void func_80169F00(void *a0) { - D_801891FC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801891AC[]; -extern char D_8018916C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801891AC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018916C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80189234[])(void); - -void func_8016A020(void *a0) { - D_80189234[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80189204; - extern u8 D_80189218[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80189204); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80189218; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80189240[])(void); - -void func_8016A700(void *a0) { - D_80189240[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80189288[])(void); - -void func_8016AB30(void *a0) { - D_80189288[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c b/src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c new file mode 100644 index 000000000..942054fb8 --- /dev/null +++ b/src/ov_SC02_026/ov_SC02_026_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80188654; +extern u8 D_801885C4; +extern u8 D_801885A0; +extern u8 D_8018857C; +extern u8 D_80188630; +extern u8 D_8018860C; +extern u8 D_801885E8; +extern u8 D_80188558; +extern void func_80145934(void); +extern u8 D_801886E4; +extern u8 D_801886C0; +extern u8 D_8018869C; +extern u8 D_80188678; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80187ADC[]; +extern unsigned char D_80187B0C[]; +extern unsigned char D_80187B5C[]; +extern unsigned char D_80187B8C[]; +extern unsigned char D_80187BBC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80187C0C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80187CD4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80187D5C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80187D64; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801CEF78; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801CEF7C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80187D94; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80187E3C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80187E60[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80187E50; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80187E74[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80187E80[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80187E90[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80187EA8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80187E98; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80187EBC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80187ED8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80187EC8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80187EEC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80187F00[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80187F14; +extern void (*D_80187F3C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80187F1C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80187F88[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80187F8C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801883F0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80188400[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801CEFB0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80188428[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80188408; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80188418; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80188468[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80188470[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018843C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018847C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018844C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801CEFB8; +extern s32 D_801CEFC4; +extern s32 D_801CEFC8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801884B8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018848C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801CEFC0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80188708[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80188528[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801887AC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80188900[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018871C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80188908[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018872C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018874C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80188910[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80188938[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801887B8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80188944[])(void); + +void func_8015C714(void *a0) { + D_80188944[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801887B8[])(void*); + extern int D_8018875C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801887B8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801887B8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018875C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801887B8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801887B8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801887B8[])(void*); + extern int D_8018875C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801887B8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018875C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801887B8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80188954[])(void); + D_80188954[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801887B8[])(struct Ent_8015CD20 *); + extern u8 D_8018876C; + extern u8 D_8018895C; + extern u8 D_8018896C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801887B8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018876C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018895C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018896C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801887B8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018898C[])(void); + D_8018898C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018897C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018897C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801887B8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801889E8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801889E8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80187ACC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80187ACC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801889F0[])(void); + D_801889F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801889FC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801889FC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801889FC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801889FC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801887B8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801889FC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018877C[]; + extern u8 D_8018878C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018877C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018878C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801889FC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801889FC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801889FC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80188A30[])(void); + D_80188A30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801887B8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188A38[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80188A50[])(void); + D_80188A50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801887B8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188A38[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188A38[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80188A70[])(void); + D_80188A70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801887B8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801887B8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80188A80; +extern u16 D_80188A82; +extern u16 D_80188A84; +extern s32 D_80188A88; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80188A80 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80188A82 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80188A84 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188A88, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80188A90; + +void func_8015E588(void) { + func_8013C9C4(&D_80188A90); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801887B8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801887B8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80188AA4[])(void); + D_80188AA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801887B8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801887B8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80188AAC[])(void); + D_80188AAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018879C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018879C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801887B8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80188AB4[])(void); + D_80188AB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801887B8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801887B8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80188ABC[])(void); + D_80188ABC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801887B8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80188AC4; + extern s32 D_80188AD4; + extern s32 D_80188AE4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188AC4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188AD4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801887B8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188AE4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80188AF4[])(void); + D_80188AF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801887B8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801887B8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801887B8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801887B8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80188B00[])(void); + D_80188B00[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801887B8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801887B8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801887B8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801887B8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80188B14[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80188B14[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801887B8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801887B8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801887B8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801887B8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80188B90[])(void); + D_80188B90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801887B8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801887B8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80188BA0[])(void); + D_80188BA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801887B8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801887B8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801887B8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801887B8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801887B8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801887B8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801887B8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80188BA8[])(void); + D_80188BA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801887B8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801887B8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801887B8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801887B8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80188BB4[])(void); + D_80188BB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801887B8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801887B8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801887B8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801887B8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80188BC4[])(void); + +void func_80160EA4(void *a0) { + D_80188BC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801887B8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801887B8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80188BF4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80188BF4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80188C58; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80188C58); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801CEFD0[]; + extern u8 D_80188C24[]; + extern u8 D_80188C44[]; + extern u8 D_801CEFDC[]; + extern u8 D_801CF004[]; + extern u8 D_801CF01C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801CEFD0[0] = p; + func_80024054(&D_80188C24, &D_801CEFDC); + func_8001CE28(p, &D_801CEFDC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801CEFD0[1] = p; + func_80024054(&D_80188C44, &D_801CF004); + func_8001CE28(p, &D_801CF004); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801CEFD0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801CF01C, 0x84); + func_8001CE68(p, &D_801CF01C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801CF01C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CEFD0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801CEFD0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80188C58; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80188C58; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80188C58; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80188C58; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801CEFD0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801CEFD0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80188C7C[])(void); + +void func_80162330(void *a0) { + D_80188C7C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801CF028[i] via `extern int D_801CF028[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80188C88[]; + extern s32 D_80188CA0; + extern u8 D_801CF034[]; + extern u8 D_801CF05C[]; + extern u8 D_801CF078[]; + extern int D_801CF028[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801CF028[0] = (s32)item; + func_80024054(D_80188C88, D_801CF034); + func_8001CE28(item, D_801CF034); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801CF028[1] = (s32)item; + func_80024054(((u8 *)&D_80188CA0), D_801CF05C); + func_8001CE28(item, D_801CF05C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801CF028[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801CF078, 0x84); + func_8001CE68(item, D_801CF078); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801CF078, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CF028[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801CF028; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_801627E8); + + +extern void (*D_80188CC4[])(void); + +void func_80162834(void *a0) { + D_80188CC4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80188CB4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80188CB4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801CE85C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801CE85C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801CE85C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801CE85C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80188CCC[])(void); + +void func_80163A58(void *a0) { + D_80188CCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801CE864; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801CE864; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80188D20[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80188D20[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80188CE8; +extern s16 D_80188D1C; +extern s16 D_80188D1A; +extern s16 D_80188D18; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80188CE8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80188D1C = 0x80; + D_80188D1A = 0x80; + D_80188D18 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80188D1C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188D1C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80188D1C - 8; + D_80188D1C = nv; + D_80188D1A = nv; + D_80188D18 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80188D2C[])(void); + +void func_80164BA0(void *a0) { + D_80188D2C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801CF088; +extern u8 D_801CF089; +extern u8 D_801CF08A; +extern u8 D_801CF08B; +extern u8 D_801CF08C; +extern u8 D_801CF08D; +extern u8 D_801CF08E; +extern u8 D_801CF08F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801CF088; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801CF089 = 0xf0; + *(u8 *)base = 0xf0; + D_801CF08A = 0xc0; + D_801CF08E = 0; + D_801CF08D = 0; + D_801CF08C = 0; + D_801CF08F = 0; + D_801CF08B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801CF088; +extern u8 D_801CF089; +extern u8 D_801CF08A; + +s32 func_80164E40(void) { + u8 *p = &D_801CF088; + if (*p != 0) { + *p -= 0x10; + } + if (D_801CF089 != 0) { + D_801CF089 -= 0x10; + } + if (D_801CF08A != 0) { + D_801CF08A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80188D3C[])(void); + +void func_80164EA4(void *a0) { + D_80188D3C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801CF0D4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801CF0D4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801CF0C8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801CF0C8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801CF0C8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801CF0C8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801CF0C8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80188D50[]; + extern u32 D_80188D70, D_80188D74, D_80188D78, D_80188D7C; + extern u32 D_80188D70, D_80188D74, D_80188D78, D_80188D7C; + extern u32 D_80188D70, D_80188D74, D_80188D78, D_80188D7C; + extern u32 D_80188D70, D_80188D74, D_80188D78, D_80188D7C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80188D50[0x00], p); + ApplyMatrixSV(mat, &D_80188D50[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80188D50[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80188D50[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80188D78; + *(u32 *)(prim + 0x24) = D_80188D70; + *(u32 *)(prim + 0x28) = D_80188D7C; + *(u32 *)(prim + 0x2c) = D_80188D74; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80188D80[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80188D80[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80188D80[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80188D80[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80188DFC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80188DFC[a1 & 0x7F]; +} + + + +extern s32 D_80188E1C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80188E1C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80188E98[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80188E98[a1 & 0x7F]; +} + + + +extern u8 D_80188EB8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80188EB8[a1 & 0x7F]; +} + + + +extern u8 D_80188ED8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80188ED8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80188EF8[])(void); + D_80188EF8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80188F74[])(void); + +void func_80165AC8(void) { + D_80188F74[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80188FF0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80188FF0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801CE86C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801CE86C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80188FFC[])(void); + +void func_80166018(void *a0) { + D_80188FFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80189004[])(void); + +void func_801663FC(void *a0) { + D_80189004[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801890CC[])(void); + +void func_80166618(void *a0) { + D_801890CC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801890DC[])(void); + +void func_80166654(void *a0) { + D_801890DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801CF148[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801CF148[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CF148). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801CF148[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801CF148)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801CF148[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801CF148[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80189020[]; + extern u8 D_8018900C[]; + extern u8 D_80189034[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80189020; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018900C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80189034; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80167714); + + +extern void (*D_801890EC[])(void); + +void func_801678B4(void *a0) { + D_801890EC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801890F8[])(void); + +void func_80167A9C(void *a0) { + D_801890F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80189204; + extern u8 D_80189218[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80189204); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80189218; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80189058[]; +extern u8 D_8018906C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80189058; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018906C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80189110[])(void); + +void func_80168744(void *a0) { + D_80189110[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80189100 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80189100[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80189100; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80189118[])(void); + +void func_801689D8(void *a0) { + D_80189118[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80189120[])(void); + +void func_80168AA8(void *a0) { + D_80189120[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80189128[])(void); + +void func_80168D58(void *a0) { + D_80189128[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80189130[])(void); + +void func_8016901C(void *a0) { + D_80189130[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_026/nonmatchings/ov_SC02_026_jr_8015C32C", func_80169228); + + +extern void (*D_80189138[])(void); + +void func_801693CC(void *a0) { + D_80189138[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80189140[])(void); + +void func_80169830(void *a0) { + D_80189140[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801891F4[])(void); + +void func_80169B80(void *a0) { + D_801891F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80189148[]; + extern u8 D_801891B8[]; + extern u8 D_801891E8[]; + extern u8 D_801D0178[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801891E8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80189148[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801D0178; + RotMatrixYXZ(rot, D_801D0178); + func_80048D9C(D_801D0178, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801891B8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801891FC[])(void); + +void func_80169F00(void *a0) { + D_801891FC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801891AC[]; +extern char D_8018916C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801891AC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018916C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80189234[])(void); + +void func_8016A020(void *a0) { + D_80189234[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80189204; + extern u8 D_80189218[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80189204); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80189218; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80189240[])(void); + +void func_8016A700(void *a0) { + D_80189240[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80189288[])(void); + +void func_8016AB30(void *a0) { + D_80189288[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_027/ov_SC02_027_jr_8015AE2C.c b/src/ov_SC02_027/ov_SC02_027_jr_8015AE2C.c index 63060a923..ce2f4b4f1 100644 --- a/src/ov_SC02_027/ov_SC02_027_jr_8015AE2C.c +++ b/src/ov_SC02_027/ov_SC02_027_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018DA68[])(void); - -void func_8015C714(void *a0) { - D_8018DA68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018D8DC[])(void*); - extern int D_8018D880; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D880); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018D8DC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018D8DC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018D8DC[])(void*); - extern int D_8018D880; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D880); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018DA78[])(void); - D_8018DA78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018D8DC[])(struct Ent_8015CD20 *); - extern u8 D_8018D890; - extern u8 D_8018DA80; - extern u8 D_8018DA90; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018D8DC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D890); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DA80); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DA90); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018D8DC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018DAB0[])(void); - D_8018DAB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018DAA0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018DAA0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018D8DC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018DB0C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018DB0C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018CBF0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018CBF0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018DB14[])(void); - D_8018DB14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018DB20[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018DB20[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018DB20[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018DB20[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018D8DC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018DB20[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018D8A0[]; - extern u8 D_8018D8B0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D8A0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D8B0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018DB20[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018DB20[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018DB20[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018DB54[])(void); - D_8018DB54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D8DC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018DB5C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018DB74[])(void); - D_8018DB74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D8DC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018DB5C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018DB94[])(void); - D_8018DB94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018D8DC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D8DC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018DBA4; -extern u16 D_8018DBA6; -extern u16 D_8018DBA8; -extern s32 D_8018DBAC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018DBA4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018DBA6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018DBA8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018DBAC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018DBB4; - -void func_8015E588(void) { - func_8013C9C4(&D_8018DBB4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018D8DC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D8DC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018DBC8[])(void); - D_8018DBC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018D8DC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018D8DC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018DBD0[])(void); - D_8018DBD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018D8C0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D8C0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018D8DC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018DBD8[])(void); - D_8018DBD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018D8DC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018D8DC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018DBE0[])(void); - D_8018DBE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018D8DC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018DBE8; - extern s32 D_8018DBF8; - extern s32 D_8018DC08; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018D8DC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DBE8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DBF8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018D8DC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DC08); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018DC18[])(void); - D_8018DC18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018D8DC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018D8DC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018D8DC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D8DC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018DC24[])(void); - D_8018DC24[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018D8DC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D8DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018D8DC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D8DC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018DC38[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018DC38[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018D8DC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018D8DC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018D8DC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D8DC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018DCB4[])(void); - D_8018DCB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018D8DC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018D8DC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018DCC4[])(void); - D_8018DCC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018D8DC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018D8DC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018D8DC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018D8DC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018D8DC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018D8DC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018D8DC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018DCCC[])(void); - D_8018DCCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018D8DC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018D8DC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018D8DC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018DCD8[])(void); - D_8018DCD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D8DC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018D8DC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018D8DC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018D8DC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018DCE8[])(void); - -void func_80160EA4(void *a0) { - D_8018DCE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018D8DC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018D8DC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018DD18[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018DD18[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018DD7C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018DD7C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801D8D40[]; - extern u8 D_8018DD48[]; - extern u8 D_8018DD68[]; - extern u8 D_801D8D4C[]; - extern u8 D_801D8D74[]; - extern u8 D_801D8D8C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801D8D40[0] = p; - func_80024054(&D_8018DD48, &D_801D8D4C); - func_8001CE28(p, &D_801D8D4C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801D8D40[1] = p; - func_80024054(&D_8018DD68, &D_801D8D74); - func_8001CE28(p, &D_801D8D74); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801D8D40[2] = p; - func_800242D0((s16)func_801620C4(), &D_801D8D8C, 0x84); - func_8001CE68(p, &D_801D8D8C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801D8D8C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D8D40[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801D8D40; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018DD7C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018DD7C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018DD7C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018DD7C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801D8D40[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801D8D40; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018DDA0[])(void); - -void func_80162330(void *a0) { - D_8018DDA0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801D8D98[i] via `extern int D_801D8D98[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018DDAC[]; - extern s32 D_8018DDC4; - extern u8 D_801D8DA4[]; - extern u8 D_801D8DCC[]; - extern u8 D_801D8DE8[]; - extern int D_801D8D98[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801D8D98[0] = (s32)item; - func_80024054(D_8018DDAC, D_801D8DA4); - func_8001CE28(item, D_801D8DA4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801D8D98[1] = (s32)item; - func_80024054(((u8 *)&D_8018DDC4), D_801D8DCC); - func_8001CE28(item, D_801D8DCC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801D8D98[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801D8DE8, 0x84); - func_8001CE68(item, D_801D8DE8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801D8DE8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D8D98[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801D8D98; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018DDE8[])(void); - -void func_80162834(void *a0) { - D_8018DDE8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018DDD8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018DDD8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801D85C8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801D85C8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801D85C8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801D85C8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018DDF0[])(void); - -void func_80163A58(void *a0) { - D_8018DDF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801D85D0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801D85D0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018DE44[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018DE44[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018DE0C; -extern s16 D_8018DE40; -extern s16 D_8018DE3E; -extern s16 D_8018DE3C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018DE0C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018DE40 = 0x80; - D_8018DE3E = 0x80; - D_8018DE3C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018DE40 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018DE40` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018DE40 - 8; - D_8018DE40 = nv; - D_8018DE3E = nv; - D_8018DE3C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018DE50[])(void); - -void func_80164BA0(void *a0) { - D_8018DE50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801D8DF8; -extern u8 D_801D8DF9; -extern u8 D_801D8DFA; -extern u8 D_801D8DFB; -extern u8 D_801D8DFC; -extern u8 D_801D8DFD; -extern u8 D_801D8DFE; -extern u8 D_801D8DFF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801D8DF8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801D8DF9 = 0xf0; - *(u8 *)base = 0xf0; - D_801D8DFA = 0xc0; - D_801D8DFE = 0; - D_801D8DFD = 0; - D_801D8DFC = 0; - D_801D8DFF = 0; - D_801D8DFB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801D8DF8; -extern u8 D_801D8DF9; -extern u8 D_801D8DFA; - -s32 func_80164E40(void) { - u8 *p = &D_801D8DF8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801D8DF9 != 0) { - D_801D8DF9 -= 0x10; - } - if (D_801D8DFA != 0) { - D_801D8DFA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018DE60[])(void); - -void func_80164EA4(void *a0) { - D_8018DE60[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801D8E44[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801D8E44[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801D8E38[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801D8E38[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801D8E38[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801D8E38; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801D8E38; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018DE74[]; - extern u32 D_8018DE94, D_8018DE98, D_8018DE9C, D_8018DEA0; - extern u32 D_8018DE94, D_8018DE98, D_8018DE9C, D_8018DEA0; - extern u32 D_8018DE94, D_8018DE98, D_8018DE9C, D_8018DEA0; - extern u32 D_8018DE94, D_8018DE98, D_8018DE9C, D_8018DEA0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018DE74[0x00], p); - ApplyMatrixSV(mat, &D_8018DE74[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018DE74[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018DE74[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018DE9C; - *(u32 *)(prim + 0x24) = D_8018DE94; - *(u32 *)(prim + 0x28) = D_8018DEA0; - *(u32 *)(prim + 0x2c) = D_8018DE98; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018DEA4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018DEA4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018DEA4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018DEA4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018DF20[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018DF20[a1 & 0x7F]; -} - - - -extern s32 D_8018DF40[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018DF40[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018DFBC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018DFBC[a1 & 0x7F]; -} - - - -extern u8 D_8018DFDC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018DFDC[a1 & 0x7F]; -} - - - -extern u8 D_8018DFFC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018DFFC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018E01C[])(void); - D_8018E01C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018E098[])(void); - -void func_80165AC8(void) { - D_8018E098[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018E114[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018E114[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801D85D8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801D85D8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018E120[])(void); - -void func_80166018(void *a0) { - D_8018E120[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018E128[])(void); - -void func_801663FC(void *a0) { - D_8018E128[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018E1F0[])(void); - -void func_80166618(void *a0) { - D_8018E1F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018E200[])(void); - -void func_80166654(void *a0) { - D_8018E200[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801D8EB8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801D8EB8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D8EB8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801D8EB8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801D8EB8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801D8EB8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801D8EB8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018E144[]; - extern u8 D_8018E130[]; - extern u8 D_8018E158[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018E144; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018E130; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018E158; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80167714); - - -extern void (*D_8018E210[])(void); - -void func_801678B4(void *a0) { - D_8018E210[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018E21C[])(void); - -void func_80167A9C(void *a0) { - D_8018E21C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018E328; - extern u8 D_8018E33C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018E328); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018E33C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018E17C[]; -extern u8 D_8018E190[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018E17C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018E190; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018E234[])(void); - -void func_80168744(void *a0) { - D_8018E234[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018E224 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018E224[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018E224; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018E23C[])(void); - -void func_801689D8(void *a0) { - D_8018E23C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018E244[])(void); - -void func_80168AA8(void *a0) { - D_8018E244[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018E24C[])(void); - -void func_80168D58(void *a0) { - D_8018E24C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018E254[])(void); - -void func_8016901C(void *a0) { - D_8018E254[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015AE2C", func_80169228); - - -extern void (*D_8018E25C[])(void); - -void func_801693CC(void *a0) { - D_8018E25C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018E264[])(void); - -void func_80169830(void *a0) { - D_8018E264[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018E318[])(void); - -void func_80169B80(void *a0) { - D_8018E318[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018E26C[]; - extern u8 D_8018E2DC[]; - extern u8 D_8018E30C[]; - extern u8 D_801DA8F8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018E30C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018E26C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801DA8F8; - RotMatrixYXZ(rot, D_801DA8F8); - func_80048D9C(D_801DA8F8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018E2DC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018E320[])(void); - -void func_80169F00(void *a0) { - D_8018E320[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018E2D0[]; -extern char D_8018E290[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018E2D0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018E290); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018E358[])(void); - -void func_8016A020(void *a0) { - D_8018E358[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018E328; - extern u8 D_8018E33C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018E328); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018E33C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018E364[])(void); - -void func_8016A700(void *a0) { - D_8018E364[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018E3AC[])(void); - -void func_8016AB30(void *a0) { - D_8018E3AC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c b/src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c new file mode 100644 index 000000000..b19b4a7ee --- /dev/null +++ b/src/ov_SC02_027/ov_SC02_027_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018D778; +extern u8 D_8018D6E8; +extern u8 D_8018D6C4; +extern u8 D_8018D6A0; +extern u8 D_8018D754; +extern u8 D_8018D730; +extern u8 D_8018D70C; +extern u8 D_8018D67C; +extern void func_80145934(void); +extern u8 D_8018D808; +extern u8 D_8018D7E4; +extern u8 D_8018D7C0; +extern u8 D_8018D79C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018CC00[]; +extern unsigned char D_8018CC30[]; +extern unsigned char D_8018CC80[]; +extern unsigned char D_8018CCB0[]; +extern unsigned char D_8018CCE0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018CD30[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018CDF8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018CE80[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018CE88; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801D8CE8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801D8CEC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018CEB8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018CF60[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018CF84[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018CF74; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018CF98[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018CFA4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018CFB4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018CFCC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018CFBC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018CFE0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018CFFC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018CFEC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018D010[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018D024[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018D038; +extern void (*D_8018D060[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018D040; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018D0AC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018D0B0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018D514[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018D524[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801D8D20; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018D54C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018D52C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018D53C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018D58C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018D594[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018D560; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018D5A0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018D570; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801D8D28; +extern s32 D_801D8D34; +extern s32 D_801D8D38; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018D5DC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018D5B0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801D8D30; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018D82C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018D64C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018D8D0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018DA24[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018D840; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018DA2C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018D850; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018D870; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018DA34[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018DA5C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018D8DC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018DA68[])(void); + +void func_8015C714(void *a0) { + D_8018DA68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018D8DC[])(void*); + extern int D_8018D880; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D880); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018D8DC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018D8DC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018D8DC[])(void*); + extern int D_8018D880; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D880); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018DA78[])(void); + D_8018DA78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018D8DC[])(struct Ent_8015CD20 *); + extern u8 D_8018D890; + extern u8 D_8018DA80; + extern u8 D_8018DA90; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018D8DC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D890); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DA80); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DA90); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018D8DC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018DAB0[])(void); + D_8018DAB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018DAA0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018DAA0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018D8DC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018DB0C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018DB0C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018CBF0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018CBF0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018DB14[])(void); + D_8018DB14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018DB20[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018DB20[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018DB20[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018DB20[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018D8DC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018DB20[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018D8A0[]; + extern u8 D_8018D8B0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D8A0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D8B0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018DB20[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018DB20[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018DB20[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018DB54[])(void); + D_8018DB54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D8DC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018DB5C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018DB74[])(void); + D_8018DB74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D8DC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018DB5C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018DB5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018DB94[])(void); + D_8018DB94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018D8DC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D8DC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018DBA4; +extern u16 D_8018DBA6; +extern u16 D_8018DBA8; +extern s32 D_8018DBAC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018DBA4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018DBA6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018DBA8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018DBAC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018DBB4; + +void func_8015E588(void) { + func_8013C9C4(&D_8018DBB4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018D8DC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D8DC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018DBC8[])(void); + D_8018DBC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018D8DC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018D8DC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018DBD0[])(void); + D_8018DBD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018D8C0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D8C0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018D8DC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018DBD8[])(void); + D_8018DBD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018D8DC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018D8DC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018DBE0[])(void); + D_8018DBE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018D8DC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018DBE8; + extern s32 D_8018DBF8; + extern s32 D_8018DC08; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DBE8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DBF8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018D8DC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DC08); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018DC18[])(void); + D_8018DC18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018D8DC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018D8DC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018D8DC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D8DC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018DC24[])(void); + D_8018DC24[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018D8DC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D8DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018D8DC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D8DC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018DC38[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018DC38[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018D8DC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018D8DC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018D8DC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D8DC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018DCB4[])(void); + D_8018DCB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018D8DC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018D8DC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018DCC4[])(void); + D_8018DCC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018D8DC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018D8DC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018D8DC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018D8DC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018D8DC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018D8DC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018D8DC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018DCCC[])(void); + D_8018DCCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018D8DC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018D8DC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018D8DC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018D8DC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018DCD8[])(void); + D_8018DCD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D8DC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018D8DC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018D8DC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018D8DC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018DCE8[])(void); + +void func_80160EA4(void *a0) { + D_8018DCE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018D8DC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018D8DC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018DD18[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018DD18[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018DD7C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018DD7C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801D8D40[]; + extern u8 D_8018DD48[]; + extern u8 D_8018DD68[]; + extern u8 D_801D8D4C[]; + extern u8 D_801D8D74[]; + extern u8 D_801D8D8C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801D8D40[0] = p; + func_80024054(&D_8018DD48, &D_801D8D4C); + func_8001CE28(p, &D_801D8D4C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801D8D40[1] = p; + func_80024054(&D_8018DD68, &D_801D8D74); + func_8001CE28(p, &D_801D8D74); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801D8D40[2] = p; + func_800242D0((s16)func_801620C4(), &D_801D8D8C, 0x84); + func_8001CE68(p, &D_801D8D8C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801D8D8C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D8D40[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801D8D40; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018DD7C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018DD7C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018DD7C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018DD7C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801D8D40[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801D8D40; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018DDA0[])(void); + +void func_80162330(void *a0) { + D_8018DDA0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801D8D98[i] via `extern int D_801D8D98[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018DDAC[]; + extern s32 D_8018DDC4; + extern u8 D_801D8DA4[]; + extern u8 D_801D8DCC[]; + extern u8 D_801D8DE8[]; + extern int D_801D8D98[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801D8D98[0] = (s32)item; + func_80024054(D_8018DDAC, D_801D8DA4); + func_8001CE28(item, D_801D8DA4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801D8D98[1] = (s32)item; + func_80024054(((u8 *)&D_8018DDC4), D_801D8DCC); + func_8001CE28(item, D_801D8DCC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801D8D98[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801D8DE8, 0x84); + func_8001CE68(item, D_801D8DE8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801D8DE8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D8D98[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801D8D98; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_801627E8); + + +extern void (*D_8018DDE8[])(void); + +void func_80162834(void *a0) { + D_8018DDE8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018DDD8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018DDD8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801D85C8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801D85C8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801D85C8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801D85C8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018DDF0[])(void); + +void func_80163A58(void *a0) { + D_8018DDF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801D85D0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801D85D0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018DE44[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018DE44[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018DE0C; +extern s16 D_8018DE40; +extern s16 D_8018DE3E; +extern s16 D_8018DE3C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018DE0C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018DE40 = 0x80; + D_8018DE3E = 0x80; + D_8018DE3C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018DE40 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018DE40` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018DE40 - 8; + D_8018DE40 = nv; + D_8018DE3E = nv; + D_8018DE3C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018DE50[])(void); + +void func_80164BA0(void *a0) { + D_8018DE50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801D8DF8; +extern u8 D_801D8DF9; +extern u8 D_801D8DFA; +extern u8 D_801D8DFB; +extern u8 D_801D8DFC; +extern u8 D_801D8DFD; +extern u8 D_801D8DFE; +extern u8 D_801D8DFF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801D8DF8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801D8DF9 = 0xf0; + *(u8 *)base = 0xf0; + D_801D8DFA = 0xc0; + D_801D8DFE = 0; + D_801D8DFD = 0; + D_801D8DFC = 0; + D_801D8DFF = 0; + D_801D8DFB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801D8DF8; +extern u8 D_801D8DF9; +extern u8 D_801D8DFA; + +s32 func_80164E40(void) { + u8 *p = &D_801D8DF8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801D8DF9 != 0) { + D_801D8DF9 -= 0x10; + } + if (D_801D8DFA != 0) { + D_801D8DFA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018DE60[])(void); + +void func_80164EA4(void *a0) { + D_8018DE60[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801D8E44[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801D8E44[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801D8E38[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801D8E38[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801D8E38[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801D8E38; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801D8E38; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018DE74[]; + extern u32 D_8018DE94, D_8018DE98, D_8018DE9C, D_8018DEA0; + extern u32 D_8018DE94, D_8018DE98, D_8018DE9C, D_8018DEA0; + extern u32 D_8018DE94, D_8018DE98, D_8018DE9C, D_8018DEA0; + extern u32 D_8018DE94, D_8018DE98, D_8018DE9C, D_8018DEA0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018DE74[0x00], p); + ApplyMatrixSV(mat, &D_8018DE74[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018DE74[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018DE74[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018DE9C; + *(u32 *)(prim + 0x24) = D_8018DE94; + *(u32 *)(prim + 0x28) = D_8018DEA0; + *(u32 *)(prim + 0x2c) = D_8018DE98; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018DEA4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018DEA4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018DEA4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018DEA4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018DF20[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018DF20[a1 & 0x7F]; +} + + + +extern s32 D_8018DF40[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018DF40[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018DFBC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018DFBC[a1 & 0x7F]; +} + + + +extern u8 D_8018DFDC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018DFDC[a1 & 0x7F]; +} + + + +extern u8 D_8018DFFC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018DFFC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018E01C[])(void); + D_8018E01C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018E098[])(void); + +void func_80165AC8(void) { + D_8018E098[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018E114[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018E114[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801D85D8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801D85D8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018E120[])(void); + +void func_80166018(void *a0) { + D_8018E120[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018E128[])(void); + +void func_801663FC(void *a0) { + D_8018E128[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018E1F0[])(void); + +void func_80166618(void *a0) { + D_8018E1F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018E200[])(void); + +void func_80166654(void *a0) { + D_8018E200[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801D8EB8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801D8EB8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D8EB8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801D8EB8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801D8EB8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801D8EB8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801D8EB8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018E144[]; + extern u8 D_8018E130[]; + extern u8 D_8018E158[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018E144; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018E130; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018E158; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80167714); + + +extern void (*D_8018E210[])(void); + +void func_801678B4(void *a0) { + D_8018E210[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018E21C[])(void); + +void func_80167A9C(void *a0) { + D_8018E21C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018E328; + extern u8 D_8018E33C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018E328); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018E33C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018E17C[]; +extern u8 D_8018E190[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018E17C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018E190; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018E234[])(void); + +void func_80168744(void *a0) { + D_8018E234[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018E224 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018E224[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018E224; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018E23C[])(void); + +void func_801689D8(void *a0) { + D_8018E23C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018E244[])(void); + +void func_80168AA8(void *a0) { + D_8018E244[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018E24C[])(void); + +void func_80168D58(void *a0) { + D_8018E24C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018E254[])(void); + +void func_8016901C(void *a0) { + D_8018E254[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_027/nonmatchings/ov_SC02_027_jr_8015C32C", func_80169228); + + +extern void (*D_8018E25C[])(void); + +void func_801693CC(void *a0) { + D_8018E25C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018E264[])(void); + +void func_80169830(void *a0) { + D_8018E264[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018E318[])(void); + +void func_80169B80(void *a0) { + D_8018E318[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018E26C[]; + extern u8 D_8018E2DC[]; + extern u8 D_8018E30C[]; + extern u8 D_801DA8F8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018E30C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018E26C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801DA8F8; + RotMatrixYXZ(rot, D_801DA8F8); + func_80048D9C(D_801DA8F8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018E2DC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018E320[])(void); + +void func_80169F00(void *a0) { + D_8018E320[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018E2D0[]; +extern char D_8018E290[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018E2D0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018E290); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018E358[])(void); + +void func_8016A020(void *a0) { + D_8018E358[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018E328; + extern u8 D_8018E33C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018E328); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018E33C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018E364[])(void); + +void func_8016A700(void *a0) { + D_8018E364[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018E3AC[])(void); + +void func_8016AB30(void *a0) { + D_8018E3AC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_028/ov_SC02_028_jr_8015AE2C.c b/src/ov_SC02_028/ov_SC02_028_jr_8015AE2C.c index 08c8ca5fc..6bb5249bf 100644 --- a/src/ov_SC02_028/ov_SC02_028_jr_8015AE2C.c +++ b/src/ov_SC02_028/ov_SC02_028_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018DC6C[])(void); - -void func_8015C714(void *a0) { - D_8018DC6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018DAE0[])(void*); - extern int D_8018DA84; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DA84); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018DAE0[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018DAE0[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018DAE0[])(void*); - extern int D_8018DA84; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DA84); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018DC7C[])(void); - D_8018DC7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018DAE0[])(struct Ent_8015CD20 *); - extern u8 D_8018DA94; - extern u8 D_8018DC84; - extern u8 D_8018DC94; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018DAE0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DA94); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DC84); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DC94); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018DAE0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018DCB4[])(void); - D_8018DCB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018DCA4; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018DCA4 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018DAE0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018DD10; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018DD10, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018CDF4[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018CDF4; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018DD18[])(void); - D_8018DD18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018DD24[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018DD24[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018DD24[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018DD24[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018DAE0[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018DD24[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018DAA4[]; - extern u8 D_8018DAB4[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DAA4); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DAB4); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018DD24[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018DD24[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018DD24[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018DD58[])(void); - D_8018DD58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018DAE0[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018DD60[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018DD78[])(void); - D_8018DD78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018DAE0[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018DD60[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018DD98[])(void); - D_8018DD98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018DAE0[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018DAE0)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018DDA8; -extern u16 D_8018DDAA; -extern u16 D_8018DDAC; -extern s32 D_8018DDB0; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018DDA8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018DDAA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018DDAC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018DDB0, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018DDB8; - -void func_8015E588(void) { - func_8013C9C4(&D_8018DDB8); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018DAE0[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018DAE0)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018DDCC[])(void); - D_8018DDCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018DAE0[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018DAE0[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018DDD4[])(void); - D_8018DDD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018DAC4; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018DAC4); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018DAE0[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018DDDC[])(void); - D_8018DDDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018DAE0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018DAE0[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018DDE4[])(void); - D_8018DDE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018DAE0[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018DDEC; - extern s32 D_8018DDFC; - extern s32 D_8018DE0C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018DAE0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DDEC); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DDFC); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018DAE0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DE0C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018DE1C[])(void); - D_8018DE1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018DAE0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018DAE0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018DAE0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018DAE0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018DE28[])(void); - D_8018DE28[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018DAE0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018DAE0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018DAE0[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018DAE0[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018DE3C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018DE3C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018DAE0[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018DAE0)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018DAE0[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018DAE0[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018DEB8[])(void); - D_8018DEB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018DAE0[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018DAE0)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018DEC8[])(void); - D_8018DEC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018DAE0[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018DAE0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018DAE0[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018DAE0[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018DAE0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018DAE0[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018DAE0[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018DED0[])(void); - D_8018DED0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018DAE0[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018DAE0)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018DAE0[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018DEDC[])(void); - D_8018DEDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018DAE0 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018DAE0[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018DAE0[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018DAE0[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018DEEC[])(void); - -void func_80160EA4(void *a0) { - D_8018DEEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018DAE0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018DAE0[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018DF1C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018DF1C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018DF80; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018DF80); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801D1CE0[]; - extern u8 D_8018DF4C[]; - extern u8 D_8018DF6C[]; - extern u8 D_801D1CEC[]; - extern u8 D_801D1D14[]; - extern u8 D_801D1D2C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801D1CE0[0] = p; - func_80024054(&D_8018DF4C, &D_801D1CEC); - func_8001CE28(p, &D_801D1CEC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801D1CE0[1] = p; - func_80024054(&D_8018DF6C, &D_801D1D14); - func_8001CE28(p, &D_801D1D14); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801D1CE0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801D1D2C, 0x84); - func_8001CE68(p, &D_801D1D2C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801D1D2C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D1CE0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801D1CE0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018DF80; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018DF80; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018DF80; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018DF80; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801D1CE0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801D1CE0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018DFA4[])(void); - -void func_80162330(void *a0) { - D_8018DFA4[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801D1D38[i] via `extern int D_801D1D38[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018DFB0[]; - extern s32 D_8018DFC8; - extern u8 D_801D1D44[]; - extern u8 D_801D1D6C[]; - extern u8 D_801D1D88[]; - extern int D_801D1D38[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801D1D38[0] = (s32)item; - func_80024054(D_8018DFB0, D_801D1D44); - func_8001CE28(item, D_801D1D44); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801D1D38[1] = (s32)item; - func_80024054(((u8 *)&D_8018DFC8), D_801D1D6C); - func_8001CE28(item, D_801D1D6C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801D1D38[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801D1D88, 0x84); - func_8001CE68(item, D_801D1D88); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801D1D88, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D1D38[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801D1D38; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018DFEC[])(void); - -void func_80162834(void *a0) { - D_8018DFEC[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018DFDC; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018DFDC, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801D154C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801D154C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801D154C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801D154C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018DFF4[])(void); - -void func_80163A58(void *a0) { - D_8018DFF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801D1554; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801D1554; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018E048[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018E048[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018E010; -extern s16 D_8018E044; -extern s16 D_8018E042; -extern s16 D_8018E040; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018E010; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018E044 = 0x80; - D_8018E042 = 0x80; - D_8018E040 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018E044 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E044` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018E044 - 8; - D_8018E044 = nv; - D_8018E042 = nv; - D_8018E040 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018E054[])(void); - -void func_80164BA0(void *a0) { - D_8018E054[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801D1D98; -extern u8 D_801D1D99; -extern u8 D_801D1D9A; -extern u8 D_801D1D9B; -extern u8 D_801D1D9C; -extern u8 D_801D1D9D; -extern u8 D_801D1D9E; -extern u8 D_801D1D9F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801D1D98; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801D1D99 = 0xf0; - *(u8 *)base = 0xf0; - D_801D1D9A = 0xc0; - D_801D1D9E = 0; - D_801D1D9D = 0; - D_801D1D9C = 0; - D_801D1D9F = 0; - D_801D1D9B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801D1D98; -extern u8 D_801D1D99; -extern u8 D_801D1D9A; - -s32 func_80164E40(void) { - u8 *p = &D_801D1D98; - if (*p != 0) { - *p -= 0x10; - } - if (D_801D1D99 != 0) { - D_801D1D99 -= 0x10; - } - if (D_801D1D9A != 0) { - D_801D1D9A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018E064[])(void); - -void func_80164EA4(void *a0) { - D_8018E064[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801D1DE4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801D1DE4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801D1DD8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801D1DD8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801D1DD8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801D1DD8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801D1DD8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018E078[]; - extern u32 D_8018E098, D_8018E09C, D_8018E0A0, D_8018E0A4; - extern u32 D_8018E098, D_8018E09C, D_8018E0A0, D_8018E0A4; - extern u32 D_8018E098, D_8018E09C, D_8018E0A0, D_8018E0A4; - extern u32 D_8018E098, D_8018E09C, D_8018E0A0, D_8018E0A4; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018E078[0x00], p); - ApplyMatrixSV(mat, &D_8018E078[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018E078[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018E078[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018E0A0; - *(u32 *)(prim + 0x24) = D_8018E098; - *(u32 *)(prim + 0x28) = D_8018E0A4; - *(u32 *)(prim + 0x2c) = D_8018E09C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018E0A8[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018E0A8[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018E0A8[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018E0A8[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018E124[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018E124[a1 & 0x7F]; -} - - - -extern s32 D_8018E144[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018E144[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018E1C0[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018E1C0[a1 & 0x7F]; -} - - - -extern u8 D_8018E1E0[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018E1E0[a1 & 0x7F]; -} - - - -extern u8 D_8018E200[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018E200[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018E220[])(void); - D_8018E220[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018E29C[])(void); - -void func_80165AC8(void) { - D_8018E29C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018E318[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018E318[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801D155C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801D155C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018E324[])(void); - -void func_80166018(void *a0) { - D_8018E324[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018E32C[])(void); - -void func_801663FC(void *a0) { - D_8018E32C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018E3F4[])(void); - -void func_80166618(void *a0) { - D_8018E3F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018E404[])(void); - -void func_80166654(void *a0) { - D_8018E404[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801D1E58[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801D1E58[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D1E58). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801D1E58[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801D1E58)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801D1E58[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801D1E58[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018E348[]; - extern u8 D_8018E334[]; - extern u8 D_8018E35C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018E348; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018E334; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018E35C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80167714); - - -extern void (*D_8018E414[])(void); - -void func_801678B4(void *a0) { - D_8018E414[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018E420[])(void); - -void func_80167A9C(void *a0) { - D_8018E420[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018E52C; - extern u8 D_8018E540[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018E52C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018E540; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018E380[]; -extern u8 D_8018E394[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018E380; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018E394; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018E438[])(void); - -void func_80168744(void *a0) { - D_8018E438[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018E428 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018E428[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018E428; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018E440[])(void); - -void func_801689D8(void *a0) { - D_8018E440[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018E448[])(void); - -void func_80168AA8(void *a0) { - D_8018E448[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018E450[])(void); - -void func_80168D58(void *a0) { - D_8018E450[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018E458[])(void); - -void func_8016901C(void *a0) { - D_8018E458[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015AE2C", func_80169228); - - -extern void (*D_8018E460[])(void); - -void func_801693CC(void *a0) { - D_8018E460[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018E468[])(void); - -void func_80169830(void *a0) { - D_8018E468[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018E51C[])(void); - -void func_80169B80(void *a0) { - D_8018E51C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018E470[]; - extern u8 D_8018E4E0[]; - extern u8 D_8018E510[]; - extern u8 D_801D34F8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018E510, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018E470[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801D34F8; - RotMatrixYXZ(rot, D_801D34F8); - func_80048D9C(D_801D34F8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018E4E0); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018E524[])(void); - -void func_80169F00(void *a0) { - D_8018E524[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018E4D4[]; -extern char D_8018E494[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018E4D4, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018E494); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018E55C[])(void); - -void func_8016A020(void *a0) { - D_8018E55C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018E52C; - extern u8 D_8018E540[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018E52C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018E540; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018E568[])(void); - -void func_8016A700(void *a0) { - D_8018E568[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018E5B0[])(void); - -void func_8016AB30(void *a0) { - D_8018E5B0[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c b/src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c new file mode 100644 index 000000000..719f9787d --- /dev/null +++ b/src/ov_SC02_028/ov_SC02_028_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018D97C; +extern u8 D_8018D8EC; +extern u8 D_8018D8C8; +extern u8 D_8018D8A4; +extern u8 D_8018D958; +extern u8 D_8018D934; +extern u8 D_8018D910; +extern u8 D_8018D880; +extern void func_80145934(void); +extern u8 D_8018DA0C; +extern u8 D_8018D9E8; +extern u8 D_8018D9C4; +extern u8 D_8018D9A0; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018CE04[]; +extern unsigned char D_8018CE34[]; +extern unsigned char D_8018CE84[]; +extern unsigned char D_8018CEB4[]; +extern unsigned char D_8018CEE4[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018CF34[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018CFFC[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018D084[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018D08C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801D1C88; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801D1C8C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018D0BC; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018D164[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018D188[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018D178; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018D19C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018D1A8[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018D1B8[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018D1D0[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018D1C0; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018D1E4[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018D200[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018D1F0; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018D214[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018D228[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018D23C; +extern void (*D_8018D264[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018D244; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018D2B0[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018D2B4[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018D718[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018D728[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801D1CC0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018D750[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018D730; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018D740; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018D790[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018D798[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018D764; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018D7A4[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018D774; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801D1CC8; +extern s32 D_801D1CD4; +extern s32 D_801D1CD8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018D7E0[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018D7B4[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801D1CD0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018DA30[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018D850[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018DAD4[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018DC28[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018DA44; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018DC30[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018DA54; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018DA74; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018DC38[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018DC60[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018DAE0[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018DC6C[])(void); + +void func_8015C714(void *a0) { + D_8018DC6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018DAE0[])(void*); + extern int D_8018DA84; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DA84); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018DAE0[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018DAE0[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018DAE0[])(void*); + extern int D_8018DA84; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DA84); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018DC7C[])(void); + D_8018DC7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018DAE0[])(struct Ent_8015CD20 *); + extern u8 D_8018DA94; + extern u8 D_8018DC84; + extern u8 D_8018DC94; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018DAE0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DA94); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DC84); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DC94); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018DAE0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018DCB4[])(void); + D_8018DCB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018DCA4; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018DCA4 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018DAE0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018DD10; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018DD10, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018CDF4[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018CDF4; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018DD18[])(void); + D_8018DD18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018DD24[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018DD24[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018DD24[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018DD24[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018DAE0[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018DD24[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018DAA4[]; + extern u8 D_8018DAB4[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DAA4); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DAB4); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018DD24[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018DD24[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018DD24[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018DD58[])(void); + D_8018DD58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018DAE0[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018DD60[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018DD78[])(void); + D_8018DD78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018DAE0[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018DD60[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018DD60[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018DD98[])(void); + D_8018DD98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018DAE0[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018DAE0)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018DDA8; +extern u16 D_8018DDAA; +extern u16 D_8018DDAC; +extern s32 D_8018DDB0; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018DDA8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018DDAA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018DDAC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018DDB0, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018DDB8; + +void func_8015E588(void) { + func_8013C9C4(&D_8018DDB8); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018DAE0[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018DAE0)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018DDCC[])(void); + D_8018DDCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018DAE0[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018DAE0[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018DDD4[])(void); + D_8018DDD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018DAC4; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018DAC4); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018DAE0[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018DDDC[])(void); + D_8018DDDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018DAE0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018DAE0[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018DDE4[])(void); + D_8018DDE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018DAE0[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018DDEC; + extern s32 D_8018DDFC; + extern s32 D_8018DE0C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DDEC); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DDFC); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018DAE0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DE0C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018DE1C[])(void); + D_8018DE1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018DAE0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018DAE0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018DAE0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018DAE0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018DE28[])(void); + D_8018DE28[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018DAE0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018DAE0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018DAE0[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018DAE0[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018DE3C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018DE3C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018DAE0[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018DAE0)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018DAE0[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018DAE0[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018DEB8[])(void); + D_8018DEB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018DAE0[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018DAE0)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018DEC8[])(void); + D_8018DEC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018DAE0[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018DAE0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018DAE0[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018DAE0[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018DAE0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018DAE0[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018DAE0[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018DED0[])(void); + D_8018DED0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018DAE0[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018DAE0)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018DAE0[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018DAE0)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018DEDC[])(void); + D_8018DEDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018DAE0 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018DAE0[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018DAE0[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018DAE0[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018DEEC[])(void); + +void func_80160EA4(void *a0) { + D_8018DEEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018DAE0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018DAE0[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018DF1C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018DF1C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018DF80; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018DF80); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801D1CE0[]; + extern u8 D_8018DF4C[]; + extern u8 D_8018DF6C[]; + extern u8 D_801D1CEC[]; + extern u8 D_801D1D14[]; + extern u8 D_801D1D2C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801D1CE0[0] = p; + func_80024054(&D_8018DF4C, &D_801D1CEC); + func_8001CE28(p, &D_801D1CEC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801D1CE0[1] = p; + func_80024054(&D_8018DF6C, &D_801D1D14); + func_8001CE28(p, &D_801D1D14); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801D1CE0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801D1D2C, 0x84); + func_8001CE68(p, &D_801D1D2C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801D1D2C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D1CE0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801D1CE0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018DF80; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018DF80; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018DF80; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018DF80; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801D1CE0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801D1CE0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018DFA4[])(void); + +void func_80162330(void *a0) { + D_8018DFA4[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801D1D38[i] via `extern int D_801D1D38[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018DFB0[]; + extern s32 D_8018DFC8; + extern u8 D_801D1D44[]; + extern u8 D_801D1D6C[]; + extern u8 D_801D1D88[]; + extern int D_801D1D38[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801D1D38[0] = (s32)item; + func_80024054(D_8018DFB0, D_801D1D44); + func_8001CE28(item, D_801D1D44); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801D1D38[1] = (s32)item; + func_80024054(((u8 *)&D_8018DFC8), D_801D1D6C); + func_8001CE28(item, D_801D1D6C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801D1D38[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801D1D88, 0x84); + func_8001CE68(item, D_801D1D88); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801D1D88, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D1D38[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801D1D38; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_801627E8); + + +extern void (*D_8018DFEC[])(void); + +void func_80162834(void *a0) { + D_8018DFEC[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018DFDC; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018DFDC, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801D154C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801D154C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801D154C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801D154C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018DFF4[])(void); + +void func_80163A58(void *a0) { + D_8018DFF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801D1554; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801D1554; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018E048[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018E048[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018E010; +extern s16 D_8018E044; +extern s16 D_8018E042; +extern s16 D_8018E040; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018E010; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018E044 = 0x80; + D_8018E042 = 0x80; + D_8018E040 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018E044 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E044` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018E044 - 8; + D_8018E044 = nv; + D_8018E042 = nv; + D_8018E040 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018E054[])(void); + +void func_80164BA0(void *a0) { + D_8018E054[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801D1D98; +extern u8 D_801D1D99; +extern u8 D_801D1D9A; +extern u8 D_801D1D9B; +extern u8 D_801D1D9C; +extern u8 D_801D1D9D; +extern u8 D_801D1D9E; +extern u8 D_801D1D9F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801D1D98; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801D1D99 = 0xf0; + *(u8 *)base = 0xf0; + D_801D1D9A = 0xc0; + D_801D1D9E = 0; + D_801D1D9D = 0; + D_801D1D9C = 0; + D_801D1D9F = 0; + D_801D1D9B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801D1D98; +extern u8 D_801D1D99; +extern u8 D_801D1D9A; + +s32 func_80164E40(void) { + u8 *p = &D_801D1D98; + if (*p != 0) { + *p -= 0x10; + } + if (D_801D1D99 != 0) { + D_801D1D99 -= 0x10; + } + if (D_801D1D9A != 0) { + D_801D1D9A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018E064[])(void); + +void func_80164EA4(void *a0) { + D_8018E064[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801D1DE4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801D1DE4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801D1DD8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801D1DD8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801D1DD8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801D1DD8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801D1DD8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018E078[]; + extern u32 D_8018E098, D_8018E09C, D_8018E0A0, D_8018E0A4; + extern u32 D_8018E098, D_8018E09C, D_8018E0A0, D_8018E0A4; + extern u32 D_8018E098, D_8018E09C, D_8018E0A0, D_8018E0A4; + extern u32 D_8018E098, D_8018E09C, D_8018E0A0, D_8018E0A4; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018E078[0x00], p); + ApplyMatrixSV(mat, &D_8018E078[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018E078[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018E078[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018E0A0; + *(u32 *)(prim + 0x24) = D_8018E098; + *(u32 *)(prim + 0x28) = D_8018E0A4; + *(u32 *)(prim + 0x2c) = D_8018E09C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018E0A8[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018E0A8[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018E0A8[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018E0A8[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018E124[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018E124[a1 & 0x7F]; +} + + + +extern s32 D_8018E144[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018E144[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018E1C0[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018E1C0[a1 & 0x7F]; +} + + + +extern u8 D_8018E1E0[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018E1E0[a1 & 0x7F]; +} + + + +extern u8 D_8018E200[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018E200[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018E220[])(void); + D_8018E220[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018E29C[])(void); + +void func_80165AC8(void) { + D_8018E29C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018E318[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018E318[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801D155C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801D155C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018E324[])(void); + +void func_80166018(void *a0) { + D_8018E324[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018E32C[])(void); + +void func_801663FC(void *a0) { + D_8018E32C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018E3F4[])(void); + +void func_80166618(void *a0) { + D_8018E3F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018E404[])(void); + +void func_80166654(void *a0) { + D_8018E404[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801D1E58[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801D1E58[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D1E58). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801D1E58[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801D1E58)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801D1E58[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801D1E58[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018E348[]; + extern u8 D_8018E334[]; + extern u8 D_8018E35C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018E348; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018E334; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018E35C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80167714); + + +extern void (*D_8018E414[])(void); + +void func_801678B4(void *a0) { + D_8018E414[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018E420[])(void); + +void func_80167A9C(void *a0) { + D_8018E420[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018E52C; + extern u8 D_8018E540[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018E52C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018E540; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018E380[]; +extern u8 D_8018E394[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018E380; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018E394; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018E438[])(void); + +void func_80168744(void *a0) { + D_8018E438[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018E428 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018E428[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018E428; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018E440[])(void); + +void func_801689D8(void *a0) { + D_8018E440[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018E448[])(void); + +void func_80168AA8(void *a0) { + D_8018E448[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018E450[])(void); + +void func_80168D58(void *a0) { + D_8018E450[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018E458[])(void); + +void func_8016901C(void *a0) { + D_8018E458[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_028/nonmatchings/ov_SC02_028_jr_8015C32C", func_80169228); + + +extern void (*D_8018E460[])(void); + +void func_801693CC(void *a0) { + D_8018E460[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018E468[])(void); + +void func_80169830(void *a0) { + D_8018E468[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018E51C[])(void); + +void func_80169B80(void *a0) { + D_8018E51C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018E470[]; + extern u8 D_8018E4E0[]; + extern u8 D_8018E510[]; + extern u8 D_801D34F8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018E510, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018E470[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801D34F8; + RotMatrixYXZ(rot, D_801D34F8); + func_80048D9C(D_801D34F8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018E4E0); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018E524[])(void); + +void func_80169F00(void *a0) { + D_8018E524[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018E4D4[]; +extern char D_8018E494[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018E4D4, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018E494); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018E55C[])(void); + +void func_8016A020(void *a0) { + D_8018E55C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018E52C; + extern u8 D_8018E540[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018E52C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018E540; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018E568[])(void); + +void func_8016A700(void *a0) { + D_8018E568[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018E5B0[])(void); + +void func_8016AB30(void *a0) { + D_8018E5B0[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_031/ov_SC02_031_jr_8015AE2C.c b/src/ov_SC02_031/ov_SC02_031_jr_8015AE2C.c index 5f4303367..dd61491ae 100644 --- a/src/ov_SC02_031/ov_SC02_031_jr_8015AE2C.c +++ b/src/ov_SC02_031/ov_SC02_031_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80187498[])(void); - -void func_8015C714(void *a0) { - D_80187498[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018730C[])(void*); - extern int D_801872B0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018730C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018730C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801872B0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018730C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018730C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018730C[])(void*); - extern int D_801872B0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018730C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801872B0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018730C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801874A8[])(void); - D_801874A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018730C[])(struct Ent_8015CD20 *); - extern u8 D_801872C0; - extern u8 D_801874B0; - extern u8 D_801874C0; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018730C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801872C0); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801874B0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801874C0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018730C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801874E0[])(void); - D_801874E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801874D0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801874D0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018730C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018753C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018753C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80186620[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80186620; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80187544[])(void); - D_80187544[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80187550[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80187550[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80187550[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80187550[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018730C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80187550[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801872D0[]; - extern u8 D_801872E0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801872D0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801872E0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80187550[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187550[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187550[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80187584[])(void); - D_80187584[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018730C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018758C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801875A4[])(void); - D_801875A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018730C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018758C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801875C4[])(void); - D_801875C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018730C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018730C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801875D4; -extern u16 D_801875D6; -extern u16 D_801875D8; -extern s32 D_801875DC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801875D4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801875D6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801875D8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801875DC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801875E4; - -void func_8015E588(void) { - func_8013C9C4(&D_801875E4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018730C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018730C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801875F8[])(void); - D_801875F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018730C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018730C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80187600[])(void); - D_80187600[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801872F0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801872F0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018730C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187608[])(void); - D_80187608[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018730C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018730C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80187610[])(void); - D_80187610[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018730C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80187618; - extern s32 D_80187628; - extern s32 D_80187638; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018730C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187618); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187628); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018730C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187638); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80187648[])(void); - D_80187648[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018730C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018730C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018730C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018730C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80187654[])(void); - D_80187654[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018730C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018730C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018730C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018730C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80187668[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80187668[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018730C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018730C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018730C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018730C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801876E4[])(void); - D_801876E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018730C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018730C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801876F4[])(void); - D_801876F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018730C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018730C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018730C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018730C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018730C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018730C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018730C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801876FC[])(void); - D_801876FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018730C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018730C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018730C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018730C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187708[])(void); - D_80187708[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018730C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018730C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018730C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018730C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80187718[])(void); - -void func_80160EA4(void *a0) { - D_80187718[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018730C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018730C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80187748[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80187748[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801877AC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801877AC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B6458[]; - extern u8 D_80187778[]; - extern u8 D_80187798[]; - extern u8 D_801B6464[]; - extern u8 D_801B648C[]; - extern u8 D_801B64A4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B6458[0] = p; - func_80024054(&D_80187778, &D_801B6464); - func_8001CE28(p, &D_801B6464); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B6458[1] = p; - func_80024054(&D_80187798, &D_801B648C); - func_8001CE28(p, &D_801B648C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B6458[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B64A4, 0x84); - func_8001CE68(p, &D_801B64A4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B64A4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B6458[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B6458; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801877AC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801877AC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801877AC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801877AC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B6458[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B6458; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801877D0[])(void); - -void func_80162330(void *a0) { - D_801877D0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B64B0[i] via `extern int D_801B64B0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801877DC[]; - extern s32 D_801877F4; - extern u8 D_801B64BC[]; - extern u8 D_801B64E4[]; - extern u8 D_801B6500[]; - extern int D_801B64B0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B64B0[0] = (s32)item; - func_80024054(D_801877DC, D_801B64BC); - func_8001CE28(item, D_801B64BC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B64B0[1] = (s32)item; - func_80024054(((u8 *)&D_801877F4), D_801B64E4); - func_8001CE28(item, D_801B64E4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B64B0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B6500, 0x84); - func_8001CE68(item, D_801B6500); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B6500, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B64B0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B64B0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187818[])(void); - -void func_80162834(void *a0) { - D_80187818[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187808; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187808, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B5D48[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B5D48, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B5D48[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B5D48, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80187820[])(void); - -void func_80163A58(void *a0) { - D_80187820[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B5D50; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B5D50; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80187874[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80187874[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018783C; -extern s16 D_80187870; -extern s16 D_8018786E; -extern s16 D_8018786C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018783C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80187870 = 0x80; - D_8018786E = 0x80; - D_8018786C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80187870 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187870` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80187870 - 8; - D_80187870 = nv; - D_8018786E = nv; - D_8018786C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80187880[])(void); - -void func_80164BA0(void *a0) { - D_80187880[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B6510; -extern u8 D_801B6511; -extern u8 D_801B6512; -extern u8 D_801B6513; -extern u8 D_801B6514; -extern u8 D_801B6515; -extern u8 D_801B6516; -extern u8 D_801B6517; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B6510; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B6511 = 0xf0; - *(u8 *)base = 0xf0; - D_801B6512 = 0xc0; - D_801B6516 = 0; - D_801B6515 = 0; - D_801B6514 = 0; - D_801B6517 = 0; - D_801B6513 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B6510; -extern u8 D_801B6511; -extern u8 D_801B6512; - -s32 func_80164E40(void) { - u8 *p = &D_801B6510; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B6511 != 0) { - D_801B6511 -= 0x10; - } - if (D_801B6512 != 0) { - D_801B6512 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80187890[])(void); - -void func_80164EA4(void *a0) { - D_80187890[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B655C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B655C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B6550[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B6550[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B6550[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B6550; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B6550; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801878A4[]; - extern u32 D_801878C4, D_801878C8, D_801878CC, D_801878D0; - extern u32 D_801878C4, D_801878C8, D_801878CC, D_801878D0; - extern u32 D_801878C4, D_801878C8, D_801878CC, D_801878D0; - extern u32 D_801878C4, D_801878C8, D_801878CC, D_801878D0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801878A4[0x00], p); - ApplyMatrixSV(mat, &D_801878A4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801878A4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801878A4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801878CC; - *(u32 *)(prim + 0x24) = D_801878C4; - *(u32 *)(prim + 0x28) = D_801878D0; - *(u32 *)(prim + 0x2c) = D_801878C8; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801878D4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801878D4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801878D4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801878D4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80187950[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80187950[a1 & 0x7F]; -} - - - -extern s32 D_80187970[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80187970[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801879EC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801879EC[a1 & 0x7F]; -} - - - -extern u8 D_80187A0C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80187A0C[a1 & 0x7F]; -} - - - -extern u8 D_80187A2C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80187A2C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80187A4C[])(void); - D_80187A4C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187AC8[])(void); - -void func_80165AC8(void) { - D_80187AC8[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80187B44[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80187B44[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B5D58; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B5D58, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80187B50[])(void); - -void func_80166018(void *a0) { - D_80187B50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80187B58[])(void); - -void func_801663FC(void *a0) { - D_80187B58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80187C20[])(void); - -void func_80166618(void *a0) { - D_80187C20[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80187C30[])(void); - -void func_80166654(void *a0) { - D_80187C30[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B65D0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B65D0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B65D0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B65D0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B65D0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B65D0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B65D0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80187B74[]; - extern u8 D_80187B60[]; - extern u8 D_80187B88[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80187B74; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80187B60; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187B88; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80167714); - - -extern void (*D_80187C40[])(void); - -void func_801678B4(void *a0) { - D_80187C40[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80187C4C[])(void); - -void func_80167A9C(void *a0) { - D_80187C4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80187D58; - extern u8 D_80187D6C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80187D58); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187D6C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80187BAC[]; -extern u8 D_80187BC0[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80187BAC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187BC0; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80187C64[])(void); - -void func_80168744(void *a0) { - D_80187C64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80187C54 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80187C54[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80187C54; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80187C6C[])(void); - -void func_801689D8(void *a0) { - D_80187C6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80187C74[])(void); - -void func_80168AA8(void *a0) { - D_80187C74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80187C7C[])(void); - -void func_80168D58(void *a0) { - D_80187C7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80187C84[])(void); - -void func_8016901C(void *a0) { - D_80187C84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015AE2C", func_80169228); - - -extern void (*D_80187C8C[])(void); - -void func_801693CC(void *a0) { - D_80187C8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80187C94[])(void); - -void func_80169830(void *a0) { - D_80187C94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187D48[])(void); - -void func_80169B80(void *a0) { - D_80187D48[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80187C9C[]; - extern u8 D_80187D0C[]; - extern u8 D_80187D3C[]; - extern u8 D_801B79C8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80187D3C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80187C9C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B79C8; - RotMatrixYXZ(rot, D_801B79C8); - func_80048D9C(D_801B79C8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80187D0C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80187D50[])(void); - -void func_80169F00(void *a0) { - D_80187D50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80187D00[]; -extern char D_80187CC0[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80187D00, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187CC0); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187D88[])(void); - -void func_8016A020(void *a0) { - D_80187D88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80187D58; - extern u8 D_80187D6C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80187D58); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187D6C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80187D94[])(void); - -void func_8016A700(void *a0) { - D_80187D94[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80187DDC[])(void); - -void func_8016AB30(void *a0) { - D_80187DDC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c b/src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c new file mode 100644 index 000000000..4e3ec39c7 --- /dev/null +++ b/src/ov_SC02_031/ov_SC02_031_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801871A8; +extern u8 D_80187118; +extern u8 D_801870F4; +extern u8 D_801870D0; +extern u8 D_80187184; +extern u8 D_80187160; +extern u8 D_8018713C; +extern u8 D_801870AC; +extern void func_80145934(void); +extern u8 D_80187238; +extern u8 D_80187214; +extern u8 D_801871F0; +extern u8 D_801871CC; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80186630[]; +extern unsigned char D_80186660[]; +extern unsigned char D_801866B0[]; +extern unsigned char D_801866E0[]; +extern unsigned char D_80186710[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80186760[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80186828[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801868B0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801868B8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B6400; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B6404; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801868E8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80186990[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801869B4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801869A4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801869C8[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801869D4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801869E4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801869FC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801869EC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80186A10[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80186A2C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80186A1C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80186A40[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80186A54[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80186A68; +extern void (*D_80186A90[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80186A70; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80186ADC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80186AE0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186F44[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80186F54[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B6438; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80186F7C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80186F5C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80186F6C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80186FBC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80186FC4[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80186F90; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80186FD0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80186FA0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B6440; +extern s32 D_801B644C; +extern s32 D_801B6450; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018700C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80186FE0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B6448; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018725C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018707C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80187300[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80187454[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80187270; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018745C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80187280; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801872A0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80187464[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018748C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018730C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80187498[])(void); + +void func_8015C714(void *a0) { + D_80187498[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018730C[])(void*); + extern int D_801872B0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018730C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018730C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801872B0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018730C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018730C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018730C[])(void*); + extern int D_801872B0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018730C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801872B0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018730C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801874A8[])(void); + D_801874A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018730C[])(struct Ent_8015CD20 *); + extern u8 D_801872C0; + extern u8 D_801874B0; + extern u8 D_801874C0; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018730C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801872C0); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801874B0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801874C0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018730C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801874E0[])(void); + D_801874E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801874D0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801874D0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018730C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018753C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018753C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80186620[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80186620; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80187544[])(void); + D_80187544[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80187550[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80187550[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80187550[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80187550[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018730C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80187550[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801872D0[]; + extern u8 D_801872E0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801872D0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801872E0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80187550[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187550[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187550[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80187584[])(void); + D_80187584[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018730C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018758C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801875A4[])(void); + D_801875A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018730C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018758C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018758C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801875C4[])(void); + D_801875C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018730C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018730C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801875D4; +extern u16 D_801875D6; +extern u16 D_801875D8; +extern s32 D_801875DC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801875D4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801875D6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801875D8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801875DC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801875E4; + +void func_8015E588(void) { + func_8013C9C4(&D_801875E4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018730C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018730C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801875F8[])(void); + D_801875F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018730C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018730C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80187600[])(void); + D_80187600[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801872F0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801872F0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018730C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187608[])(void); + D_80187608[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018730C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018730C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80187610[])(void); + D_80187610[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018730C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80187618; + extern s32 D_80187628; + extern s32 D_80187638; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187618); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187628); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018730C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187638); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80187648[])(void); + D_80187648[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018730C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018730C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018730C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018730C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80187654[])(void); + D_80187654[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018730C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018730C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018730C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018730C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80187668[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80187668[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018730C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018730C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018730C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018730C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801876E4[])(void); + D_801876E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018730C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018730C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801876F4[])(void); + D_801876F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018730C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018730C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018730C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018730C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018730C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018730C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018730C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801876FC[])(void); + D_801876FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018730C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018730C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018730C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018730C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187708[])(void); + D_80187708[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018730C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018730C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018730C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018730C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80187718[])(void); + +void func_80160EA4(void *a0) { + D_80187718[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018730C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018730C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80187748[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80187748[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801877AC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801877AC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B6458[]; + extern u8 D_80187778[]; + extern u8 D_80187798[]; + extern u8 D_801B6464[]; + extern u8 D_801B648C[]; + extern u8 D_801B64A4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B6458[0] = p; + func_80024054(&D_80187778, &D_801B6464); + func_8001CE28(p, &D_801B6464); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B6458[1] = p; + func_80024054(&D_80187798, &D_801B648C); + func_8001CE28(p, &D_801B648C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B6458[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B64A4, 0x84); + func_8001CE68(p, &D_801B64A4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B64A4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B6458[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B6458; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801877AC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801877AC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801877AC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801877AC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B6458[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B6458; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801877D0[])(void); + +void func_80162330(void *a0) { + D_801877D0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B64B0[i] via `extern int D_801B64B0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801877DC[]; + extern s32 D_801877F4; + extern u8 D_801B64BC[]; + extern u8 D_801B64E4[]; + extern u8 D_801B6500[]; + extern int D_801B64B0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B64B0[0] = (s32)item; + func_80024054(D_801877DC, D_801B64BC); + func_8001CE28(item, D_801B64BC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B64B0[1] = (s32)item; + func_80024054(((u8 *)&D_801877F4), D_801B64E4); + func_8001CE28(item, D_801B64E4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B64B0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B6500, 0x84); + func_8001CE68(item, D_801B6500); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B6500, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B64B0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B64B0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_801627E8); + + +extern void (*D_80187818[])(void); + +void func_80162834(void *a0) { + D_80187818[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187808; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187808, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B5D48[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B5D48, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B5D48[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B5D48, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80187820[])(void); + +void func_80163A58(void *a0) { + D_80187820[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B5D50; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B5D50; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80187874[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80187874[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018783C; +extern s16 D_80187870; +extern s16 D_8018786E; +extern s16 D_8018786C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018783C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80187870 = 0x80; + D_8018786E = 0x80; + D_8018786C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80187870 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187870` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80187870 - 8; + D_80187870 = nv; + D_8018786E = nv; + D_8018786C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80187880[])(void); + +void func_80164BA0(void *a0) { + D_80187880[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B6510; +extern u8 D_801B6511; +extern u8 D_801B6512; +extern u8 D_801B6513; +extern u8 D_801B6514; +extern u8 D_801B6515; +extern u8 D_801B6516; +extern u8 D_801B6517; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B6510; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B6511 = 0xf0; + *(u8 *)base = 0xf0; + D_801B6512 = 0xc0; + D_801B6516 = 0; + D_801B6515 = 0; + D_801B6514 = 0; + D_801B6517 = 0; + D_801B6513 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B6510; +extern u8 D_801B6511; +extern u8 D_801B6512; + +s32 func_80164E40(void) { + u8 *p = &D_801B6510; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B6511 != 0) { + D_801B6511 -= 0x10; + } + if (D_801B6512 != 0) { + D_801B6512 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80187890[])(void); + +void func_80164EA4(void *a0) { + D_80187890[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B655C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B655C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B6550[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B6550[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B6550[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B6550; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B6550; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801878A4[]; + extern u32 D_801878C4, D_801878C8, D_801878CC, D_801878D0; + extern u32 D_801878C4, D_801878C8, D_801878CC, D_801878D0; + extern u32 D_801878C4, D_801878C8, D_801878CC, D_801878D0; + extern u32 D_801878C4, D_801878C8, D_801878CC, D_801878D0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801878A4[0x00], p); + ApplyMatrixSV(mat, &D_801878A4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801878A4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801878A4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801878CC; + *(u32 *)(prim + 0x24) = D_801878C4; + *(u32 *)(prim + 0x28) = D_801878D0; + *(u32 *)(prim + 0x2c) = D_801878C8; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801878D4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801878D4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801878D4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801878D4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80187950[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80187950[a1 & 0x7F]; +} + + + +extern s32 D_80187970[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80187970[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801879EC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801879EC[a1 & 0x7F]; +} + + + +extern u8 D_80187A0C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80187A0C[a1 & 0x7F]; +} + + + +extern u8 D_80187A2C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80187A2C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80187A4C[])(void); + D_80187A4C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187AC8[])(void); + +void func_80165AC8(void) { + D_80187AC8[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80187B44[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80187B44[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B5D58; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B5D58, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80187B50[])(void); + +void func_80166018(void *a0) { + D_80187B50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80187B58[])(void); + +void func_801663FC(void *a0) { + D_80187B58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80187C20[])(void); + +void func_80166618(void *a0) { + D_80187C20[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80187C30[])(void); + +void func_80166654(void *a0) { + D_80187C30[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B65D0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B65D0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B65D0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B65D0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B65D0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B65D0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B65D0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80187B74[]; + extern u8 D_80187B60[]; + extern u8 D_80187B88[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80187B74; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80187B60; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187B88; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80167714); + + +extern void (*D_80187C40[])(void); + +void func_801678B4(void *a0) { + D_80187C40[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80187C4C[])(void); + +void func_80167A9C(void *a0) { + D_80187C4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80187D58; + extern u8 D_80187D6C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80187D58); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187D6C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80187BAC[]; +extern u8 D_80187BC0[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80187BAC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187BC0; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80187C64[])(void); + +void func_80168744(void *a0) { + D_80187C64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80187C54 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80187C54[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80187C54; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80187C6C[])(void); + +void func_801689D8(void *a0) { + D_80187C6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80187C74[])(void); + +void func_80168AA8(void *a0) { + D_80187C74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80187C7C[])(void); + +void func_80168D58(void *a0) { + D_80187C7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80187C84[])(void); + +void func_8016901C(void *a0) { + D_80187C84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_031/nonmatchings/ov_SC02_031_jr_8015C32C", func_80169228); + + +extern void (*D_80187C8C[])(void); + +void func_801693CC(void *a0) { + D_80187C8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80187C94[])(void); + +void func_80169830(void *a0) { + D_80187C94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187D48[])(void); + +void func_80169B80(void *a0) { + D_80187D48[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80187C9C[]; + extern u8 D_80187D0C[]; + extern u8 D_80187D3C[]; + extern u8 D_801B79C8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80187D3C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80187C9C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B79C8; + RotMatrixYXZ(rot, D_801B79C8); + func_80048D9C(D_801B79C8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80187D0C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80187D50[])(void); + +void func_80169F00(void *a0) { + D_80187D50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80187D00[]; +extern char D_80187CC0[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80187D00, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187CC0); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187D88[])(void); + +void func_8016A020(void *a0) { + D_80187D88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80187D58; + extern u8 D_80187D6C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80187D58); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187D6C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80187D94[])(void); + +void func_8016A700(void *a0) { + D_80187D94[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80187DDC[])(void); + +void func_8016AB30(void *a0) { + D_80187DDC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_035/ov_SC02_035_jr_8015AE2C.c b/src/ov_SC02_035/ov_SC02_035_jr_8015AE2C.c index af1d4429f..d89fa3cf1 100644 --- a/src/ov_SC02_035/ov_SC02_035_jr_8015AE2C.c +++ b/src/ov_SC02_035/ov_SC02_035_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80186CF8[])(void); - -void func_8015C714(void *a0) { - D_80186CF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80186B6C[])(void*); - extern int D_80186B10; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80186B6C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80186B6C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186B10); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80186B6C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80186B6C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80186B6C[])(void*); - extern int D_80186B10; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80186B6C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186B10); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80186B6C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80186D08[])(void); - D_80186D08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80186B6C[])(struct Ent_8015CD20 *); - extern u8 D_80186B20; - extern u8 D_80186D10; - extern u8 D_80186D20; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80186B6C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186B20); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D10); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D20); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80186B6C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80186D40[])(void); - D_80186D40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80186D30; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80186D30 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80186B6C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80186D9C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80186D9C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80185E80[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80185E80; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80186DA4[])(void); - D_80186DA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80186DB0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80186DB0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80186DB0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80186DB0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80186B6C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80186DB0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80186B30[]; - extern u8 D_80186B40[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186B30); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186B40); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80186DB0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186DB0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186DB0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80186DE4[])(void); - D_80186DE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186B6C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186DEC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80186E04[])(void); - D_80186E04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186B6C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186DEC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80186E24[])(void); - D_80186E24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80186B6C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186B6C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80186E34; -extern u16 D_80186E36; -extern u16 D_80186E38; -extern s32 D_80186E3C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80186E34 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80186E36 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80186E38 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186E3C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80186E44; - -void func_8015E588(void) { - func_8013C9C4(&D_80186E44); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80186B6C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186B6C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80186E58[])(void); - D_80186E58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80186B6C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80186B6C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80186E60[])(void); - D_80186E60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80186B50; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186B50); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80186B6C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80186E68[])(void); - D_80186E68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80186B6C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80186B6C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80186E70[])(void); - D_80186E70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80186B6C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80186E78; - extern s32 D_80186E88; - extern s32 D_80186E98; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80186B6C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E78); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E88); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80186B6C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E98); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80186EA8[])(void); - D_80186EA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80186B6C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80186B6C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80186B6C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186B6C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80186EB4[])(void); - D_80186EB4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80186B6C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186B6C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80186B6C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186B6C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80186EC8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80186EC8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80186B6C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80186B6C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80186B6C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186B6C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80186F44[])(void); - D_80186F44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80186B6C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80186B6C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80186F54[])(void); - D_80186F54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80186B6C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80186B6C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80186B6C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80186B6C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80186B6C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80186B6C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80186B6C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80186F5C[])(void); - D_80186F5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80186B6C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80186B6C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80186B6C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80186B6C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80186F68[])(void); - D_80186F68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186B6C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80186B6C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80186B6C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80186B6C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80186F78[])(void); - -void func_80160EA4(void *a0) { - D_80186F78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80186B6C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80186B6C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80186FA8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80186FA8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018700C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018700C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801BD788[]; - extern u8 D_80186FD8[]; - extern u8 D_80186FF8[]; - extern u8 D_801BD794[]; - extern u8 D_801BD7BC[]; - extern u8 D_801BD7D4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801BD788[0] = p; - func_80024054(&D_80186FD8, &D_801BD794); - func_8001CE28(p, &D_801BD794); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801BD788[1] = p; - func_80024054(&D_80186FF8, &D_801BD7BC); - func_8001CE28(p, &D_801BD7BC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801BD788[2] = p; - func_800242D0((s16)func_801620C4(), &D_801BD7D4, 0x84); - func_8001CE68(p, &D_801BD7D4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801BD7D4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BD788[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801BD788; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018700C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018700C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018700C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018700C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801BD788[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801BD788; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80187030[])(void); - -void func_80162330(void *a0) { - D_80187030[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801BD7E0[i] via `extern int D_801BD7E0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018703C[]; - extern s32 D_80187054; - extern u8 D_801BD7EC[]; - extern u8 D_801BD814[]; - extern u8 D_801BD830[]; - extern int D_801BD7E0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801BD7E0[0] = (s32)item; - func_80024054(D_8018703C, D_801BD7EC); - func_8001CE28(item, D_801BD7EC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801BD7E0[1] = (s32)item; - func_80024054(((u8 *)&D_80187054), D_801BD814); - func_8001CE28(item, D_801BD814); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801BD7E0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801BD830, 0x84); - func_8001CE68(item, D_801BD830); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801BD830, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BD7E0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801BD7E0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187078[])(void); - -void func_80162834(void *a0) { - D_80187078[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187068; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187068, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801BD010[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801BD010, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801BD010[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801BD010, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80187080[])(void); - -void func_80163A58(void *a0) { - D_80187080[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801BD018; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801BD018; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801870D4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801870D4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018709C; -extern s16 D_801870D0; -extern s16 D_801870CE; -extern s16 D_801870CC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018709C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801870D0 = 0x80; - D_801870CE = 0x80; - D_801870CC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801870D0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801870D0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801870D0 - 8; - D_801870D0 = nv; - D_801870CE = nv; - D_801870CC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801870E0[])(void); - -void func_80164BA0(void *a0) { - D_801870E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801BD840; -extern u8 D_801BD841; -extern u8 D_801BD842; -extern u8 D_801BD843; -extern u8 D_801BD844; -extern u8 D_801BD845; -extern u8 D_801BD846; -extern u8 D_801BD847; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801BD840; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801BD841 = 0xf0; - *(u8 *)base = 0xf0; - D_801BD842 = 0xc0; - D_801BD846 = 0; - D_801BD845 = 0; - D_801BD844 = 0; - D_801BD847 = 0; - D_801BD843 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801BD840; -extern u8 D_801BD841; -extern u8 D_801BD842; - -s32 func_80164E40(void) { - u8 *p = &D_801BD840; - if (*p != 0) { - *p -= 0x10; - } - if (D_801BD841 != 0) { - D_801BD841 -= 0x10; - } - if (D_801BD842 != 0) { - D_801BD842 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801870F0[])(void); - -void func_80164EA4(void *a0) { - D_801870F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801BD88C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801BD88C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801BD880[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801BD880[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801BD880[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801BD880; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801BD880; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80187104[]; - extern u32 D_80187124, D_80187128, D_8018712C, D_80187130; - extern u32 D_80187124, D_80187128, D_8018712C, D_80187130; - extern u32 D_80187124, D_80187128, D_8018712C, D_80187130; - extern u32 D_80187124, D_80187128, D_8018712C, D_80187130; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80187104[0x00], p); - ApplyMatrixSV(mat, &D_80187104[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80187104[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80187104[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018712C; - *(u32 *)(prim + 0x24) = D_80187124; - *(u32 *)(prim + 0x28) = D_80187130; - *(u32 *)(prim + 0x2c) = D_80187128; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187134[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187134[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187134[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187134[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801871B0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801871B0[a1 & 0x7F]; -} - - - -extern s32 D_801871D0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801871D0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018724C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018724C[a1 & 0x7F]; -} - - - -extern u8 D_8018726C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018726C[a1 & 0x7F]; -} - - - -extern u8 D_8018728C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018728C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801872AC[])(void); - D_801872AC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187328[])(void); - -void func_80165AC8(void) { - D_80187328[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801873A4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801873A4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801BD020; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801BD020, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801873B0[])(void); - -void func_80166018(void *a0) { - D_801873B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801873B8[])(void); - -void func_801663FC(void *a0) { - D_801873B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80187480[])(void); - -void func_80166618(void *a0) { - D_80187480[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80187490[])(void); - -void func_80166654(void *a0) { - D_80187490[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801BD900[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801BD900[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BD900). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801BD900[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801BD900)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801BD900[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801BD900[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801873D4[]; - extern u8 D_801873C0[]; - extern u8 D_801873E8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801873D4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801873C0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801873E8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80167714); - - -extern void (*D_801874A0[])(void); - -void func_801678B4(void *a0) { - D_801874A0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801874AC[])(void); - -void func_80167A9C(void *a0) { - D_801874AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801875B8; - extern u8 D_801875CC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801875B8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801875CC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018740C[]; -extern u8 D_80187420[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018740C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187420; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801874C4[])(void); - -void func_80168744(void *a0) { - D_801874C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801874B4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801874B4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801874B4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801874CC[])(void); - -void func_801689D8(void *a0) { - D_801874CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801874D4[])(void); - -void func_80168AA8(void *a0) { - D_801874D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801874DC[])(void); - -void func_80168D58(void *a0) { - D_801874DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801874E4[])(void); - -void func_8016901C(void *a0) { - D_801874E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015AE2C", func_80169228); - - -extern void (*D_801874EC[])(void); - -void func_801693CC(void *a0) { - D_801874EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801874F4[])(void); - -void func_80169830(void *a0) { - D_801874F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801875A8[])(void); - -void func_80169B80(void *a0) { - D_801875A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801874FC[]; - extern u8 D_8018756C[]; - extern u8 D_8018759C[]; - extern u8 D_801BE900[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018759C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801874FC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801BE900; - RotMatrixYXZ(rot, D_801BE900); - func_80048D9C(D_801BE900, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018756C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801875B0[])(void); - -void func_80169F00(void *a0) { - D_801875B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80187560[]; -extern char D_80187520[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80187560, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187520); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801875E8[])(void); - -void func_8016A020(void *a0) { - D_801875E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801875B8; - extern u8 D_801875CC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801875B8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801875CC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801875F4[])(void); - -void func_8016A700(void *a0) { - D_801875F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018763C[])(void); - -void func_8016AB30(void *a0) { - D_8018763C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c b/src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c new file mode 100644 index 000000000..5666f5236 --- /dev/null +++ b/src/ov_SC02_035/ov_SC02_035_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80186A08; +extern u8 D_80186978; +extern u8 D_80186954; +extern u8 D_80186930; +extern u8 D_801869E4; +extern u8 D_801869C0; +extern u8 D_8018699C; +extern u8 D_8018690C; +extern void func_80145934(void); +extern u8 D_80186A98; +extern u8 D_80186A74; +extern u8 D_80186A50; +extern u8 D_80186A2C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80185E90[]; +extern unsigned char D_80185EC0[]; +extern unsigned char D_80185F10[]; +extern unsigned char D_80185F40[]; +extern unsigned char D_80185F70[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80185FC0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80186088[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80186110[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186118; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801BD730; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801BD734; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186148; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801861F0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80186214[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80186204; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186228[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80186234[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80186244[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018625C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018624C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80186270[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018628C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018627C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801862A0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801862B4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801862C8; +extern void (*D_801862F0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801862D0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018633C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80186340[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801867A4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801867B4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801BD768; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801867DC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801867BC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801867CC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018681C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80186824[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801867F0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80186830[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80186800; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801BD770; +extern s32 D_801BD77C; +extern s32 D_801BD780; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018686C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80186840[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801BD778; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80186ABC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801868DC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80186B60[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80186CB4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186AD0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80186CBC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186AE0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80186B00; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80186CC4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80186CEC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80186B6C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80186CF8[])(void); + +void func_8015C714(void *a0) { + D_80186CF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80186B6C[])(void*); + extern int D_80186B10; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80186B6C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80186B6C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186B10); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80186B6C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80186B6C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80186B6C[])(void*); + extern int D_80186B10; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80186B6C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186B10); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80186B6C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80186D08[])(void); + D_80186D08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80186B6C[])(struct Ent_8015CD20 *); + extern u8 D_80186B20; + extern u8 D_80186D10; + extern u8 D_80186D20; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80186B6C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186B20); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D10); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D20); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80186B6C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80186D40[])(void); + D_80186D40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80186D30; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80186D30 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80186B6C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80186D9C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80186D9C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80185E80[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80185E80; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80186DA4[])(void); + D_80186DA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80186DB0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80186DB0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80186DB0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80186DB0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80186B6C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80186DB0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80186B30[]; + extern u8 D_80186B40[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186B30); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186B40); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80186DB0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186DB0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186DB0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80186DE4[])(void); + D_80186DE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186B6C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186DEC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80186E04[])(void); + D_80186E04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186B6C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186DEC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186DEC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80186E24[])(void); + D_80186E24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80186B6C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186B6C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80186E34; +extern u16 D_80186E36; +extern u16 D_80186E38; +extern s32 D_80186E3C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80186E34 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80186E36 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80186E38 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186E3C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80186E44; + +void func_8015E588(void) { + func_8013C9C4(&D_80186E44); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80186B6C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186B6C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80186E58[])(void); + D_80186E58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80186B6C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80186B6C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80186E60[])(void); + D_80186E60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80186B50; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186B50); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80186B6C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80186E68[])(void); + D_80186E68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80186B6C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80186B6C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80186E70[])(void); + D_80186E70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80186B6C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80186E78; + extern s32 D_80186E88; + extern s32 D_80186E98; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E78); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E88); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80186B6C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186E98); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80186EA8[])(void); + D_80186EA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80186B6C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80186B6C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80186B6C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186B6C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80186EB4[])(void); + D_80186EB4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80186B6C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186B6C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80186B6C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186B6C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80186EC8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80186EC8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80186B6C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80186B6C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80186B6C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186B6C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80186F44[])(void); + D_80186F44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80186B6C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80186B6C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80186F54[])(void); + D_80186F54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80186B6C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80186B6C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80186B6C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80186B6C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80186B6C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80186B6C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80186B6C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80186F5C[])(void); + D_80186F5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80186B6C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80186B6C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80186B6C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80186B6C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80186F68[])(void); + D_80186F68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186B6C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80186B6C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80186B6C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80186B6C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80186F78[])(void); + +void func_80160EA4(void *a0) { + D_80186F78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80186B6C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80186B6C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80186FA8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80186FA8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018700C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018700C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801BD788[]; + extern u8 D_80186FD8[]; + extern u8 D_80186FF8[]; + extern u8 D_801BD794[]; + extern u8 D_801BD7BC[]; + extern u8 D_801BD7D4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801BD788[0] = p; + func_80024054(&D_80186FD8, &D_801BD794); + func_8001CE28(p, &D_801BD794); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801BD788[1] = p; + func_80024054(&D_80186FF8, &D_801BD7BC); + func_8001CE28(p, &D_801BD7BC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801BD788[2] = p; + func_800242D0((s16)func_801620C4(), &D_801BD7D4, 0x84); + func_8001CE68(p, &D_801BD7D4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801BD7D4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BD788[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801BD788; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018700C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018700C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018700C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018700C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801BD788[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801BD788; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80187030[])(void); + +void func_80162330(void *a0) { + D_80187030[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801BD7E0[i] via `extern int D_801BD7E0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018703C[]; + extern s32 D_80187054; + extern u8 D_801BD7EC[]; + extern u8 D_801BD814[]; + extern u8 D_801BD830[]; + extern int D_801BD7E0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801BD7E0[0] = (s32)item; + func_80024054(D_8018703C, D_801BD7EC); + func_8001CE28(item, D_801BD7EC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801BD7E0[1] = (s32)item; + func_80024054(((u8 *)&D_80187054), D_801BD814); + func_8001CE28(item, D_801BD814); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801BD7E0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801BD830, 0x84); + func_8001CE68(item, D_801BD830); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801BD830, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BD7E0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801BD7E0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_801627E8); + + +extern void (*D_80187078[])(void); + +void func_80162834(void *a0) { + D_80187078[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187068; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187068, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801BD010[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801BD010, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801BD010[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801BD010, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80187080[])(void); + +void func_80163A58(void *a0) { + D_80187080[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801BD018; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801BD018; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801870D4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801870D4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018709C; +extern s16 D_801870D0; +extern s16 D_801870CE; +extern s16 D_801870CC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018709C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801870D0 = 0x80; + D_801870CE = 0x80; + D_801870CC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801870D0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801870D0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801870D0 - 8; + D_801870D0 = nv; + D_801870CE = nv; + D_801870CC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801870E0[])(void); + +void func_80164BA0(void *a0) { + D_801870E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801BD840; +extern u8 D_801BD841; +extern u8 D_801BD842; +extern u8 D_801BD843; +extern u8 D_801BD844; +extern u8 D_801BD845; +extern u8 D_801BD846; +extern u8 D_801BD847; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801BD840; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801BD841 = 0xf0; + *(u8 *)base = 0xf0; + D_801BD842 = 0xc0; + D_801BD846 = 0; + D_801BD845 = 0; + D_801BD844 = 0; + D_801BD847 = 0; + D_801BD843 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801BD840; +extern u8 D_801BD841; +extern u8 D_801BD842; + +s32 func_80164E40(void) { + u8 *p = &D_801BD840; + if (*p != 0) { + *p -= 0x10; + } + if (D_801BD841 != 0) { + D_801BD841 -= 0x10; + } + if (D_801BD842 != 0) { + D_801BD842 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801870F0[])(void); + +void func_80164EA4(void *a0) { + D_801870F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801BD88C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801BD88C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801BD880[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801BD880[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801BD880[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801BD880; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801BD880; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80187104[]; + extern u32 D_80187124, D_80187128, D_8018712C, D_80187130; + extern u32 D_80187124, D_80187128, D_8018712C, D_80187130; + extern u32 D_80187124, D_80187128, D_8018712C, D_80187130; + extern u32 D_80187124, D_80187128, D_8018712C, D_80187130; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80187104[0x00], p); + ApplyMatrixSV(mat, &D_80187104[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80187104[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80187104[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018712C; + *(u32 *)(prim + 0x24) = D_80187124; + *(u32 *)(prim + 0x28) = D_80187130; + *(u32 *)(prim + 0x2c) = D_80187128; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187134[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187134[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187134[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187134[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801871B0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801871B0[a1 & 0x7F]; +} + + + +extern s32 D_801871D0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801871D0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018724C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018724C[a1 & 0x7F]; +} + + + +extern u8 D_8018726C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018726C[a1 & 0x7F]; +} + + + +extern u8 D_8018728C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018728C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801872AC[])(void); + D_801872AC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187328[])(void); + +void func_80165AC8(void) { + D_80187328[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801873A4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801873A4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801BD020; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801BD020, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801873B0[])(void); + +void func_80166018(void *a0) { + D_801873B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801873B8[])(void); + +void func_801663FC(void *a0) { + D_801873B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80187480[])(void); + +void func_80166618(void *a0) { + D_80187480[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80187490[])(void); + +void func_80166654(void *a0) { + D_80187490[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801BD900[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801BD900[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BD900). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801BD900[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801BD900)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801BD900[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801BD900[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801873D4[]; + extern u8 D_801873C0[]; + extern u8 D_801873E8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801873D4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801873C0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801873E8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80167714); + + +extern void (*D_801874A0[])(void); + +void func_801678B4(void *a0) { + D_801874A0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801874AC[])(void); + +void func_80167A9C(void *a0) { + D_801874AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801875B8; + extern u8 D_801875CC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801875B8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801875CC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018740C[]; +extern u8 D_80187420[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018740C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187420; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801874C4[])(void); + +void func_80168744(void *a0) { + D_801874C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801874B4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801874B4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801874B4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801874CC[])(void); + +void func_801689D8(void *a0) { + D_801874CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801874D4[])(void); + +void func_80168AA8(void *a0) { + D_801874D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801874DC[])(void); + +void func_80168D58(void *a0) { + D_801874DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801874E4[])(void); + +void func_8016901C(void *a0) { + D_801874E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_035/nonmatchings/ov_SC02_035_jr_8015C32C", func_80169228); + + +extern void (*D_801874EC[])(void); + +void func_801693CC(void *a0) { + D_801874EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801874F4[])(void); + +void func_80169830(void *a0) { + D_801874F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801875A8[])(void); + +void func_80169B80(void *a0) { + D_801875A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801874FC[]; + extern u8 D_8018756C[]; + extern u8 D_8018759C[]; + extern u8 D_801BE900[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018759C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801874FC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801BE900; + RotMatrixYXZ(rot, D_801BE900); + func_80048D9C(D_801BE900, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018756C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801875B0[])(void); + +void func_80169F00(void *a0) { + D_801875B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80187560[]; +extern char D_80187520[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80187560, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187520); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801875E8[])(void); + +void func_8016A020(void *a0) { + D_801875E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801875B8; + extern u8 D_801875CC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801875B8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801875CC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801875F4[])(void); + +void func_8016A700(void *a0) { + D_801875F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018763C[])(void); + +void func_8016AB30(void *a0) { + D_8018763C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_039/ov_SC02_039_jr_8015AE2C.c b/src/ov_SC02_039/ov_SC02_039_jr_8015AE2C.c index 7fecef3b0..a7d4d00d1 100644 --- a/src/ov_SC02_039/ov_SC02_039_jr_8015AE2C.c +++ b/src/ov_SC02_039/ov_SC02_039_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181924[])(void); - -void func_8015C714(void *a0) { - D_80181924[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181798[])(void*); - extern int D_8018173C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181798)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181798)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018173C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181798[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181798[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181798[])(void*); - extern int D_8018173C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181798)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018173C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181798)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181934[])(void); - D_80181934[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181798[])(struct Ent_8015CD20 *); - extern u8 D_8018174C; - extern u8 D_8018193C; - extern u8 D_8018194C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181798[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018174C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018193C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018194C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181798[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018196C[])(void); - D_8018196C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018195C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018195C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181798[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801819C8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801819C8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180AAC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180AAC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801819D0[])(void); - D_801819D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801819DC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801819DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801819DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801819DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181798[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801819DC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018175C[]; - extern u8 D_8018176C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018175C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018176C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801819DC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801819DC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801819DC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80181A10[])(void); - D_80181A10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181798[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181A18[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181A30[])(void); - D_80181A30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181798[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181A18[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181A50[])(void); - D_80181A50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181798[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181798)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181A60; -extern u16 D_80181A62; -extern u16 D_80181A64; -extern s32 D_80181A68; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181A60 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80181A62 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181A64 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181A68, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181A70; - -void func_8015E588(void) { - func_8013C9C4(&D_80181A70); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181798[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181798)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181A84[])(void); - D_80181A84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181798[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181798[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181A8C[])(void); - D_80181A8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018177C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018177C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181798[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181A94[])(void); - D_80181A94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181798[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181798[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181A9C[])(void); - D_80181A9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181798[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181AA4; - extern s32 D_80181AB4; - extern s32 D_80181AC4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181798[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181AA4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181AB4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181798[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181AC4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80181AD4[])(void); - D_80181AD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181798[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181798[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181798[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181798[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80181AE0[])(void); - D_80181AE0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181798[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181798[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181798[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181798[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80181AF4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80181AF4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181798[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181798)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181798[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181798[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181B70[])(void); - D_80181B70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181798[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181798)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181B80[])(void); - D_80181B80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181798[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181798[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181798[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181798[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181798[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181798[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181798[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181B88[])(void); - D_80181B88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181798[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181798)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181798[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181798)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181B94[])(void); - D_80181B94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181798 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181798[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181798[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181798[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181BA4[])(void); - -void func_80160EA4(void *a0) { - D_80181BA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181798[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181798[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80181BD4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80181BD4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181C38; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181C38); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019FB38[]; - extern u8 D_80181C04[]; - extern u8 D_80181C24[]; - extern u8 D_8019FB44[]; - extern u8 D_8019FB6C[]; - extern u8 D_8019FB84[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019FB38[0] = p; - func_80024054(&D_80181C04, &D_8019FB44); - func_8001CE28(p, &D_8019FB44); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019FB38[1] = p; - func_80024054(&D_80181C24, &D_8019FB6C); - func_8001CE28(p, &D_8019FB6C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019FB38[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019FB84, 0x84); - func_8001CE68(p, &D_8019FB84); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019FB84, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019FB38[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019FB38; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181C38; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181C38; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181C38; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181C38; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019FB38[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019FB38; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181C5C[])(void); - -void func_80162330(void *a0) { - D_80181C5C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019FB90[i] via `extern int D_8019FB90[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181C68[]; - extern s32 D_80181C80; - extern u8 D_8019FB9C[]; - extern u8 D_8019FBC4[]; - extern u8 D_8019FBE0[]; - extern int D_8019FB90[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019FB90[0] = (s32)item; - func_80024054(D_80181C68, D_8019FB9C); - func_8001CE28(item, D_8019FB9C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019FB90[1] = (s32)item; - func_80024054(((u8 *)&D_80181C80), D_8019FBC4); - func_8001CE28(item, D_8019FBC4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019FB90[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019FBE0, 0x84); - func_8001CE68(item, D_8019FBE0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019FBE0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019FB90[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019FB90; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181CA4[])(void); - -void func_80162834(void *a0) { - D_80181CA4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181C94; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181C94, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019F3FC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019F3FC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019F3FC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019F3FC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181CAC[])(void); - -void func_80163A58(void *a0) { - D_80181CAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019F404; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019F404; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80181D00[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80181D00[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181CC8; -extern s16 D_80181CFC; -extern s16 D_80181CFA; -extern s16 D_80181CF8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181CC8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181CFC = 0x80; - D_80181CFA = 0x80; - D_80181CF8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181CFC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181CFC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181CFC - 8; - D_80181CFC = nv; - D_80181CFA = nv; - D_80181CF8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181D0C[])(void); - -void func_80164BA0(void *a0) { - D_80181D0C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019FBF0; -extern u8 D_8019FBF1; -extern u8 D_8019FBF2; -extern u8 D_8019FBF3; -extern u8 D_8019FBF4; -extern u8 D_8019FBF5; -extern u8 D_8019FBF6; -extern u8 D_8019FBF7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019FBF0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019FBF1 = 0xf0; - *(u8 *)base = 0xf0; - D_8019FBF2 = 0xc0; - D_8019FBF6 = 0; - D_8019FBF5 = 0; - D_8019FBF4 = 0; - D_8019FBF7 = 0; - D_8019FBF3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019FBF0; -extern u8 D_8019FBF1; -extern u8 D_8019FBF2; - -s32 func_80164E40(void) { - u8 *p = &D_8019FBF0; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019FBF1 != 0) { - D_8019FBF1 -= 0x10; - } - if (D_8019FBF2 != 0) { - D_8019FBF2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181D1C[])(void); - -void func_80164EA4(void *a0) { - D_80181D1C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019FC3C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019FC3C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019FC30[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019FC30[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019FC30[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019FC30; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019FC30; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181D30[]; - extern u32 D_80181D50, D_80181D54, D_80181D58, D_80181D5C; - extern u32 D_80181D50, D_80181D54, D_80181D58, D_80181D5C; - extern u32 D_80181D50, D_80181D54, D_80181D58, D_80181D5C; - extern u32 D_80181D50, D_80181D54, D_80181D58, D_80181D5C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181D30[0x00], p); - ApplyMatrixSV(mat, &D_80181D30[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181D30[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181D30[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181D58; - *(u32 *)(prim + 0x24) = D_80181D50; - *(u32 *)(prim + 0x28) = D_80181D5C; - *(u32 *)(prim + 0x2c) = D_80181D54; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181D60[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181D60[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181D60[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181D60[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80181DDC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80181DDC[a1 & 0x7F]; -} - - - -extern s32 D_80181DFC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181DFC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181E78[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181E78[a1 & 0x7F]; -} - - - -extern u8 D_80181E98[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80181E98[a1 & 0x7F]; -} - - - -extern u8 D_80181EB8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181EB8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80181ED8[])(void); - D_80181ED8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80181F54[])(void); - -void func_80165AC8(void) { - D_80181F54[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181FD0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181FD0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019F40C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019F40C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80181FDC[])(void); - -void func_80166018(void *a0) { - D_80181FDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181FE4[])(void); - -void func_801663FC(void *a0) { - D_80181FE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801820AC[])(void); - -void func_80166618(void *a0) { - D_801820AC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801820BC[])(void); - -void func_80166654(void *a0) { - D_801820BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019FCB0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019FCB0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019FCB0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019FCB0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019FCB0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019FCB0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019FCB0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80182000[]; - extern u8 D_80181FEC[]; - extern u8 D_80182014[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80182000; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80181FEC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182014; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80167714); - - -extern void (*D_801820CC[])(void); - -void func_801678B4(void *a0) { - D_801820CC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801820D8[])(void); - -void func_80167A9C(void *a0) { - D_801820D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801821E4; - extern u8 D_801821F8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801821E4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801821F8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80182038[]; -extern u8 D_8018204C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80182038; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018204C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801820F0[])(void); - -void func_80168744(void *a0) { - D_801820F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801820E0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801820E0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801820E0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801820F8[])(void); - -void func_801689D8(void *a0) { - D_801820F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80182100[])(void); - -void func_80168AA8(void *a0) { - D_80182100[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80182108[])(void); - -void func_80168D58(void *a0) { - D_80182108[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80182110[])(void); - -void func_8016901C(void *a0) { - D_80182110[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015AE2C", func_80169228); - - -extern void (*D_80182118[])(void); - -void func_801693CC(void *a0) { - D_80182118[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80182120[])(void); - -void func_80169830(void *a0) { - D_80182120[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801821D4[])(void); - -void func_80169B80(void *a0) { - D_801821D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80182128[]; - extern u8 D_80182198[]; - extern u8 D_801821C8[]; - extern u8 D_801A0CB8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801821C8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80182128[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A0CB8; - RotMatrixYXZ(rot, D_801A0CB8); - func_80048D9C(D_801A0CB8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182198); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801821DC[])(void); - -void func_80169F00(void *a0) { - D_801821DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018218C[]; -extern char D_8018214C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018218C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018214C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80182214[])(void); - -void func_8016A020(void *a0) { - D_80182214[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801821E4; - extern u8 D_801821F8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801821E4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801821F8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80182220[])(void); - -void func_8016A700(void *a0) { - D_80182220[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80182268[])(void); - -void func_8016AB30(void *a0) { - D_80182268[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c b/src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c new file mode 100644 index 000000000..41b0072d3 --- /dev/null +++ b/src/ov_SC02_039/ov_SC02_039_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80181634; +extern u8 D_801815A4; +extern u8 D_80181580; +extern u8 D_8018155C; +extern u8 D_80181610; +extern u8 D_801815EC; +extern u8 D_801815C8; +extern u8 D_80181538; +extern void func_80145934(void); +extern u8 D_801816C4; +extern u8 D_801816A0; +extern u8 D_8018167C; +extern u8 D_80181658; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180ABC[]; +extern unsigned char D_80180AEC[]; +extern unsigned char D_80180B3C[]; +extern unsigned char D_80180B6C[]; +extern unsigned char D_80180B9C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80180BEC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80180CB4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180D3C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180D44; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019FAE0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019FAE4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180D74; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180E1C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180E40[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180E30; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180E54[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180E60[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180E70[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80180E88[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180E78; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80180E9C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80180EB8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80180EA8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80180ECC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80180EE0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80180EF4; +extern void (*D_80180F1C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80180EFC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80180F68[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80180F6C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801813D0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801813E0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019FB18; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80181408[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801813E8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801813F8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80181448[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80181450[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018141C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018145C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018142C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019FB20; +extern s32 D_8019FB2C; +extern s32 D_8019FB30; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80181498[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018146C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019FB28; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801816E8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80181508[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018178C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801818E0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801816FC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801818E8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018170C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018172C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801818F0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80181918[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181798[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181798[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181798[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181798[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181798[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181798[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181798[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181798[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181924[])(void); + +void func_8015C714(void *a0) { + D_80181924[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181798[])(void*); + extern int D_8018173C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181798)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181798)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018173C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181798[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181798[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181798[])(void*); + extern int D_8018173C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181798)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018173C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181798)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181934[])(void); + D_80181934[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181798[])(struct Ent_8015CD20 *); + extern u8 D_8018174C; + extern u8 D_8018193C; + extern u8 D_8018194C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181798[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018174C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018193C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018194C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181798[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018196C[])(void); + D_8018196C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018195C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018195C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181798[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801819C8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801819C8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180AAC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180AAC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801819D0[])(void); + D_801819D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801819DC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801819DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801819DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801819DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181798[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801819DC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018175C[]; + extern u8 D_8018176C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018175C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018176C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801819DC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801819DC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801819DC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80181A10[])(void); + D_80181A10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181798[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181A18[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181A30[])(void); + D_80181A30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181798[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181A18[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181A18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181A50[])(void); + D_80181A50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181798[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181798)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181A60; +extern u16 D_80181A62; +extern u16 D_80181A64; +extern s32 D_80181A68; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181A60 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80181A62 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181A64 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181A68, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181A70; + +void func_8015E588(void) { + func_8013C9C4(&D_80181A70); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181798[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181798)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181A84[])(void); + D_80181A84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181798[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181798[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181A8C[])(void); + D_80181A8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018177C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018177C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181798[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181A94[])(void); + D_80181A94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181798[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181798[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181A9C[])(void); + D_80181A9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181798[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181AA4; + extern s32 D_80181AB4; + extern s32 D_80181AC4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181798[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181AA4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181AB4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181798[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181AC4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80181AD4[])(void); + D_80181AD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181798[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181798[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181798[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181798[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80181AE0[])(void); + D_80181AE0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181798[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181798[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181798[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181798[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80181AF4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80181AF4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181798[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181798)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181798[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181798[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181B70[])(void); + D_80181B70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181798[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181798)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181B80[])(void); + D_80181B80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181798[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181798[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181798[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181798[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181798[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181798[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181798[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181B88[])(void); + D_80181B88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181798[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181798)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181798[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181798)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181B94[])(void); + D_80181B94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181798 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181798[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181798[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181798[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181BA4[])(void); + +void func_80160EA4(void *a0) { + D_80181BA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181798[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181798[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80181BD4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80181BD4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181C38; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181C38); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019FB38[]; + extern u8 D_80181C04[]; + extern u8 D_80181C24[]; + extern u8 D_8019FB44[]; + extern u8 D_8019FB6C[]; + extern u8 D_8019FB84[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019FB38[0] = p; + func_80024054(&D_80181C04, &D_8019FB44); + func_8001CE28(p, &D_8019FB44); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019FB38[1] = p; + func_80024054(&D_80181C24, &D_8019FB6C); + func_8001CE28(p, &D_8019FB6C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019FB38[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019FB84, 0x84); + func_8001CE68(p, &D_8019FB84); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019FB84, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019FB38[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019FB38; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181C38; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181C38; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181C38; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181C38; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019FB38[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019FB38; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181C5C[])(void); + +void func_80162330(void *a0) { + D_80181C5C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019FB90[i] via `extern int D_8019FB90[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181C68[]; + extern s32 D_80181C80; + extern u8 D_8019FB9C[]; + extern u8 D_8019FBC4[]; + extern u8 D_8019FBE0[]; + extern int D_8019FB90[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019FB90[0] = (s32)item; + func_80024054(D_80181C68, D_8019FB9C); + func_8001CE28(item, D_8019FB9C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019FB90[1] = (s32)item; + func_80024054(((u8 *)&D_80181C80), D_8019FBC4); + func_8001CE28(item, D_8019FBC4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019FB90[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019FBE0, 0x84); + func_8001CE68(item, D_8019FBE0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019FBE0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019FB90[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019FB90; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_801627E8); + + +extern void (*D_80181CA4[])(void); + +void func_80162834(void *a0) { + D_80181CA4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181C94; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181C94, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019F3FC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019F3FC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019F3FC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019F3FC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181CAC[])(void); + +void func_80163A58(void *a0) { + D_80181CAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019F404; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019F404; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80181D00[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80181D00[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181CC8; +extern s16 D_80181CFC; +extern s16 D_80181CFA; +extern s16 D_80181CF8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181CC8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181CFC = 0x80; + D_80181CFA = 0x80; + D_80181CF8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181CFC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181CFC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181CFC - 8; + D_80181CFC = nv; + D_80181CFA = nv; + D_80181CF8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181D0C[])(void); + +void func_80164BA0(void *a0) { + D_80181D0C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019FBF0; +extern u8 D_8019FBF1; +extern u8 D_8019FBF2; +extern u8 D_8019FBF3; +extern u8 D_8019FBF4; +extern u8 D_8019FBF5; +extern u8 D_8019FBF6; +extern u8 D_8019FBF7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019FBF0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019FBF1 = 0xf0; + *(u8 *)base = 0xf0; + D_8019FBF2 = 0xc0; + D_8019FBF6 = 0; + D_8019FBF5 = 0; + D_8019FBF4 = 0; + D_8019FBF7 = 0; + D_8019FBF3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019FBF0; +extern u8 D_8019FBF1; +extern u8 D_8019FBF2; + +s32 func_80164E40(void) { + u8 *p = &D_8019FBF0; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019FBF1 != 0) { + D_8019FBF1 -= 0x10; + } + if (D_8019FBF2 != 0) { + D_8019FBF2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181D1C[])(void); + +void func_80164EA4(void *a0) { + D_80181D1C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019FC3C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019FC3C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019FC30[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019FC30[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019FC30[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019FC30; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019FC30; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181D30[]; + extern u32 D_80181D50, D_80181D54, D_80181D58, D_80181D5C; + extern u32 D_80181D50, D_80181D54, D_80181D58, D_80181D5C; + extern u32 D_80181D50, D_80181D54, D_80181D58, D_80181D5C; + extern u32 D_80181D50, D_80181D54, D_80181D58, D_80181D5C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181D30[0x00], p); + ApplyMatrixSV(mat, &D_80181D30[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181D30[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181D30[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181D58; + *(u32 *)(prim + 0x24) = D_80181D50; + *(u32 *)(prim + 0x28) = D_80181D5C; + *(u32 *)(prim + 0x2c) = D_80181D54; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181D60[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181D60[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181D60[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181D60[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80181DDC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80181DDC[a1 & 0x7F]; +} + + + +extern s32 D_80181DFC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181DFC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181E78[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181E78[a1 & 0x7F]; +} + + + +extern u8 D_80181E98[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80181E98[a1 & 0x7F]; +} + + + +extern u8 D_80181EB8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181EB8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80181ED8[])(void); + D_80181ED8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80181F54[])(void); + +void func_80165AC8(void) { + D_80181F54[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181FD0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181FD0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019F40C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019F40C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80181FDC[])(void); + +void func_80166018(void *a0) { + D_80181FDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181FE4[])(void); + +void func_801663FC(void *a0) { + D_80181FE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801820AC[])(void); + +void func_80166618(void *a0) { + D_801820AC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801820BC[])(void); + +void func_80166654(void *a0) { + D_801820BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019FCB0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019FCB0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019FCB0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019FCB0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019FCB0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019FCB0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019FCB0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80182000[]; + extern u8 D_80181FEC[]; + extern u8 D_80182014[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80182000; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80181FEC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182014; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80167714); + + +extern void (*D_801820CC[])(void); + +void func_801678B4(void *a0) { + D_801820CC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801820D8[])(void); + +void func_80167A9C(void *a0) { + D_801820D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801821E4; + extern u8 D_801821F8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801821E4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801821F8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80182038[]; +extern u8 D_8018204C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80182038; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018204C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801820F0[])(void); + +void func_80168744(void *a0) { + D_801820F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801820E0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801820E0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801820E0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801820F8[])(void); + +void func_801689D8(void *a0) { + D_801820F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80182100[])(void); + +void func_80168AA8(void *a0) { + D_80182100[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80182108[])(void); + +void func_80168D58(void *a0) { + D_80182108[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80182110[])(void); + +void func_8016901C(void *a0) { + D_80182110[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_039/nonmatchings/ov_SC02_039_jr_8015C32C", func_80169228); + + +extern void (*D_80182118[])(void); + +void func_801693CC(void *a0) { + D_80182118[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80182120[])(void); + +void func_80169830(void *a0) { + D_80182120[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801821D4[])(void); + +void func_80169B80(void *a0) { + D_801821D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80182128[]; + extern u8 D_80182198[]; + extern u8 D_801821C8[]; + extern u8 D_801A0CB8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801821C8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80182128[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A0CB8; + RotMatrixYXZ(rot, D_801A0CB8); + func_80048D9C(D_801A0CB8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182198); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801821DC[])(void); + +void func_80169F00(void *a0) { + D_801821DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018218C[]; +extern char D_8018214C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018218C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018214C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80182214[])(void); + +void func_8016A020(void *a0) { + D_80182214[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801821E4; + extern u8 D_801821F8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801821E4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801821F8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80182220[])(void); + +void func_8016A700(void *a0) { + D_80182220[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80182268[])(void); + +void func_8016AB30(void *a0) { + D_80182268[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC02_041/ov_SC02_041_jr_8015AE2C.c b/src/ov_SC02_041/ov_SC02_041_jr_8015AE2C.c index 4bb7aaf59..2c1d19d2d 100644 --- a/src/ov_SC02_041/ov_SC02_041_jr_8015AE2C.c +++ b/src/ov_SC02_041/ov_SC02_041_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801875F4[])(void); - -void func_8015C714(void *a0) { - D_801875F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80187468[])(void*); - extern int D_8018740C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80187468)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80187468)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018740C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80187468[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80187468[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80187468[])(void*); - extern int D_8018740C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80187468)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018740C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80187468)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80187604[])(void); - D_80187604[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80187468[])(struct Ent_8015CD20 *); - extern u8 D_8018741C; - extern u8 D_8018760C; - extern u8 D_8018761C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80187468[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018741C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018760C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018761C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80187468[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018763C[])(void); - D_8018763C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018762C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018762C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80187468[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80187698; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80187698, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018677C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018677C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801876A0[])(void); - D_801876A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801876AC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801876AC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801876AC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801876AC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80187468[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801876AC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018742C[]; - extern u8 D_8018743C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018742C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018743C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801876AC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801876AC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801876AC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801876E0[])(void); - D_801876E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187468[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801876E8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80187700[])(void); - D_80187700[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187468[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801876E8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80187720[])(void); - D_80187720[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80187468[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187468)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80187730; -extern u16 D_80187732; -extern u16 D_80187734; -extern s32 D_80187738; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80187730 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80187732 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187734 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187738, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80187740; - -void func_8015E588(void) { - func_8013C9C4(&D_80187740); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80187468[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187468)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80187754[])(void); - D_80187754[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80187468[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80187468[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018775C[])(void); - D_8018775C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018744C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018744C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80187468[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187764[])(void); - D_80187764[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80187468[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80187468[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018776C[])(void); - D_8018776C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80187468[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80187774; - extern s32 D_80187784; - extern s32 D_80187794; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80187468[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187774); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187784); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80187468[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187794); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801877A4[])(void); - D_801877A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80187468[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80187468[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80187468[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187468[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801877B0[])(void); - D_801877B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80187468[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187468[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80187468[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187468[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801877C4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801877C4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80187468[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80187468)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80187468[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187468[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80187840[])(void); - D_80187840[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80187468[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80187468)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80187850[])(void); - D_80187850[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80187468[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80187468[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80187468[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80187468[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80187468[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80187468[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80187468[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80187858[])(void); - D_80187858[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80187468[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80187468)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80187468[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80187468)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187864[])(void); - D_80187864[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187468 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80187468[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80187468[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80187468[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80187874[])(void); - -void func_80160EA4(void *a0) { - D_80187874[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80187468[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80187468[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801878A4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801878A4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80187908; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80187908); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B7EB0[]; - extern u8 D_801878D4[]; - extern u8 D_801878F4[]; - extern u8 D_801B7EBC[]; - extern u8 D_801B7EE4[]; - extern u8 D_801B7EFC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B7EB0[0] = p; - func_80024054(&D_801878D4, &D_801B7EBC); - func_8001CE28(p, &D_801B7EBC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B7EB0[1] = p; - func_80024054(&D_801878F4, &D_801B7EE4); - func_8001CE28(p, &D_801B7EE4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B7EB0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B7EFC, 0x84); - func_8001CE68(p, &D_801B7EFC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B7EFC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B7EB0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B7EB0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80187908; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80187908; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80187908; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80187908; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B7EB0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B7EB0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018792C[])(void); - -void func_80162330(void *a0) { - D_8018792C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B7F08[i] via `extern int D_801B7F08[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80187938[]; - extern s32 D_80187950; - extern u8 D_801B7F14[]; - extern u8 D_801B7F3C[]; - extern u8 D_801B7F58[]; - extern int D_801B7F08[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B7F08[0] = (s32)item; - func_80024054(D_80187938, D_801B7F14); - func_8001CE28(item, D_801B7F14); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B7F08[1] = (s32)item; - func_80024054(((u8 *)&D_80187950), D_801B7F3C); - func_8001CE28(item, D_801B7F3C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B7F08[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B7F58, 0x84); - func_8001CE68(item, D_801B7F58); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B7F58, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B7F08[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B7F08; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187974[])(void); - -void func_80162834(void *a0) { - D_80187974[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187964; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187964, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B7768[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B7768, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B7768[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B7768, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018797C[])(void); - -void func_80163A58(void *a0) { - D_8018797C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B7770; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B7770; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801879D0[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801879D0[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80187998; -extern s16 D_801879CC; -extern s16 D_801879CA; -extern s16 D_801879C8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80187998; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801879CC = 0x80; - D_801879CA = 0x80; - D_801879C8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801879CC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801879CC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801879CC - 8; - D_801879CC = nv; - D_801879CA = nv; - D_801879C8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801879DC[])(void); - -void func_80164BA0(void *a0) { - D_801879DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B7F68; -extern u8 D_801B7F69; -extern u8 D_801B7F6A; -extern u8 D_801B7F6B; -extern u8 D_801B7F6C; -extern u8 D_801B7F6D; -extern u8 D_801B7F6E; -extern u8 D_801B7F6F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B7F68; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B7F69 = 0xf0; - *(u8 *)base = 0xf0; - D_801B7F6A = 0xc0; - D_801B7F6E = 0; - D_801B7F6D = 0; - D_801B7F6C = 0; - D_801B7F6F = 0; - D_801B7F6B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B7F68; -extern u8 D_801B7F69; -extern u8 D_801B7F6A; - -s32 func_80164E40(void) { - u8 *p = &D_801B7F68; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B7F69 != 0) { - D_801B7F69 -= 0x10; - } - if (D_801B7F6A != 0) { - D_801B7F6A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801879EC[])(void); - -void func_80164EA4(void *a0) { - D_801879EC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B7FB4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B7FB4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B7FA8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B7FA8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B7FA8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B7FA8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B7FA8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80187A00[]; - extern u32 D_80187A20, D_80187A24, D_80187A28, D_80187A2C; - extern u32 D_80187A20, D_80187A24, D_80187A28, D_80187A2C; - extern u32 D_80187A20, D_80187A24, D_80187A28, D_80187A2C; - extern u32 D_80187A20, D_80187A24, D_80187A28, D_80187A2C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80187A00[0x00], p); - ApplyMatrixSV(mat, &D_80187A00[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80187A00[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80187A00[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80187A28; - *(u32 *)(prim + 0x24) = D_80187A20; - *(u32 *)(prim + 0x28) = D_80187A2C; - *(u32 *)(prim + 0x2c) = D_80187A24; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187A30[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187A30[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187A30[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187A30[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80187AAC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80187AAC[a1 & 0x7F]; -} - - - -extern s32 D_80187ACC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80187ACC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80187B48[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80187B48[a1 & 0x7F]; -} - - - -extern u8 D_80187B68[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80187B68[a1 & 0x7F]; -} - - - -extern u8 D_80187B88[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80187B88[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80187BA8[])(void); - D_80187BA8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187C24[])(void); - -void func_80165AC8(void) { - D_80187C24[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80187CA0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80187CA0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B7778; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B7778, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80187CAC[])(void); - -void func_80166018(void *a0) { - D_80187CAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80187CB4[])(void); - -void func_801663FC(void *a0) { - D_80187CB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80187D7C[])(void); - -void func_80166618(void *a0) { - D_80187D7C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80187D8C[])(void); - -void func_80166654(void *a0) { - D_80187D8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B8028[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B8028[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B8028). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B8028[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B8028)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B8028[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B8028[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80187CD0[]; - extern u8 D_80187CBC[]; - extern u8 D_80187CE4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80187CD0; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80187CBC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187CE4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80167714); - - -extern void (*D_80187D9C[])(void); - -void func_801678B4(void *a0) { - D_80187D9C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80187DA8[])(void); - -void func_80167A9C(void *a0) { - D_80187DA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80187EB4; - extern u8 D_80187EC8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80187EB4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187EC8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80187D08[]; -extern u8 D_80187D1C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80187D08; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187D1C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80187DC0[])(void); - -void func_80168744(void *a0) { - D_80187DC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80187DB0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80187DB0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80187DB0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80187DC8[])(void); - -void func_801689D8(void *a0) { - D_80187DC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80187DD0[])(void); - -void func_80168AA8(void *a0) { - D_80187DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80187DD8[])(void); - -void func_80168D58(void *a0) { - D_80187DD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80187DE0[])(void); - -void func_8016901C(void *a0) { - D_80187DE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015AE2C", func_80169228); - - -extern void (*D_80187DE8[])(void); - -void func_801693CC(void *a0) { - D_80187DE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80187DF0[])(void); - -void func_80169830(void *a0) { - D_80187DF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187EA4[])(void); - -void func_80169B80(void *a0) { - D_80187EA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80187DF8[]; - extern u8 D_80187E68[]; - extern u8 D_80187E98[]; - extern u8 D_801B9590[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80187E98, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80187DF8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B9590; - RotMatrixYXZ(rot, D_801B9590); - func_80048D9C(D_801B9590, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80187E68); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80187EAC[])(void); - -void func_80169F00(void *a0) { - D_80187EAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80187E5C[]; -extern char D_80187E1C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80187E5C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187E1C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187EE4[])(void); - -void func_8016A020(void *a0) { - D_80187EE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80187EB4; - extern u8 D_80187EC8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80187EB4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187EC8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80187EF0[])(void); - -void func_8016A700(void *a0) { - D_80187EF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80187F38[])(void); - -void func_8016AB30(void *a0) { - D_80187F38[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c b/src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c new file mode 100644 index 000000000..d18933269 --- /dev/null +++ b/src/ov_SC02_041/ov_SC02_041_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80187304; +extern u8 D_80187274; +extern u8 D_80187250; +extern u8 D_8018722C; +extern u8 D_801872E0; +extern u8 D_801872BC; +extern u8 D_80187298; +extern u8 D_80187208; +extern void func_80145934(void); +extern u8 D_80187394; +extern u8 D_80187370; +extern u8 D_8018734C; +extern u8 D_80187328; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018678C[]; +extern unsigned char D_801867BC[]; +extern unsigned char D_8018680C[]; +extern unsigned char D_8018683C[]; +extern unsigned char D_8018686C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801868BC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80186984[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80186A0C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186A14; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B7E58; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B7E5C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186A44; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80186AEC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80186B10[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80186B00; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186B24[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80186B30[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80186B40[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80186B58[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80186B48; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80186B6C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80186B88[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80186B78; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80186B9C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80186BB0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80186BC4; +extern void (*D_80186BEC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80186BCC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80186C38[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80186C3C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801870A0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801870B0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B7E90; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801870D8[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801870B8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801870C8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80187118[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80187120[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801870EC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018712C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801870FC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B7E98; +extern s32 D_801B7EA4; +extern s32 D_801B7EA8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80187168[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018713C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B7EA0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801873B8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801871D8[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018745C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801875B0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801873CC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801875B8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801873DC; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801873FC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801875C0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801875E8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80187468[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80187468[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80187468[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80187468[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80187468[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80187468[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80187468[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80187468[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801875F4[])(void); + +void func_8015C714(void *a0) { + D_801875F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80187468[])(void*); + extern int D_8018740C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80187468)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80187468)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018740C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80187468[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80187468[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80187468[])(void*); + extern int D_8018740C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80187468)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018740C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80187468)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80187604[])(void); + D_80187604[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80187468[])(struct Ent_8015CD20 *); + extern u8 D_8018741C; + extern u8 D_8018760C; + extern u8 D_8018761C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80187468[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018741C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018760C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018761C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80187468[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018763C[])(void); + D_8018763C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018762C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018762C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80187468[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80187698; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80187698, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018677C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018677C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801876A0[])(void); + D_801876A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801876AC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801876AC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801876AC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801876AC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80187468[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801876AC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018742C[]; + extern u8 D_8018743C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018742C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018743C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801876AC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801876AC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801876AC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801876E0[])(void); + D_801876E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187468[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801876E8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80187700[])(void); + D_80187700[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187468[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801876E8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801876E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80187720[])(void); + D_80187720[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80187468[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187468)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80187730; +extern u16 D_80187732; +extern u16 D_80187734; +extern s32 D_80187738; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80187730 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80187732 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187734 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187738, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80187740; + +void func_8015E588(void) { + func_8013C9C4(&D_80187740); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80187468[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187468)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80187754[])(void); + D_80187754[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80187468[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80187468[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018775C[])(void); + D_8018775C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018744C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018744C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80187468[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187764[])(void); + D_80187764[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80187468[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80187468[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018776C[])(void); + D_8018776C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80187468[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80187774; + extern s32 D_80187784; + extern s32 D_80187794; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80187468[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187774); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187784); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80187468[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187794); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801877A4[])(void); + D_801877A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80187468[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80187468[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80187468[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187468[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801877B0[])(void); + D_801877B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80187468[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187468[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80187468[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187468[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801877C4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801877C4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80187468[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80187468)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80187468[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187468[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80187840[])(void); + D_80187840[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80187468[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80187468)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80187850[])(void); + D_80187850[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80187468[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80187468[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80187468[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80187468[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80187468[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80187468[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80187468[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80187858[])(void); + D_80187858[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80187468[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80187468)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80187468[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80187468)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187864[])(void); + D_80187864[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187468 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80187468[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80187468[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80187468[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80187874[])(void); + +void func_80160EA4(void *a0) { + D_80187874[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80187468[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80187468[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801878A4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801878A4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80187908; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80187908); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B7EB0[]; + extern u8 D_801878D4[]; + extern u8 D_801878F4[]; + extern u8 D_801B7EBC[]; + extern u8 D_801B7EE4[]; + extern u8 D_801B7EFC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B7EB0[0] = p; + func_80024054(&D_801878D4, &D_801B7EBC); + func_8001CE28(p, &D_801B7EBC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B7EB0[1] = p; + func_80024054(&D_801878F4, &D_801B7EE4); + func_8001CE28(p, &D_801B7EE4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B7EB0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B7EFC, 0x84); + func_8001CE68(p, &D_801B7EFC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B7EFC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B7EB0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B7EB0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80187908; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80187908; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80187908; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80187908; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B7EB0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B7EB0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018792C[])(void); + +void func_80162330(void *a0) { + D_8018792C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B7F08[i] via `extern int D_801B7F08[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80187938[]; + extern s32 D_80187950; + extern u8 D_801B7F14[]; + extern u8 D_801B7F3C[]; + extern u8 D_801B7F58[]; + extern int D_801B7F08[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B7F08[0] = (s32)item; + func_80024054(D_80187938, D_801B7F14); + func_8001CE28(item, D_801B7F14); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B7F08[1] = (s32)item; + func_80024054(((u8 *)&D_80187950), D_801B7F3C); + func_8001CE28(item, D_801B7F3C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B7F08[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B7F58, 0x84); + func_8001CE68(item, D_801B7F58); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B7F58, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B7F08[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B7F08; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_801627E8); + + +extern void (*D_80187974[])(void); + +void func_80162834(void *a0) { + D_80187974[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187964; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187964, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B7768[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B7768, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B7768[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B7768, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018797C[])(void); + +void func_80163A58(void *a0) { + D_8018797C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B7770; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B7770; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801879D0[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801879D0[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80187998; +extern s16 D_801879CC; +extern s16 D_801879CA; +extern s16 D_801879C8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80187998; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801879CC = 0x80; + D_801879CA = 0x80; + D_801879C8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801879CC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801879CC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801879CC - 8; + D_801879CC = nv; + D_801879CA = nv; + D_801879C8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801879DC[])(void); + +void func_80164BA0(void *a0) { + D_801879DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B7F68; +extern u8 D_801B7F69; +extern u8 D_801B7F6A; +extern u8 D_801B7F6B; +extern u8 D_801B7F6C; +extern u8 D_801B7F6D; +extern u8 D_801B7F6E; +extern u8 D_801B7F6F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B7F68; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B7F69 = 0xf0; + *(u8 *)base = 0xf0; + D_801B7F6A = 0xc0; + D_801B7F6E = 0; + D_801B7F6D = 0; + D_801B7F6C = 0; + D_801B7F6F = 0; + D_801B7F6B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B7F68; +extern u8 D_801B7F69; +extern u8 D_801B7F6A; + +s32 func_80164E40(void) { + u8 *p = &D_801B7F68; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B7F69 != 0) { + D_801B7F69 -= 0x10; + } + if (D_801B7F6A != 0) { + D_801B7F6A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801879EC[])(void); + +void func_80164EA4(void *a0) { + D_801879EC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B7FB4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B7FB4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B7FA8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B7FA8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B7FA8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B7FA8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B7FA8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80187A00[]; + extern u32 D_80187A20, D_80187A24, D_80187A28, D_80187A2C; + extern u32 D_80187A20, D_80187A24, D_80187A28, D_80187A2C; + extern u32 D_80187A20, D_80187A24, D_80187A28, D_80187A2C; + extern u32 D_80187A20, D_80187A24, D_80187A28, D_80187A2C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80187A00[0x00], p); + ApplyMatrixSV(mat, &D_80187A00[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80187A00[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80187A00[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80187A28; + *(u32 *)(prim + 0x24) = D_80187A20; + *(u32 *)(prim + 0x28) = D_80187A2C; + *(u32 *)(prim + 0x2c) = D_80187A24; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187A30[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187A30[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187A30[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187A30[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80187AAC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80187AAC[a1 & 0x7F]; +} + + + +extern s32 D_80187ACC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80187ACC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80187B48[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80187B48[a1 & 0x7F]; +} + + + +extern u8 D_80187B68[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80187B68[a1 & 0x7F]; +} + + + +extern u8 D_80187B88[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80187B88[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80187BA8[])(void); + D_80187BA8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187C24[])(void); + +void func_80165AC8(void) { + D_80187C24[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80187CA0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80187CA0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B7778; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B7778, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80187CAC[])(void); + +void func_80166018(void *a0) { + D_80187CAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80187CB4[])(void); + +void func_801663FC(void *a0) { + D_80187CB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80187D7C[])(void); + +void func_80166618(void *a0) { + D_80187D7C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80187D8C[])(void); + +void func_80166654(void *a0) { + D_80187D8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B8028[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B8028[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B8028). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B8028[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B8028)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B8028[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B8028[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80187CD0[]; + extern u8 D_80187CBC[]; + extern u8 D_80187CE4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80187CD0; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80187CBC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187CE4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80167714); + + +extern void (*D_80187D9C[])(void); + +void func_801678B4(void *a0) { + D_80187D9C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80187DA8[])(void); + +void func_80167A9C(void *a0) { + D_80187DA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80187EB4; + extern u8 D_80187EC8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80187EB4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187EC8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80187D08[]; +extern u8 D_80187D1C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80187D08; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187D1C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80187DC0[])(void); + +void func_80168744(void *a0) { + D_80187DC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80187DB0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80187DB0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80187DB0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80187DC8[])(void); + +void func_801689D8(void *a0) { + D_80187DC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80187DD0[])(void); + +void func_80168AA8(void *a0) { + D_80187DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80187DD8[])(void); + +void func_80168D58(void *a0) { + D_80187DD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80187DE0[])(void); + +void func_8016901C(void *a0) { + D_80187DE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC02_041/nonmatchings/ov_SC02_041_jr_8015C32C", func_80169228); + + +extern void (*D_80187DE8[])(void); + +void func_801693CC(void *a0) { + D_80187DE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80187DF0[])(void); + +void func_80169830(void *a0) { + D_80187DF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187EA4[])(void); + +void func_80169B80(void *a0) { + D_80187EA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80187DF8[]; + extern u8 D_80187E68[]; + extern u8 D_80187E98[]; + extern u8 D_801B9590[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80187E98, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80187DF8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B9590; + RotMatrixYXZ(rot, D_801B9590); + func_80048D9C(D_801B9590, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80187E68); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80187EAC[])(void); + +void func_80169F00(void *a0) { + D_80187EAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80187E5C[]; +extern char D_80187E1C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80187E5C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187E1C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187EE4[])(void); + +void func_8016A020(void *a0) { + D_80187EE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80187EB4; + extern u8 D_80187EC8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80187EB4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187EC8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80187EF0[])(void); + +void func_8016A700(void *a0) { + D_80187EF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80187F38[])(void); + +void func_8016AB30(void *a0) { + D_80187F38[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_001/ov_SC03_001_jr_8015AE2C.c b/src/ov_SC03_001/ov_SC03_001_jr_8015AE2C.c index e8f27471a..6c3ddb535 100644 --- a/src/ov_SC03_001/ov_SC03_001_jr_8015AE2C.c +++ b/src/ov_SC03_001/ov_SC03_001_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018FD34[])(void); - -void func_8015C714(void *a0) { - D_8018FD34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018FBA8[])(void*); - extern int D_8018FB4C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018FB4C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018FBA8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018FBA8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018FBA8[])(void*); - extern int D_8018FB4C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018FB4C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018FD44[])(void); - D_8018FD44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018FBA8[])(struct Ent_8015CD20 *); - extern u8 D_8018FB5C; - extern u8 D_8018FD4C; - extern u8 D_8018FD5C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018FBA8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FB5C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FD4C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FD5C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018FBA8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018FD7C[])(void); - D_8018FD7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018FD6C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018FD6C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018FBA8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018FDD8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018FDD8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018EEBC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018EEBC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018FDE0[])(void); - D_8018FDE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018FDEC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018FDEC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018FDEC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018FDEC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018FBA8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018FDEC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018FB6C[]; - extern u8 D_8018FB7C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018FB6C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018FB7C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018FDEC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018FDEC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018FDEC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018FE20[])(void); - D_8018FE20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018FBA8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018FE28[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018FE40[])(void); - D_8018FE40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018FBA8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018FE28[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018FE60[])(void); - D_8018FE60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018FBA8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018FBA8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018FE70; -extern u16 D_8018FE72; -extern u16 D_8018FE74; -extern s32 D_8018FE78; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018FE70 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018FE72 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018FE74 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018FE78, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018FE80; - -void func_8015E588(void) { - func_8013C9C4(&D_8018FE80); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018FBA8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018FBA8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018FE94[])(void); - D_8018FE94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018FBA8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018FBA8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018FE9C[])(void); - D_8018FE9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018FB8C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018FB8C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018FBA8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018FEA4[])(void); - D_8018FEA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018FBA8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018FBA8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018FEAC[])(void); - D_8018FEAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018FBA8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018FEB4; - extern s32 D_8018FEC4; - extern s32 D_8018FED4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018FBA8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FEB4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FEC4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018FBA8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FED4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018FEE4[])(void); - D_8018FEE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018FBA8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018FBA8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018FBA8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018FBA8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018FEF0[])(void); - D_8018FEF0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018FBA8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018FBA8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018FBA8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018FBA8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018FF04[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018FF04[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018FBA8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018FBA8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018FBA8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018FBA8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018FF80[])(void); - D_8018FF80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018FBA8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018FBA8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018FF90[])(void); - D_8018FF90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018FBA8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018FBA8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018FBA8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018FBA8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018FBA8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018FBA8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018FBA8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018FF98[])(void); - D_8018FF98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018FBA8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018FBA8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018FBA8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018FFA4[])(void); - D_8018FFA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018FBA8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018FBA8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018FBA8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018FBA8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018FFB4[])(void); - -void func_80160EA4(void *a0) { - D_8018FFB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018FBA8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018FBA8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018FFE4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018FFE4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80190048; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80190048); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801ED530[]; - extern u8 D_80190014[]; - extern u8 D_80190034[]; - extern u8 D_801ED53C[]; - extern u8 D_801ED564[]; - extern u8 D_801ED57C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801ED530[0] = p; - func_80024054(&D_80190014, &D_801ED53C); - func_8001CE28(p, &D_801ED53C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801ED530[1] = p; - func_80024054(&D_80190034, &D_801ED564); - func_8001CE28(p, &D_801ED564); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801ED530[2] = p; - func_800242D0((s16)func_801620C4(), &D_801ED57C, 0x84); - func_8001CE68(p, &D_801ED57C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801ED57C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801ED530[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801ED530; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80190048; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80190048; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80190048; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80190048; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801ED530[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801ED530; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8019006C[])(void); - -void func_80162330(void *a0) { - D_8019006C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801ED588[i] via `extern int D_801ED588[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80190078[]; - extern s32 D_80190090; - extern u8 D_801ED594[]; - extern u8 D_801ED5BC[]; - extern u8 D_801ED5D8[]; - extern int D_801ED588[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801ED588[0] = (s32)item; - func_80024054(D_80190078, D_801ED594); - func_8001CE28(item, D_801ED594); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801ED588[1] = (s32)item; - func_80024054(((u8 *)&D_80190090), D_801ED5BC); - func_8001CE28(item, D_801ED5BC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801ED588[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801ED5D8, 0x84); - func_8001CE68(item, D_801ED5D8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801ED5D8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801ED588[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801ED588; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_801627E8); - - -extern void (*D_801900B4[])(void); - -void func_80162834(void *a0) { - D_801900B4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801900A4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801900A4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801EC888[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801EC888, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801EC888[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801EC888, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801900BC[])(void); - -void func_80163A58(void *a0) { - D_801900BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801EC890; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801EC890; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80190110[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80190110[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801900D8; -extern s16 D_8019010C; -extern s16 D_8019010A; -extern s16 D_80190108; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801900D8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8019010C = 0x80; - D_8019010A = 0x80; - D_80190108 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8019010C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8019010C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8019010C - 8; - D_8019010C = nv; - D_8019010A = nv; - D_80190108 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8019011C[])(void); - -void func_80164BA0(void *a0) { - D_8019011C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801ED5E8; -extern u8 D_801ED5E9; -extern u8 D_801ED5EA; -extern u8 D_801ED5EB; -extern u8 D_801ED5EC; -extern u8 D_801ED5ED; -extern u8 D_801ED5EE; -extern u8 D_801ED5EF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801ED5E8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801ED5E9 = 0xf0; - *(u8 *)base = 0xf0; - D_801ED5EA = 0xc0; - D_801ED5EE = 0; - D_801ED5ED = 0; - D_801ED5EC = 0; - D_801ED5EF = 0; - D_801ED5EB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801ED5E8; -extern u8 D_801ED5E9; -extern u8 D_801ED5EA; - -s32 func_80164E40(void) { - u8 *p = &D_801ED5E8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801ED5E9 != 0) { - D_801ED5E9 -= 0x10; - } - if (D_801ED5EA != 0) { - D_801ED5EA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8019012C[])(void); - -void func_80164EA4(void *a0) { - D_8019012C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801ED634[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801ED634[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801ED628[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801ED628[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801ED628[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801ED628; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801ED628; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80190140[]; - extern u32 D_80190160, D_80190164, D_80190168, D_8019016C; - extern u32 D_80190160, D_80190164, D_80190168, D_8019016C; - extern u32 D_80190160, D_80190164, D_80190168, D_8019016C; - extern u32 D_80190160, D_80190164, D_80190168, D_8019016C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80190140[0x00], p); - ApplyMatrixSV(mat, &D_80190140[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80190140[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80190140[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80190168; - *(u32 *)(prim + 0x24) = D_80190160; - *(u32 *)(prim + 0x28) = D_8019016C; - *(u32 *)(prim + 0x2c) = D_80190164; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80190170[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80190170[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80190170[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80190170[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801901EC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801901EC[a1 & 0x7F]; -} - - - -extern s32 D_8019020C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8019020C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80190288[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80190288[a1 & 0x7F]; -} - - - -extern u8 D_801902A8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801902A8[a1 & 0x7F]; -} - - - -extern u8 D_801902C8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801902C8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801902E8[])(void); - D_801902E8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80190364[])(void); - -void func_80165AC8(void) { - D_80190364[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801903E0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801903E0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801EC898; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801EC898, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801903EC[])(void); - -void func_80166018(void *a0) { - D_801903EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801903F4[])(void); - -void func_801663FC(void *a0) { - D_801903F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801904BC[])(void); - -void func_80166618(void *a0) { - D_801904BC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801904CC[])(void); - -void func_80166654(void *a0) { - D_801904CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801ED6A8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801ED6A8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801ED6A8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801ED6A8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801ED6A8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801ED6A8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801ED6A8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80190410[]; - extern u8 D_801903FC[]; - extern u8 D_80190424[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80190410; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801903FC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80190424; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80167714); - - -extern void (*D_801904DC[])(void); - -void func_801678B4(void *a0) { - D_801904DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801904E8[])(void); - -void func_80167A9C(void *a0) { - D_801904E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801905F4; - extern u8 D_80190608[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801905F4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80190608; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80190448[]; -extern u8 D_8019045C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80190448; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8019045C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80190500[])(void); - -void func_80168744(void *a0) { - D_80190500[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801904F0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801904F0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801904F0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80190508[])(void); - -void func_801689D8(void *a0) { - D_80190508[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80190510[])(void); - -void func_80168AA8(void *a0) { - D_80190510[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80190518[])(void); - -void func_80168D58(void *a0) { - D_80190518[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80190520[])(void); - -void func_8016901C(void *a0) { - D_80190520[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015AE2C", func_80169228); - - -extern void (*D_80190528[])(void); - -void func_801693CC(void *a0) { - D_80190528[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80190530[])(void); - -void func_80169830(void *a0) { - D_80190530[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801905E4[])(void); - -void func_80169B80(void *a0) { - D_801905E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80190538[]; - extern u8 D_801905A8[]; - extern u8 D_801905D8[]; - extern u8 D_801EF2F8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801905D8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80190538[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801EF2F8; - RotMatrixYXZ(rot, D_801EF2F8); - func_80048D9C(D_801EF2F8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801905A8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801905EC[])(void); - -void func_80169F00(void *a0) { - D_801905EC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8019059C[]; -extern char D_8019055C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8019059C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8019055C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80190624[])(void); - -void func_8016A020(void *a0) { - D_80190624[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801905F4; - extern u8 D_80190608[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801905F4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80190608; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80190630[])(void); - -void func_8016A700(void *a0) { - D_80190630[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80190678[])(void); - -void func_8016AB30(void *a0) { - D_80190678[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c b/src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c new file mode 100644 index 000000000..12137c9af --- /dev/null +++ b/src/ov_SC03_001/ov_SC03_001_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018FA44; +extern u8 D_8018F9B4; +extern u8 D_8018F990; +extern u8 D_8018F96C; +extern u8 D_8018FA20; +extern u8 D_8018F9FC; +extern u8 D_8018F9D8; +extern u8 D_8018F948; +extern void func_80145934(void); +extern u8 D_8018FAD4; +extern u8 D_8018FAB0; +extern u8 D_8018FA8C; +extern u8 D_8018FA68; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018EECC[]; +extern unsigned char D_8018EEFC[]; +extern unsigned char D_8018EF4C[]; +extern unsigned char D_8018EF7C[]; +extern unsigned char D_8018EFAC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018EFFC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018F0C4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018F14C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018F154; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801ED4D8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801ED4DC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018F184; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018F22C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018F250[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018F240; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018F264[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018F270[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018F280[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018F298[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018F288; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018F2AC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018F2C8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018F2B8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018F2DC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018F2F0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018F304; +extern void (*D_8018F32C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018F30C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018F378[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018F37C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018F7E0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018F7F0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801ED510; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018F818[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018F7F8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018F808; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018F858[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018F860[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018F82C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018F86C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018F83C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801ED518; +extern s32 D_801ED524; +extern s32 D_801ED528; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018F8A8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018F87C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801ED520; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018FAF8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018F918[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018FB9C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018FCF0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018FB0C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018FCF8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018FB1C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018FB3C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018FD00[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018FD28[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018FBA8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018FD34[])(void); + +void func_8015C714(void *a0) { + D_8018FD34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018FBA8[])(void*); + extern int D_8018FB4C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018FB4C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018FBA8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018FBA8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018FBA8[])(void*); + extern int D_8018FB4C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018FB4C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018FD44[])(void); + D_8018FD44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018FBA8[])(struct Ent_8015CD20 *); + extern u8 D_8018FB5C; + extern u8 D_8018FD4C; + extern u8 D_8018FD5C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018FBA8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FB5C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FD4C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FD5C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018FBA8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018FD7C[])(void); + D_8018FD7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018FD6C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018FD6C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018FBA8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018FDD8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018FDD8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018EEBC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018EEBC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018FDE0[])(void); + D_8018FDE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018FDEC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018FDEC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018FDEC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018FDEC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018FBA8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018FDEC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018FB6C[]; + extern u8 D_8018FB7C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018FB6C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018FB7C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018FDEC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018FDEC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018FDEC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018FE20[])(void); + D_8018FE20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018FBA8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018FE28[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018FE40[])(void); + D_8018FE40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018FBA8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018FE28[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018FE28[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018FE60[])(void); + D_8018FE60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018FBA8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018FBA8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018FE70; +extern u16 D_8018FE72; +extern u16 D_8018FE74; +extern s32 D_8018FE78; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018FE70 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018FE72 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018FE74 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018FE78, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018FE80; + +void func_8015E588(void) { + func_8013C9C4(&D_8018FE80); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018FBA8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018FBA8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018FE94[])(void); + D_8018FE94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018FBA8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018FBA8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018FE9C[])(void); + D_8018FE9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018FB8C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018FB8C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018FBA8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018FEA4[])(void); + D_8018FEA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018FBA8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018FBA8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018FEAC[])(void); + D_8018FEAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018FBA8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018FEB4; + extern s32 D_8018FEC4; + extern s32 D_8018FED4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FEB4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FEC4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018FBA8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FED4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018FEE4[])(void); + D_8018FEE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018FBA8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018FBA8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018FBA8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018FBA8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018FEF0[])(void); + D_8018FEF0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018FBA8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018FBA8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018FBA8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018FBA8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018FF04[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018FF04[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018FBA8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018FBA8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018FBA8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018FBA8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018FF80[])(void); + D_8018FF80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018FBA8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018FBA8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018FF90[])(void); + D_8018FF90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018FBA8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018FBA8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018FBA8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018FBA8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018FBA8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018FBA8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018FBA8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018FF98[])(void); + D_8018FF98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018FBA8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018FBA8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018FBA8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018FBA8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018FFA4[])(void); + D_8018FFA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018FBA8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018FBA8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018FBA8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018FBA8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018FFB4[])(void); + +void func_80160EA4(void *a0) { + D_8018FFB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018FBA8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018FBA8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018FFE4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018FFE4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80190048; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80190048); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801ED530[]; + extern u8 D_80190014[]; + extern u8 D_80190034[]; + extern u8 D_801ED53C[]; + extern u8 D_801ED564[]; + extern u8 D_801ED57C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801ED530[0] = p; + func_80024054(&D_80190014, &D_801ED53C); + func_8001CE28(p, &D_801ED53C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801ED530[1] = p; + func_80024054(&D_80190034, &D_801ED564); + func_8001CE28(p, &D_801ED564); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801ED530[2] = p; + func_800242D0((s16)func_801620C4(), &D_801ED57C, 0x84); + func_8001CE68(p, &D_801ED57C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801ED57C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801ED530[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801ED530; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80190048; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80190048; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80190048; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80190048; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801ED530[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801ED530; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8019006C[])(void); + +void func_80162330(void *a0) { + D_8019006C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801ED588[i] via `extern int D_801ED588[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80190078[]; + extern s32 D_80190090; + extern u8 D_801ED594[]; + extern u8 D_801ED5BC[]; + extern u8 D_801ED5D8[]; + extern int D_801ED588[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801ED588[0] = (s32)item; + func_80024054(D_80190078, D_801ED594); + func_8001CE28(item, D_801ED594); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801ED588[1] = (s32)item; + func_80024054(((u8 *)&D_80190090), D_801ED5BC); + func_8001CE28(item, D_801ED5BC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801ED588[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801ED5D8, 0x84); + func_8001CE68(item, D_801ED5D8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801ED5D8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801ED588[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801ED588; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_801627E8); + + +extern void (*D_801900B4[])(void); + +void func_80162834(void *a0) { + D_801900B4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801900A4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801900A4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801EC888[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801EC888, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801EC888[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801EC888, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801900BC[])(void); + +void func_80163A58(void *a0) { + D_801900BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801EC890; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801EC890; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80190110[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80190110[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801900D8; +extern s16 D_8019010C; +extern s16 D_8019010A; +extern s16 D_80190108; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801900D8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8019010C = 0x80; + D_8019010A = 0x80; + D_80190108 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8019010C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8019010C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8019010C - 8; + D_8019010C = nv; + D_8019010A = nv; + D_80190108 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8019011C[])(void); + +void func_80164BA0(void *a0) { + D_8019011C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801ED5E8; +extern u8 D_801ED5E9; +extern u8 D_801ED5EA; +extern u8 D_801ED5EB; +extern u8 D_801ED5EC; +extern u8 D_801ED5ED; +extern u8 D_801ED5EE; +extern u8 D_801ED5EF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801ED5E8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801ED5E9 = 0xf0; + *(u8 *)base = 0xf0; + D_801ED5EA = 0xc0; + D_801ED5EE = 0; + D_801ED5ED = 0; + D_801ED5EC = 0; + D_801ED5EF = 0; + D_801ED5EB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801ED5E8; +extern u8 D_801ED5E9; +extern u8 D_801ED5EA; + +s32 func_80164E40(void) { + u8 *p = &D_801ED5E8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801ED5E9 != 0) { + D_801ED5E9 -= 0x10; + } + if (D_801ED5EA != 0) { + D_801ED5EA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8019012C[])(void); + +void func_80164EA4(void *a0) { + D_8019012C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801ED634[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801ED634[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801ED628[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801ED628[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801ED628[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801ED628; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801ED628; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80190140[]; + extern u32 D_80190160, D_80190164, D_80190168, D_8019016C; + extern u32 D_80190160, D_80190164, D_80190168, D_8019016C; + extern u32 D_80190160, D_80190164, D_80190168, D_8019016C; + extern u32 D_80190160, D_80190164, D_80190168, D_8019016C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80190140[0x00], p); + ApplyMatrixSV(mat, &D_80190140[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80190140[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80190140[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80190168; + *(u32 *)(prim + 0x24) = D_80190160; + *(u32 *)(prim + 0x28) = D_8019016C; + *(u32 *)(prim + 0x2c) = D_80190164; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80190170[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80190170[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80190170[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80190170[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801901EC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801901EC[a1 & 0x7F]; +} + + + +extern s32 D_8019020C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8019020C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80190288[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80190288[a1 & 0x7F]; +} + + + +extern u8 D_801902A8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801902A8[a1 & 0x7F]; +} + + + +extern u8 D_801902C8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801902C8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801902E8[])(void); + D_801902E8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80190364[])(void); + +void func_80165AC8(void) { + D_80190364[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801903E0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801903E0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801EC898; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801EC898, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801903EC[])(void); + +void func_80166018(void *a0) { + D_801903EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801903F4[])(void); + +void func_801663FC(void *a0) { + D_801903F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801904BC[])(void); + +void func_80166618(void *a0) { + D_801904BC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801904CC[])(void); + +void func_80166654(void *a0) { + D_801904CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801ED6A8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801ED6A8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801ED6A8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801ED6A8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801ED6A8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801ED6A8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801ED6A8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80190410[]; + extern u8 D_801903FC[]; + extern u8 D_80190424[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80190410; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801903FC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80190424; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80167714); + + +extern void (*D_801904DC[])(void); + +void func_801678B4(void *a0) { + D_801904DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801904E8[])(void); + +void func_80167A9C(void *a0) { + D_801904E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801905F4; + extern u8 D_80190608[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801905F4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80190608; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80190448[]; +extern u8 D_8019045C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80190448; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8019045C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80190500[])(void); + +void func_80168744(void *a0) { + D_80190500[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801904F0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801904F0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801904F0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80190508[])(void); + +void func_801689D8(void *a0) { + D_80190508[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80190510[])(void); + +void func_80168AA8(void *a0) { + D_80190510[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80190518[])(void); + +void func_80168D58(void *a0) { + D_80190518[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80190520[])(void); + +void func_8016901C(void *a0) { + D_80190520[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_001/nonmatchings/ov_SC03_001_jr_8015C32C", func_80169228); + + +extern void (*D_80190528[])(void); + +void func_801693CC(void *a0) { + D_80190528[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80190530[])(void); + +void func_80169830(void *a0) { + D_80190530[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801905E4[])(void); + +void func_80169B80(void *a0) { + D_801905E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80190538[]; + extern u8 D_801905A8[]; + extern u8 D_801905D8[]; + extern u8 D_801EF2F8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801905D8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80190538[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801EF2F8; + RotMatrixYXZ(rot, D_801EF2F8); + func_80048D9C(D_801EF2F8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801905A8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801905EC[])(void); + +void func_80169F00(void *a0) { + D_801905EC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8019059C[]; +extern char D_8019055C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8019059C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8019055C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80190624[])(void); + +void func_8016A020(void *a0) { + D_80190624[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801905F4; + extern u8 D_80190608[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801905F4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80190608; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80190630[])(void); + +void func_8016A700(void *a0) { + D_80190630[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80190678[])(void); + +void func_8016AB30(void *a0) { + D_80190678[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_002/ov_SC03_002_jr_8015AE2C.c b/src/ov_SC03_002/ov_SC03_002_jr_8015AE2C.c index 2f46f0bb7..fa57f41a9 100644 --- a/src/ov_SC03_002/ov_SC03_002_jr_8015AE2C.c +++ b/src/ov_SC03_002/ov_SC03_002_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80187D24[])(void); - -void func_8015C714(void *a0) { - D_80187D24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80187B98[])(void*); - extern int D_80187B3C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80187B98)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80187B98)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187B3C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80187B98[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80187B98[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80187B98[])(void*); - extern int D_80187B3C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80187B98)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187B3C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80187B98)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80187D34[])(void); - D_80187D34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80187B98[])(struct Ent_8015CD20 *); - extern u8 D_80187B4C; - extern u8 D_80187D3C; - extern u8 D_80187D4C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80187B98[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187B4C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187D3C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187D4C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80187B98[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80187D6C[])(void); - D_80187D6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80187D5C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80187D5C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80187B98[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80187DC8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80187DC8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80186EAC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80186EAC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80187DD0[])(void); - D_80187DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80187DDC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80187DDC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80187DDC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80187DDC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80187B98[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80187DDC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80187B5C[]; - extern u8 D_80187B6C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187B5C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187B6C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80187DDC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187DDC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187DDC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80187E10[])(void); - D_80187E10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187B98[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80187E18[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80187E30[])(void); - D_80187E30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187B98[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80187E18[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80187E50[])(void); - D_80187E50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80187B98[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187B98)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80187E60; -extern u16 D_80187E62; -extern u16 D_80187E64; -extern s32 D_80187E68; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80187E60 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80187E62 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187E64 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187E68, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80187E70; - -void func_8015E588(void) { - func_8013C9C4(&D_80187E70); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80187B98[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187B98)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80187E84[])(void); - D_80187E84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80187B98[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80187B98[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80187E8C[])(void); - D_80187E8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80187B7C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187B7C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80187B98[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187E94[])(void); - D_80187E94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80187B98[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80187B98[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80187E9C[])(void); - D_80187E9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80187B98[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80187EA4; - extern s32 D_80187EB4; - extern s32 D_80187EC4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80187B98[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187EA4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187EB4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80187B98[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187EC4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80187ED4[])(void); - D_80187ED4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80187B98[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80187B98[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80187B98[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187B98[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80187EE0[])(void); - D_80187EE0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80187B98[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187B98[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80187B98[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187B98[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80187EF4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80187EF4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80187B98[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80187B98)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80187B98[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187B98[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80187F70[])(void); - D_80187F70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80187B98[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80187B98)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80187F80[])(void); - D_80187F80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80187B98[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80187B98[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80187B98[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80187B98[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80187B98[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80187B98[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80187B98[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80187F88[])(void); - D_80187F88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80187B98[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80187B98)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80187B98[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80187B98)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187F94[])(void); - D_80187F94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187B98 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80187B98[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80187B98[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80187B98[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80187FA4[])(void); - -void func_80160EA4(void *a0) { - D_80187FA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80187B98[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80187B98[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80187FD4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80187FD4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80188038; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80188038); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801CA5B0[]; - extern u8 D_80188004[]; - extern u8 D_80188024[]; - extern u8 D_801CA5BC[]; - extern u8 D_801CA5E4[]; - extern u8 D_801CA5FC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801CA5B0[0] = p; - func_80024054(&D_80188004, &D_801CA5BC); - func_8001CE28(p, &D_801CA5BC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801CA5B0[1] = p; - func_80024054(&D_80188024, &D_801CA5E4); - func_8001CE28(p, &D_801CA5E4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801CA5B0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801CA5FC, 0x84); - func_8001CE68(p, &D_801CA5FC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801CA5FC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CA5B0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801CA5B0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80188038; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80188038; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80188038; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80188038; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801CA5B0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801CA5B0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018805C[])(void); - -void func_80162330(void *a0) { - D_8018805C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801CA608[i] via `extern int D_801CA608[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80188068[]; - extern s32 D_80188080; - extern u8 D_801CA614[]; - extern u8 D_801CA63C[]; - extern u8 D_801CA658[]; - extern int D_801CA608[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801CA608[0] = (s32)item; - func_80024054(D_80188068, D_801CA614); - func_8001CE28(item, D_801CA614); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801CA608[1] = (s32)item; - func_80024054(((u8 *)&D_80188080), D_801CA63C); - func_8001CE28(item, D_801CA63C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801CA608[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801CA658, 0x84); - func_8001CE68(item, D_801CA658); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801CA658, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CA608[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801CA608; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_801627E8); - - -extern void (*D_801880A4[])(void); - -void func_80162834(void *a0) { - D_801880A4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80188094; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80188094, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C9DE4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C9DE4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C9DE4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C9DE4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801880AC[])(void); - -void func_80163A58(void *a0) { - D_801880AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C9DEC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C9DEC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80188100[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80188100[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801880C8; -extern s16 D_801880FC; -extern s16 D_801880FA; -extern s16 D_801880F8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801880C8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801880FC = 0x80; - D_801880FA = 0x80; - D_801880F8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801880FC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801880FC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801880FC - 8; - D_801880FC = nv; - D_801880FA = nv; - D_801880F8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018810C[])(void); - -void func_80164BA0(void *a0) { - D_8018810C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801CA668; -extern u8 D_801CA669; -extern u8 D_801CA66A; -extern u8 D_801CA66B; -extern u8 D_801CA66C; -extern u8 D_801CA66D; -extern u8 D_801CA66E; -extern u8 D_801CA66F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801CA668; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801CA669 = 0xf0; - *(u8 *)base = 0xf0; - D_801CA66A = 0xc0; - D_801CA66E = 0; - D_801CA66D = 0; - D_801CA66C = 0; - D_801CA66F = 0; - D_801CA66B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801CA668; -extern u8 D_801CA669; -extern u8 D_801CA66A; - -s32 func_80164E40(void) { - u8 *p = &D_801CA668; - if (*p != 0) { - *p -= 0x10; - } - if (D_801CA669 != 0) { - D_801CA669 -= 0x10; - } - if (D_801CA66A != 0) { - D_801CA66A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018811C[])(void); - -void func_80164EA4(void *a0) { - D_8018811C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801CA6B4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801CA6B4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801CA6A8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801CA6A8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801CA6A8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801CA6A8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801CA6A8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80188130[]; - extern u32 D_80188150, D_80188154, D_80188158, D_8018815C; - extern u32 D_80188150, D_80188154, D_80188158, D_8018815C; - extern u32 D_80188150, D_80188154, D_80188158, D_8018815C; - extern u32 D_80188150, D_80188154, D_80188158, D_8018815C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80188130[0x00], p); - ApplyMatrixSV(mat, &D_80188130[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80188130[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80188130[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80188158; - *(u32 *)(prim + 0x24) = D_80188150; - *(u32 *)(prim + 0x28) = D_8018815C; - *(u32 *)(prim + 0x2c) = D_80188154; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80188160[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80188160[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80188160[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80188160[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801881DC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801881DC[a1 & 0x7F]; -} - - - -extern s32 D_801881FC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801881FC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80188278[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80188278[a1 & 0x7F]; -} - - - -extern u8 D_80188298[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80188298[a1 & 0x7F]; -} - - - -extern u8 D_801882B8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801882B8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801882D8[])(void); - D_801882D8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80188354[])(void); - -void func_80165AC8(void) { - D_80188354[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801883D0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801883D0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C9DF4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C9DF4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801883DC[])(void); - -void func_80166018(void *a0) { - D_801883DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801883E4[])(void); - -void func_801663FC(void *a0) { - D_801883E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801884AC[])(void); - -void func_80166618(void *a0) { - D_801884AC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801884BC[])(void); - -void func_80166654(void *a0) { - D_801884BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801CA728[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801CA728[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CA728). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801CA728[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801CA728)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801CA728[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801CA728[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80188400[]; - extern u8 D_801883EC[]; - extern u8 D_80188414[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80188400; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801883EC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80188414; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80167714); - - -extern void (*D_801884CC[])(void); - -void func_801678B4(void *a0) { - D_801884CC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801884D8[])(void); - -void func_80167A9C(void *a0) { - D_801884D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801885E4; - extern u8 D_801885F8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801885E4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801885F8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80188438[]; -extern u8 D_8018844C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80188438; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018844C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801884F0[])(void); - -void func_80168744(void *a0) { - D_801884F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801884E0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801884E0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801884E0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801884F8[])(void); - -void func_801689D8(void *a0) { - D_801884F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80188500[])(void); - -void func_80168AA8(void *a0) { - D_80188500[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80188508[])(void); - -void func_80168D58(void *a0) { - D_80188508[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80188510[])(void); - -void func_8016901C(void *a0) { - D_80188510[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015AE2C", func_80169228); - - -extern void (*D_80188518[])(void); - -void func_801693CC(void *a0) { - D_80188518[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80188520[])(void); - -void func_80169830(void *a0) { - D_80188520[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801885D4[])(void); - -void func_80169B80(void *a0) { - D_801885D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80188528[]; - extern u8 D_80188598[]; - extern u8 D_801885C8[]; - extern u8 D_801CB9E0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801885C8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80188528[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801CB9E0; - RotMatrixYXZ(rot, D_801CB9E0); - func_80048D9C(D_801CB9E0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80188598); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801885DC[])(void); - -void func_80169F00(void *a0) { - D_801885DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018858C[]; -extern char D_8018854C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018858C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018854C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80188614[])(void); - -void func_8016A020(void *a0) { - D_80188614[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801885E4; - extern u8 D_801885F8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801885E4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801885F8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80188620[])(void); - -void func_8016A700(void *a0) { - D_80188620[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80188668[])(void); - -void func_8016AB30(void *a0) { - D_80188668[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c b/src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c new file mode 100644 index 000000000..37e0d47fe --- /dev/null +++ b/src/ov_SC03_002/ov_SC03_002_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80187A34; +extern u8 D_801879A4; +extern u8 D_80187980; +extern u8 D_8018795C; +extern u8 D_80187A10; +extern u8 D_801879EC; +extern u8 D_801879C8; +extern u8 D_80187938; +extern void func_80145934(void); +extern u8 D_80187AC4; +extern u8 D_80187AA0; +extern u8 D_80187A7C; +extern u8 D_80187A58; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80186EBC[]; +extern unsigned char D_80186EEC[]; +extern unsigned char D_80186F3C[]; +extern unsigned char D_80186F6C[]; +extern unsigned char D_80186F9C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80186FEC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801870B4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018713C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80187144; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801CA558; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801CA55C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80187174; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018721C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80187240[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80187230; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80187254[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80187260[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80187270[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80187288[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80187278; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018729C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801872B8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801872A8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801872CC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801872E0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801872F4; +extern void (*D_8018731C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801872FC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80187368[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018736C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801877D0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801877E0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801CA590; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80187808[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801877E8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801877F8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80187848[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80187850[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018781C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018785C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018782C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801CA598; +extern s32 D_801CA5A4; +extern s32 D_801CA5A8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80187898[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018786C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801CA5A0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80187AE8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80187908[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80187B8C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80187CE0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80187AFC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80187CE8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80187B0C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80187B2C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80187CF0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80187D18[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80187B98[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80187D24[])(void); + +void func_8015C714(void *a0) { + D_80187D24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80187B98[])(void*); + extern int D_80187B3C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80187B98)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80187B98)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187B3C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80187B98[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80187B98[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80187B98[])(void*); + extern int D_80187B3C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80187B98)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187B3C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80187B98)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80187D34[])(void); + D_80187D34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80187B98[])(struct Ent_8015CD20 *); + extern u8 D_80187B4C; + extern u8 D_80187D3C; + extern u8 D_80187D4C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80187B98[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187B4C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187D3C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187D4C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80187B98[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80187D6C[])(void); + D_80187D6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80187D5C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80187D5C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80187B98[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80187DC8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80187DC8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80186EAC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80186EAC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80187DD0[])(void); + D_80187DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80187DDC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80187DDC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80187DDC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80187DDC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80187B98[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80187DDC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80187B5C[]; + extern u8 D_80187B6C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187B5C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187B6C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80187DDC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187DDC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187DDC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80187E10[])(void); + D_80187E10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187B98[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80187E18[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80187E30[])(void); + D_80187E30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187B98[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80187E18[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80187E18[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80187E50[])(void); + D_80187E50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80187B98[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187B98)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80187E60; +extern u16 D_80187E62; +extern u16 D_80187E64; +extern s32 D_80187E68; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80187E60 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80187E62 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187E64 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187E68, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80187E70; + +void func_8015E588(void) { + func_8013C9C4(&D_80187E70); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80187B98[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187B98)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80187E84[])(void); + D_80187E84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80187B98[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80187B98[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80187E8C[])(void); + D_80187E8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80187B7C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187B7C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80187B98[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187E94[])(void); + D_80187E94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80187B98[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80187B98[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80187E9C[])(void); + D_80187E9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80187B98[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80187EA4; + extern s32 D_80187EB4; + extern s32 D_80187EC4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187EA4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187EB4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80187B98[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187EC4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80187ED4[])(void); + D_80187ED4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80187B98[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80187B98[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80187B98[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187B98[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80187EE0[])(void); + D_80187EE0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80187B98[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187B98[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80187B98[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187B98[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80187EF4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80187EF4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80187B98[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80187B98)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80187B98[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187B98[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80187F70[])(void); + D_80187F70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80187B98[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80187B98)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80187F80[])(void); + D_80187F80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80187B98[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80187B98[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80187B98[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80187B98[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80187B98[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80187B98[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80187B98[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80187F88[])(void); + D_80187F88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80187B98[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80187B98)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80187B98[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80187B98)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187F94[])(void); + D_80187F94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187B98 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80187B98[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80187B98[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80187B98[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80187FA4[])(void); + +void func_80160EA4(void *a0) { + D_80187FA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80187B98[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80187B98[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80187FD4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80187FD4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80188038; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80188038); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801CA5B0[]; + extern u8 D_80188004[]; + extern u8 D_80188024[]; + extern u8 D_801CA5BC[]; + extern u8 D_801CA5E4[]; + extern u8 D_801CA5FC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801CA5B0[0] = p; + func_80024054(&D_80188004, &D_801CA5BC); + func_8001CE28(p, &D_801CA5BC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801CA5B0[1] = p; + func_80024054(&D_80188024, &D_801CA5E4); + func_8001CE28(p, &D_801CA5E4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801CA5B0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801CA5FC, 0x84); + func_8001CE68(p, &D_801CA5FC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801CA5FC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CA5B0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801CA5B0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80188038; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80188038; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80188038; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80188038; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801CA5B0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801CA5B0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018805C[])(void); + +void func_80162330(void *a0) { + D_8018805C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801CA608[i] via `extern int D_801CA608[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80188068[]; + extern s32 D_80188080; + extern u8 D_801CA614[]; + extern u8 D_801CA63C[]; + extern u8 D_801CA658[]; + extern int D_801CA608[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801CA608[0] = (s32)item; + func_80024054(D_80188068, D_801CA614); + func_8001CE28(item, D_801CA614); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801CA608[1] = (s32)item; + func_80024054(((u8 *)&D_80188080), D_801CA63C); + func_8001CE28(item, D_801CA63C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801CA608[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801CA658, 0x84); + func_8001CE68(item, D_801CA658); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801CA658, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CA608[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801CA608; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_801627E8); + + +extern void (*D_801880A4[])(void); + +void func_80162834(void *a0) { + D_801880A4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80188094; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80188094, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C9DE4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C9DE4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C9DE4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C9DE4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801880AC[])(void); + +void func_80163A58(void *a0) { + D_801880AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C9DEC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C9DEC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80188100[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80188100[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801880C8; +extern s16 D_801880FC; +extern s16 D_801880FA; +extern s16 D_801880F8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801880C8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801880FC = 0x80; + D_801880FA = 0x80; + D_801880F8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801880FC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801880FC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801880FC - 8; + D_801880FC = nv; + D_801880FA = nv; + D_801880F8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018810C[])(void); + +void func_80164BA0(void *a0) { + D_8018810C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801CA668; +extern u8 D_801CA669; +extern u8 D_801CA66A; +extern u8 D_801CA66B; +extern u8 D_801CA66C; +extern u8 D_801CA66D; +extern u8 D_801CA66E; +extern u8 D_801CA66F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801CA668; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801CA669 = 0xf0; + *(u8 *)base = 0xf0; + D_801CA66A = 0xc0; + D_801CA66E = 0; + D_801CA66D = 0; + D_801CA66C = 0; + D_801CA66F = 0; + D_801CA66B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801CA668; +extern u8 D_801CA669; +extern u8 D_801CA66A; + +s32 func_80164E40(void) { + u8 *p = &D_801CA668; + if (*p != 0) { + *p -= 0x10; + } + if (D_801CA669 != 0) { + D_801CA669 -= 0x10; + } + if (D_801CA66A != 0) { + D_801CA66A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018811C[])(void); + +void func_80164EA4(void *a0) { + D_8018811C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801CA6B4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801CA6B4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801CA6A8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801CA6A8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801CA6A8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801CA6A8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801CA6A8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80188130[]; + extern u32 D_80188150, D_80188154, D_80188158, D_8018815C; + extern u32 D_80188150, D_80188154, D_80188158, D_8018815C; + extern u32 D_80188150, D_80188154, D_80188158, D_8018815C; + extern u32 D_80188150, D_80188154, D_80188158, D_8018815C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80188130[0x00], p); + ApplyMatrixSV(mat, &D_80188130[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80188130[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80188130[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80188158; + *(u32 *)(prim + 0x24) = D_80188150; + *(u32 *)(prim + 0x28) = D_8018815C; + *(u32 *)(prim + 0x2c) = D_80188154; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80188160[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80188160[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80188160[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80188160[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801881DC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801881DC[a1 & 0x7F]; +} + + + +extern s32 D_801881FC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801881FC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80188278[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80188278[a1 & 0x7F]; +} + + + +extern u8 D_80188298[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80188298[a1 & 0x7F]; +} + + + +extern u8 D_801882B8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801882B8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801882D8[])(void); + D_801882D8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80188354[])(void); + +void func_80165AC8(void) { + D_80188354[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801883D0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801883D0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C9DF4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C9DF4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801883DC[])(void); + +void func_80166018(void *a0) { + D_801883DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801883E4[])(void); + +void func_801663FC(void *a0) { + D_801883E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801884AC[])(void); + +void func_80166618(void *a0) { + D_801884AC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801884BC[])(void); + +void func_80166654(void *a0) { + D_801884BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801CA728[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801CA728[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CA728). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801CA728[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801CA728)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801CA728[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801CA728[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80188400[]; + extern u8 D_801883EC[]; + extern u8 D_80188414[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80188400; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801883EC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80188414; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80167714); + + +extern void (*D_801884CC[])(void); + +void func_801678B4(void *a0) { + D_801884CC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801884D8[])(void); + +void func_80167A9C(void *a0) { + D_801884D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801885E4; + extern u8 D_801885F8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801885E4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801885F8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80188438[]; +extern u8 D_8018844C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80188438; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018844C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801884F0[])(void); + +void func_80168744(void *a0) { + D_801884F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801884E0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801884E0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801884E0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801884F8[])(void); + +void func_801689D8(void *a0) { + D_801884F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80188500[])(void); + +void func_80168AA8(void *a0) { + D_80188500[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80188508[])(void); + +void func_80168D58(void *a0) { + D_80188508[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80188510[])(void); + +void func_8016901C(void *a0) { + D_80188510[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_002/nonmatchings/ov_SC03_002_jr_8015C32C", func_80169228); + + +extern void (*D_80188518[])(void); + +void func_801693CC(void *a0) { + D_80188518[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80188520[])(void); + +void func_80169830(void *a0) { + D_80188520[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801885D4[])(void); + +void func_80169B80(void *a0) { + D_801885D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80188528[]; + extern u8 D_80188598[]; + extern u8 D_801885C8[]; + extern u8 D_801CB9E0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801885C8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80188528[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801CB9E0; + RotMatrixYXZ(rot, D_801CB9E0); + func_80048D9C(D_801CB9E0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80188598); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801885DC[])(void); + +void func_80169F00(void *a0) { + D_801885DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018858C[]; +extern char D_8018854C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018858C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018854C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80188614[])(void); + +void func_8016A020(void *a0) { + D_80188614[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801885E4; + extern u8 D_801885F8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801885E4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801885F8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80188620[])(void); + +void func_8016A700(void *a0) { + D_80188620[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80188668[])(void); + +void func_8016AB30(void *a0) { + D_80188668[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_003/ov_SC03_003_jr_8015AE2C.c b/src/ov_SC03_003/ov_SC03_003_jr_8015AE2C.c index 3b933baa4..a46368ab8 100644 --- a/src/ov_SC03_003/ov_SC03_003_jr_8015AE2C.c +++ b/src/ov_SC03_003/ov_SC03_003_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181AEC[])(void); - -void func_8015C714(void *a0) { - D_80181AEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181960[])(void*); - extern int D_80181904; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181960)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181960)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181904); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181960[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181960[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181960[])(void*); - extern int D_80181904; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181960)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181904); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181960)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181AFC[])(void); - D_80181AFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181960[])(struct Ent_8015CD20 *); - extern u8 D_80181914; - extern u8 D_80181B04; - extern u8 D_80181B14; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181960[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181914); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181B04); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181B14); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181960[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181B34[])(void); - D_80181B34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181B24; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181B24 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181960[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181B90; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181B90, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180C74[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180C74; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80181B98[])(void); - D_80181B98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80181BA4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80181BA4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80181BA4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80181BA4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181960[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80181BA4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80181924[]; - extern u8 D_80181934[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181924); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181934); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80181BA4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181BA4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181BA4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80181BD8[])(void); - D_80181BD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181960[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181BE0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181BF8[])(void); - D_80181BF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181960[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181BE0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181C18[])(void); - D_80181C18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181960[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181960)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181C28; -extern u16 D_80181C2A; -extern u16 D_80181C2C; -extern s32 D_80181C30; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181C28 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80181C2A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181C2C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181C30, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181C38; - -void func_8015E588(void) { - func_8013C9C4(&D_80181C38); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181960[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181960)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181C4C[])(void); - D_80181C4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181960[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181960[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181C54[])(void); - D_80181C54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80181944; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181944); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181960[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181C5C[])(void); - D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181960[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181960[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181C64[])(void); - D_80181C64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181960[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181C6C; - extern s32 D_80181C7C; - extern s32 D_80181C8C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181960[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C6C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C7C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181960[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C8C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80181C9C[])(void); - D_80181C9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181960[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181960[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181960[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181960[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80181CA8[])(void); - D_80181CA8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181960[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181960[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181960[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181960[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80181CBC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80181CBC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181960[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181960)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181960[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181960[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181D38[])(void); - D_80181D38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181960[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181960)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181D48[])(void); - D_80181D48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181960[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181960[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181960[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181960[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181960[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181960[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181960[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181D50[])(void); - D_80181D50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181960[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181960)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181960[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181960)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181D5C[])(void); - D_80181D5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181960 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181960[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181960[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181960[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181D6C[])(void); - -void func_80160EA4(void *a0) { - D_80181D6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181960[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181960[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80181D9C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80181D9C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181E00; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181E00); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8018E8B8[]; - extern u8 D_80181DCC[]; - extern u8 D_80181DEC[]; - extern u8 D_8018E8C4[]; - extern u8 D_8018E8EC[]; - extern u8 D_8018E904[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8018E8B8[0] = p; - func_80024054(&D_80181DCC, &D_8018E8C4); - func_8001CE28(p, &D_8018E8C4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8018E8B8[1] = p; - func_80024054(&D_80181DEC, &D_8018E8EC); - func_8001CE28(p, &D_8018E8EC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8018E8B8[2] = p; - func_800242D0((s16)func_801620C4(), &D_8018E904, 0x84); - func_8001CE68(p, &D_8018E904); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8018E904, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E8B8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8018E8B8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181E00; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181E00; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181E00; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181E00; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8018E8B8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8018E8B8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181E24[])(void); - -void func_80162330(void *a0) { - D_80181E24[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8018E910[i] via `extern int D_8018E910[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181E30[]; - extern s32 D_80181E48; - extern u8 D_8018E91C[]; - extern u8 D_8018E944[]; - extern u8 D_8018E960[]; - extern int D_8018E910[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8018E910[0] = (s32)item; - func_80024054(D_80181E30, D_8018E91C); - func_8001CE28(item, D_8018E91C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8018E910[1] = (s32)item; - func_80024054(((u8 *)&D_80181E48), D_8018E944); - func_8001CE28(item, D_8018E944); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8018E910[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8018E960, 0x84); - func_8001CE68(item, D_8018E960); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8018E960, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E910[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8018E910; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181E6C[])(void); - -void func_80162834(void *a0) { - D_80181E6C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181E5C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181E5C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8018E164[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8018E164, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8018E164[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8018E164, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181E74[])(void); - -void func_80163A58(void *a0) { - D_80181E74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8018E16C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8018E16C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80181EC8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80181EC8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181E90; -extern s16 D_80181EC4; -extern s16 D_80181EC2; -extern s16 D_80181EC0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181E90; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181EC4 = 0x80; - D_80181EC2 = 0x80; - D_80181EC0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181EC4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181EC4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181EC4 - 8; - D_80181EC4 = nv; - D_80181EC2 = nv; - D_80181EC0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181ED4[])(void); - -void func_80164BA0(void *a0) { - D_80181ED4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8018E970; -extern u8 D_8018E971; -extern u8 D_8018E972; -extern u8 D_8018E973; -extern u8 D_8018E974; -extern u8 D_8018E975; -extern u8 D_8018E976; -extern u8 D_8018E977; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8018E970; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8018E971 = 0xf0; - *(u8 *)base = 0xf0; - D_8018E972 = 0xc0; - D_8018E976 = 0; - D_8018E975 = 0; - D_8018E974 = 0; - D_8018E977 = 0; - D_8018E973 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8018E970; -extern u8 D_8018E971; -extern u8 D_8018E972; - -s32 func_80164E40(void) { - u8 *p = &D_8018E970; - if (*p != 0) { - *p -= 0x10; - } - if (D_8018E971 != 0) { - D_8018E971 -= 0x10; - } - if (D_8018E972 != 0) { - D_8018E972 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181EE4[])(void); - -void func_80164EA4(void *a0) { - D_80181EE4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8018E9BC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8018E9BC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8018E9B0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8018E9B0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8018E9B0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8018E9B0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8018E9B0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181EF8[]; - extern u32 D_80181F18, D_80181F1C, D_80181F20, D_80181F24; - extern u32 D_80181F18, D_80181F1C, D_80181F20, D_80181F24; - extern u32 D_80181F18, D_80181F1C, D_80181F20, D_80181F24; - extern u32 D_80181F18, D_80181F1C, D_80181F20, D_80181F24; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181EF8[0x00], p); - ApplyMatrixSV(mat, &D_80181EF8[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181EF8[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181EF8[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181F20; - *(u32 *)(prim + 0x24) = D_80181F18; - *(u32 *)(prim + 0x28) = D_80181F24; - *(u32 *)(prim + 0x2c) = D_80181F1C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181F28[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181F28[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181F28[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181F28[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80181FA4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80181FA4[a1 & 0x7F]; -} - - - -extern s32 D_80181FC4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181FC4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80182040[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80182040[a1 & 0x7F]; -} - - - -extern u8 D_80182060[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182060[a1 & 0x7F]; -} - - - -extern u8 D_80182080[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182080[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801820A0[])(void); - D_801820A0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018211C[])(void); - -void func_80165AC8(void) { - D_8018211C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80182198[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80182198[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8018E174; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8018E174, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801821A4[])(void); - -void func_80166018(void *a0) { - D_801821A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801821AC[])(void); - -void func_801663FC(void *a0) { - D_801821AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182274[])(void); - -void func_80166618(void *a0) { - D_80182274[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182284[])(void); - -void func_80166654(void *a0) { - D_80182284[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8018EA30[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8018EA30[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018EA30). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8018EA30[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8018EA30)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8018EA30[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8018EA30[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801821C8[]; - extern u8 D_801821B4[]; - extern u8 D_801821DC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801821C8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801821B4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801821DC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80167714); - - -extern void (*D_80182294[])(void); - -void func_801678B4(void *a0) { - D_80182294[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801822A0[])(void); - -void func_80167A9C(void *a0) { - D_801822A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801823AC; - extern u8 D_801823C0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801823AC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801823C0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80182200[]; -extern u8 D_80182214[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80182200; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80182214; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801822B8[])(void); - -void func_80168744(void *a0) { - D_801822B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801822A8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801822A8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801822A8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801822C0[])(void); - -void func_801689D8(void *a0) { - D_801822C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801822C8[])(void); - -void func_80168AA8(void *a0) { - D_801822C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801822D0[])(void); - -void func_80168D58(void *a0) { - D_801822D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801822D8[])(void); - -void func_8016901C(void *a0) { - D_801822D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015AE2C", func_80169228); - - -extern void (*D_801822E0[])(void); - -void func_801693CC(void *a0) { - D_801822E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801822E8[])(void); - -void func_80169830(void *a0) { - D_801822E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018239C[])(void); - -void func_80169B80(void *a0) { - D_8018239C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801822F0[]; - extern u8 D_80182360[]; - extern u8 D_80182390[]; - extern u8 D_8018FA30[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80182390, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801822F0[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8018FA30; - RotMatrixYXZ(rot, D_8018FA30); - func_80048D9C(D_8018FA30, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182360); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801823A4[])(void); - -void func_80169F00(void *a0) { - D_801823A4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80182354[]; -extern char D_80182314[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80182354, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182314); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801823DC[])(void); - -void func_8016A020(void *a0) { - D_801823DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801823AC; - extern u8 D_801823C0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801823AC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801823C0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801823E8[])(void); - -void func_8016A700(void *a0) { - D_801823E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80182430[])(void); - -void func_8016AB30(void *a0) { - D_80182430[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c b/src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c new file mode 100644 index 000000000..297281de1 --- /dev/null +++ b/src/ov_SC03_003/ov_SC03_003_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801817FC; +extern u8 D_8018176C; +extern u8 D_80181748; +extern u8 D_80181724; +extern u8 D_801817D8; +extern u8 D_801817B4; +extern u8 D_80181790; +extern u8 D_80181700; +extern void func_80145934(void); +extern u8 D_8018188C; +extern u8 D_80181868; +extern u8 D_80181844; +extern u8 D_80181820; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180C84[]; +extern unsigned char D_80180CB4[]; +extern unsigned char D_80180D04[]; +extern unsigned char D_80180D34[]; +extern unsigned char D_80180D64[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80180DB4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80180E7C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180F04[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180F0C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8018E860; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8018E864; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180F3C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180FE4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80181008[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180FF8; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018101C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80181028[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80181038[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181050[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80181040; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181064[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181080[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181070; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181094[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801810A8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801810BC; +extern void (*D_801810E4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801810C4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80181130[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80181134[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80181598[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801815A8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8018E898; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801815D0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801815B0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801815C0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80181610[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80181618[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801815E4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80181624[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801815F4; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8018E8A0; +extern s32 D_8018E8AC; +extern s32 D_8018E8B0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80181660[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80181634[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8018E8A8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801818B0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801816D0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181954[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80181AA8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801818C4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80181AB0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801818D4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801818F4; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80181AB8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80181AE0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181960[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181960[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181960[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181960[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181960[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181960[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181960[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181960[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181AEC[])(void); + +void func_8015C714(void *a0) { + D_80181AEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181960[])(void*); + extern int D_80181904; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181960)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181960)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181904); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181960[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181960[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181960[])(void*); + extern int D_80181904; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181960)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181904); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181960)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181AFC[])(void); + D_80181AFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181960[])(struct Ent_8015CD20 *); + extern u8 D_80181914; + extern u8 D_80181B04; + extern u8 D_80181B14; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181960[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181914); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181B04); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181B14); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181960[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181B34[])(void); + D_80181B34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181B24; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181B24 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181960[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181B90; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181B90, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180C74[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180C74; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80181B98[])(void); + D_80181B98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80181BA4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80181BA4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80181BA4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80181BA4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181960[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80181BA4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80181924[]; + extern u8 D_80181934[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181924); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181934); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80181BA4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181BA4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181BA4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80181BD8[])(void); + D_80181BD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181960[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181BE0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181BF8[])(void); + D_80181BF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181960[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181BE0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181BE0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181C18[])(void); + D_80181C18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181960[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181960)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181C28; +extern u16 D_80181C2A; +extern u16 D_80181C2C; +extern s32 D_80181C30; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181C28 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80181C2A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181C2C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181C30, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181C38; + +void func_8015E588(void) { + func_8013C9C4(&D_80181C38); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181960[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181960)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181C4C[])(void); + D_80181C4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181960[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181960[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181C54[])(void); + D_80181C54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80181944; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181944); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181960[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181C5C[])(void); + D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181960[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181960[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181C64[])(void); + D_80181C64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181960[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181C6C; + extern s32 D_80181C7C; + extern s32 D_80181C8C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181960[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C6C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C7C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181960[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C8C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80181C9C[])(void); + D_80181C9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181960[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181960[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181960[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181960[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80181CA8[])(void); + D_80181CA8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181960[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181960[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181960[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181960[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80181CBC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80181CBC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181960[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181960)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181960[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181960[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181D38[])(void); + D_80181D38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181960[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181960)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181D48[])(void); + D_80181D48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181960[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181960[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181960[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181960[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181960[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181960[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181960[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181D50[])(void); + D_80181D50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181960[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181960)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181960[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181960)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181D5C[])(void); + D_80181D5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181960 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181960[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181960[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181960[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181D6C[])(void); + +void func_80160EA4(void *a0) { + D_80181D6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181960[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181960[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80181D9C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80181D9C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181E00; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181E00); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8018E8B8[]; + extern u8 D_80181DCC[]; + extern u8 D_80181DEC[]; + extern u8 D_8018E8C4[]; + extern u8 D_8018E8EC[]; + extern u8 D_8018E904[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8018E8B8[0] = p; + func_80024054(&D_80181DCC, &D_8018E8C4); + func_8001CE28(p, &D_8018E8C4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8018E8B8[1] = p; + func_80024054(&D_80181DEC, &D_8018E8EC); + func_8001CE28(p, &D_8018E8EC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8018E8B8[2] = p; + func_800242D0((s16)func_801620C4(), &D_8018E904, 0x84); + func_8001CE68(p, &D_8018E904); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8018E904, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E8B8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8018E8B8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181E00; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181E00; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181E00; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181E00; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8018E8B8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8018E8B8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181E24[])(void); + +void func_80162330(void *a0) { + D_80181E24[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8018E910[i] via `extern int D_8018E910[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181E30[]; + extern s32 D_80181E48; + extern u8 D_8018E91C[]; + extern u8 D_8018E944[]; + extern u8 D_8018E960[]; + extern int D_8018E910[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8018E910[0] = (s32)item; + func_80024054(D_80181E30, D_8018E91C); + func_8001CE28(item, D_8018E91C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8018E910[1] = (s32)item; + func_80024054(((u8 *)&D_80181E48), D_8018E944); + func_8001CE28(item, D_8018E944); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8018E910[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8018E960, 0x84); + func_8001CE68(item, D_8018E960); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8018E960, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E910[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8018E910; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_801627E8); + + +extern void (*D_80181E6C[])(void); + +void func_80162834(void *a0) { + D_80181E6C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181E5C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181E5C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8018E164[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8018E164, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8018E164[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8018E164, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181E74[])(void); + +void func_80163A58(void *a0) { + D_80181E74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8018E16C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8018E16C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80181EC8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80181EC8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181E90; +extern s16 D_80181EC4; +extern s16 D_80181EC2; +extern s16 D_80181EC0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181E90; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181EC4 = 0x80; + D_80181EC2 = 0x80; + D_80181EC0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181EC4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181EC4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181EC4 - 8; + D_80181EC4 = nv; + D_80181EC2 = nv; + D_80181EC0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181ED4[])(void); + +void func_80164BA0(void *a0) { + D_80181ED4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8018E970; +extern u8 D_8018E971; +extern u8 D_8018E972; +extern u8 D_8018E973; +extern u8 D_8018E974; +extern u8 D_8018E975; +extern u8 D_8018E976; +extern u8 D_8018E977; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8018E970; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8018E971 = 0xf0; + *(u8 *)base = 0xf0; + D_8018E972 = 0xc0; + D_8018E976 = 0; + D_8018E975 = 0; + D_8018E974 = 0; + D_8018E977 = 0; + D_8018E973 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8018E970; +extern u8 D_8018E971; +extern u8 D_8018E972; + +s32 func_80164E40(void) { + u8 *p = &D_8018E970; + if (*p != 0) { + *p -= 0x10; + } + if (D_8018E971 != 0) { + D_8018E971 -= 0x10; + } + if (D_8018E972 != 0) { + D_8018E972 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181EE4[])(void); + +void func_80164EA4(void *a0) { + D_80181EE4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8018E9BC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8018E9BC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8018E9B0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8018E9B0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8018E9B0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8018E9B0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8018E9B0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181EF8[]; + extern u32 D_80181F18, D_80181F1C, D_80181F20, D_80181F24; + extern u32 D_80181F18, D_80181F1C, D_80181F20, D_80181F24; + extern u32 D_80181F18, D_80181F1C, D_80181F20, D_80181F24; + extern u32 D_80181F18, D_80181F1C, D_80181F20, D_80181F24; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181EF8[0x00], p); + ApplyMatrixSV(mat, &D_80181EF8[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181EF8[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181EF8[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181F20; + *(u32 *)(prim + 0x24) = D_80181F18; + *(u32 *)(prim + 0x28) = D_80181F24; + *(u32 *)(prim + 0x2c) = D_80181F1C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181F28[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181F28[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181F28[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181F28[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80181FA4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80181FA4[a1 & 0x7F]; +} + + + +extern s32 D_80181FC4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181FC4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80182040[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80182040[a1 & 0x7F]; +} + + + +extern u8 D_80182060[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182060[a1 & 0x7F]; +} + + + +extern u8 D_80182080[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182080[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801820A0[])(void); + D_801820A0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018211C[])(void); + +void func_80165AC8(void) { + D_8018211C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80182198[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80182198[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8018E174; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8018E174, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801821A4[])(void); + +void func_80166018(void *a0) { + D_801821A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801821AC[])(void); + +void func_801663FC(void *a0) { + D_801821AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182274[])(void); + +void func_80166618(void *a0) { + D_80182274[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182284[])(void); + +void func_80166654(void *a0) { + D_80182284[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8018EA30[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8018EA30[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018EA30). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8018EA30[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8018EA30)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8018EA30[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8018EA30[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801821C8[]; + extern u8 D_801821B4[]; + extern u8 D_801821DC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801821C8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801821B4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801821DC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80167714); + + +extern void (*D_80182294[])(void); + +void func_801678B4(void *a0) { + D_80182294[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801822A0[])(void); + +void func_80167A9C(void *a0) { + D_801822A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801823AC; + extern u8 D_801823C0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801823AC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801823C0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80182200[]; +extern u8 D_80182214[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80182200; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80182214; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801822B8[])(void); + +void func_80168744(void *a0) { + D_801822B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801822A8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801822A8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801822A8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801822C0[])(void); + +void func_801689D8(void *a0) { + D_801822C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801822C8[])(void); + +void func_80168AA8(void *a0) { + D_801822C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801822D0[])(void); + +void func_80168D58(void *a0) { + D_801822D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801822D8[])(void); + +void func_8016901C(void *a0) { + D_801822D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_003/nonmatchings/ov_SC03_003_jr_8015C32C", func_80169228); + + +extern void (*D_801822E0[])(void); + +void func_801693CC(void *a0) { + D_801822E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801822E8[])(void); + +void func_80169830(void *a0) { + D_801822E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018239C[])(void); + +void func_80169B80(void *a0) { + D_8018239C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801822F0[]; + extern u8 D_80182360[]; + extern u8 D_80182390[]; + extern u8 D_8018FA30[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80182390, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801822F0[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8018FA30; + RotMatrixYXZ(rot, D_8018FA30); + func_80048D9C(D_8018FA30, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182360); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801823A4[])(void); + +void func_80169F00(void *a0) { + D_801823A4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80182354[]; +extern char D_80182314[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80182354, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182314); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801823DC[])(void); + +void func_8016A020(void *a0) { + D_801823DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801823AC; + extern u8 D_801823C0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801823AC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801823C0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801823E8[])(void); + +void func_8016A700(void *a0) { + D_801823E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80182430[])(void); + +void func_8016AB30(void *a0) { + D_80182430[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_006/ov_SC03_006_jr_8015AE2C.c b/src/ov_SC03_006/ov_SC03_006_jr_8015AE2C.c index 7fba02283..2674eb6f3 100644 --- a/src/ov_SC03_006/ov_SC03_006_jr_8015AE2C.c +++ b/src/ov_SC03_006/ov_SC03_006_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018EE08[])(void); - -void func_8015C714(void *a0) { - D_8018EE08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018EC7C[])(void*); - extern int D_8018EC20; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018EC20); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018EC7C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018EC7C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018EC7C[])(void*); - extern int D_8018EC20; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018EC20); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018EE18[])(void); - D_8018EE18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018EC7C[])(struct Ent_8015CD20 *); - extern u8 D_8018EC30; - extern u8 D_8018EE20; - extern u8 D_8018EE30; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018EC7C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018EC30); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018EE20); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018EE30); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018EC7C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018EE50[])(void); - D_8018EE50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018EE40; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018EE40 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018EC7C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018EEAC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018EEAC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018DF90[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018DF90; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018EEB4[])(void); - D_8018EEB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018EEC0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018EEC0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018EEC0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018EEC0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018EC7C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018EEC0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018EC40[]; - extern u8 D_8018EC50[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018EC40); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018EC50); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018EEC0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018EEC0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018EEC0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018EEF4[])(void); - D_8018EEF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018EC7C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018EEFC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018EF14[])(void); - D_8018EF14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018EC7C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018EEFC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018EF34[])(void); - D_8018EF34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018EC7C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018EC7C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018EF44; -extern u16 D_8018EF46; -extern u16 D_8018EF48; -extern s32 D_8018EF4C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018EF44 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018EF46 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018EF48 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018EF4C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018EF54; - -void func_8015E588(void) { - func_8013C9C4(&D_8018EF54); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018EC7C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018EC7C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018EF68[])(void); - D_8018EF68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018EC7C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018EC7C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018EF70[])(void); - D_8018EF70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018EC60; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018EC60); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018EC7C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018EF78[])(void); - D_8018EF78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018EC7C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018EC7C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018EF80[])(void); - D_8018EF80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018EC7C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018EF88; - extern s32 D_8018EF98; - extern s32 D_8018EFA8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018EC7C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018EF88); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018EF98); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018EC7C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018EFA8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018EFB8[])(void); - D_8018EFB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018EC7C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018EC7C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018EC7C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018EC7C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018EFC4[])(void); - D_8018EFC4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018EC7C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018EC7C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018EC7C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018EC7C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018EFD8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018EFD8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018EC7C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018EC7C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018EC7C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018EC7C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018F054[])(void); - D_8018F054[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018EC7C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018EC7C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018F064[])(void); - D_8018F064[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018EC7C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018EC7C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018EC7C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018EC7C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018EC7C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018EC7C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018EC7C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018F06C[])(void); - D_8018F06C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018EC7C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018EC7C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018EC7C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018F078[])(void); - D_8018F078[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018EC7C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018EC7C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018EC7C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018EC7C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018F088[])(void); - -void func_80160EA4(void *a0) { - D_8018F088[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018EC7C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018EC7C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018F0B8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018F0B8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018F11C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018F11C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801F6230[]; - extern u8 D_8018F0E8[]; - extern u8 D_8018F108[]; - extern u8 D_801F623C[]; - extern u8 D_801F6264[]; - extern u8 D_801F627C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801F6230[0] = p; - func_80024054(&D_8018F0E8, &D_801F623C); - func_8001CE28(p, &D_801F623C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801F6230[1] = p; - func_80024054(&D_8018F108, &D_801F6264); - func_8001CE28(p, &D_801F6264); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801F6230[2] = p; - func_800242D0((s16)func_801620C4(), &D_801F627C, 0x84); - func_8001CE68(p, &D_801F627C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801F627C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801F6230[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801F6230; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018F11C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018F11C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018F11C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018F11C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801F6230[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801F6230; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018F140[])(void); - -void func_80162330(void *a0) { - D_8018F140[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801F6288[i] via `extern int D_801F6288[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018F14C[]; - extern s32 D_8018F164; - extern u8 D_801F6294[]; - extern u8 D_801F62BC[]; - extern u8 D_801F62D8[]; - extern int D_801F6288[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801F6288[0] = (s32)item; - func_80024054(D_8018F14C, D_801F6294); - func_8001CE28(item, D_801F6294); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801F6288[1] = (s32)item; - func_80024054(((u8 *)&D_8018F164), D_801F62BC); - func_8001CE28(item, D_801F62BC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801F6288[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801F62D8, 0x84); - func_8001CE68(item, D_801F62D8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801F62D8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801F6288[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801F6288; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018F188[])(void); - -void func_80162834(void *a0) { - D_8018F188[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018F178; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018F178, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801F5A20[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801F5A20, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801F5A20[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801F5A20, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018F190[])(void); - -void func_80163A58(void *a0) { - D_8018F190[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801F5A28; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801F5A28; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018F1E4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018F1E4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018F1AC; -extern s16 D_8018F1E0; -extern s16 D_8018F1DE; -extern s16 D_8018F1DC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018F1AC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018F1E0 = 0x80; - D_8018F1DE = 0x80; - D_8018F1DC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018F1E0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018F1E0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018F1E0 - 8; - D_8018F1E0 = nv; - D_8018F1DE = nv; - D_8018F1DC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018F1F0[])(void); - -void func_80164BA0(void *a0) { - D_8018F1F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801F62E8; -extern u8 D_801F62E9; -extern u8 D_801F62EA; -extern u8 D_801F62EB; -extern u8 D_801F62EC; -extern u8 D_801F62ED; -extern u8 D_801F62EE; -extern u8 D_801F62EF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801F62E8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801F62E9 = 0xf0; - *(u8 *)base = 0xf0; - D_801F62EA = 0xc0; - D_801F62EE = 0; - D_801F62ED = 0; - D_801F62EC = 0; - D_801F62EF = 0; - D_801F62EB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801F62E8; -extern u8 D_801F62E9; -extern u8 D_801F62EA; - -s32 func_80164E40(void) { - u8 *p = &D_801F62E8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801F62E9 != 0) { - D_801F62E9 -= 0x10; - } - if (D_801F62EA != 0) { - D_801F62EA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018F200[])(void); - -void func_80164EA4(void *a0) { - D_8018F200[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801F6334[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801F6334[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801F6328[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801F6328[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801F6328[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801F6328; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801F6328; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018F214[]; - extern u32 D_8018F234, D_8018F238, D_8018F23C, D_8018F240; - extern u32 D_8018F234, D_8018F238, D_8018F23C, D_8018F240; - extern u32 D_8018F234, D_8018F238, D_8018F23C, D_8018F240; - extern u32 D_8018F234, D_8018F238, D_8018F23C, D_8018F240; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018F214[0x00], p); - ApplyMatrixSV(mat, &D_8018F214[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018F214[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018F214[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018F23C; - *(u32 *)(prim + 0x24) = D_8018F234; - *(u32 *)(prim + 0x28) = D_8018F240; - *(u32 *)(prim + 0x2c) = D_8018F238; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018F244[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018F244[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018F244[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018F244[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018F2C0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018F2C0[a1 & 0x7F]; -} - - - -extern s32 D_8018F2E0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018F2E0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018F35C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018F35C[a1 & 0x7F]; -} - - - -extern u8 D_8018F37C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018F37C[a1 & 0x7F]; -} - - - -extern u8 D_8018F39C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018F39C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018F3BC[])(void); - D_8018F3BC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018F438[])(void); - -void func_80165AC8(void) { - D_8018F438[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018F4B4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018F4B4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801F5A30; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801F5A30, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018F4C0[])(void); - -void func_80166018(void *a0) { - D_8018F4C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018F4C8[])(void); - -void func_801663FC(void *a0) { - D_8018F4C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018F590[])(void); - -void func_80166618(void *a0) { - D_8018F590[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018F5A0[])(void); - -void func_80166654(void *a0) { - D_8018F5A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801F63A8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801F63A8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801F63A8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801F63A8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801F63A8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801F63A8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801F63A8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018F4E4[]; - extern u8 D_8018F4D0[]; - extern u8 D_8018F4F8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018F4E4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018F4D0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018F4F8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80167714); - - -extern void (*D_8018F5B0[])(void); - -void func_801678B4(void *a0) { - D_8018F5B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018F5BC[])(void); - -void func_80167A9C(void *a0) { - D_8018F5BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018F6C8; - extern u8 D_8018F6DC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018F6C8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018F6DC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018F51C[]; -extern u8 D_8018F530[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018F51C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018F530; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018F5D4[])(void); - -void func_80168744(void *a0) { - D_8018F5D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018F5C4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018F5C4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018F5C4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018F5DC[])(void); - -void func_801689D8(void *a0) { - D_8018F5DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018F5E4[])(void); - -void func_80168AA8(void *a0) { - D_8018F5E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018F5EC[])(void); - -void func_80168D58(void *a0) { - D_8018F5EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018F5F4[])(void); - -void func_8016901C(void *a0) { - D_8018F5F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015AE2C", func_80169228); - - -extern void (*D_8018F5FC[])(void); - -void func_801693CC(void *a0) { - D_8018F5FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018F604[])(void); - -void func_80169830(void *a0) { - D_8018F604[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018F6B8[])(void); - -void func_80169B80(void *a0) { - D_8018F6B8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018F60C[]; - extern u8 D_8018F67C[]; - extern u8 D_8018F6AC[]; - extern u8 D_801F7770[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018F6AC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018F60C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801F7770; - RotMatrixYXZ(rot, D_801F7770); - func_80048D9C(D_801F7770, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018F67C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018F6C0[])(void); - -void func_80169F00(void *a0) { - D_8018F6C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018F670[]; -extern char D_8018F630[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018F670, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018F630); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018F6F8[])(void); - -void func_8016A020(void *a0) { - D_8018F6F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018F6C8; - extern u8 D_8018F6DC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018F6C8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018F6DC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018F704[])(void); - -void func_8016A700(void *a0) { - D_8018F704[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018F74C[])(void); - -void func_8016AB30(void *a0) { - D_8018F74C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c b/src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c new file mode 100644 index 000000000..c6c0dc157 --- /dev/null +++ b/src/ov_SC03_006/ov_SC03_006_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018EB18; +extern u8 D_8018EA88; +extern u8 D_8018EA64; +extern u8 D_8018EA40; +extern u8 D_8018EAF4; +extern u8 D_8018EAD0; +extern u8 D_8018EAAC; +extern u8 D_8018EA1C; +extern void func_80145934(void); +extern u8 D_8018EBA8; +extern u8 D_8018EB84; +extern u8 D_8018EB60; +extern u8 D_8018EB3C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018DFA0[]; +extern unsigned char D_8018DFD0[]; +extern unsigned char D_8018E020[]; +extern unsigned char D_8018E050[]; +extern unsigned char D_8018E080[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018E0D0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018E198[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018E220[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018E228; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801F61D8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801F61DC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018E258; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018E300[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018E324[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018E314; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018E338[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018E344[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018E354[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018E36C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018E35C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018E380[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018E39C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018E38C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018E3B0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018E3C4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018E3D8; +extern void (*D_8018E400[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018E3E0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018E44C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018E450[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018E8B4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018E8C4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801F6210; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018E8EC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018E8CC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018E8DC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018E92C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018E934[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018E900; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018E940[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018E910; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801F6218; +extern s32 D_801F6224; +extern s32 D_801F6228; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018E97C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018E950[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801F6220; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018EBCC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018E9EC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018EC70[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018EDC4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018EBE0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018EDCC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018EBF0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018EC10; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018EDD4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018EDFC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018EC7C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018EE08[])(void); + +void func_8015C714(void *a0) { + D_8018EE08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018EC7C[])(void*); + extern int D_8018EC20; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018EC20); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018EC7C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018EC7C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018EC7C[])(void*); + extern int D_8018EC20; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018EC20); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018EE18[])(void); + D_8018EE18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018EC7C[])(struct Ent_8015CD20 *); + extern u8 D_8018EC30; + extern u8 D_8018EE20; + extern u8 D_8018EE30; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018EC7C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018EC30); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018EE20); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018EE30); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018EC7C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018EE50[])(void); + D_8018EE50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018EE40; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018EE40 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018EC7C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018EEAC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018EEAC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018DF90[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018DF90; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018EEB4[])(void); + D_8018EEB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018EEC0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018EEC0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018EEC0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018EEC0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018EC7C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018EEC0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018EC40[]; + extern u8 D_8018EC50[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018EC40); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018EC50); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018EEC0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018EEC0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018EEC0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018EEF4[])(void); + D_8018EEF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018EC7C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018EEFC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018EF14[])(void); + D_8018EF14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018EC7C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018EEFC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018EEFC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018EF34[])(void); + D_8018EF34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018EC7C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018EC7C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018EF44; +extern u16 D_8018EF46; +extern u16 D_8018EF48; +extern s32 D_8018EF4C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018EF44 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018EF46 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018EF48 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018EF4C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018EF54; + +void func_8015E588(void) { + func_8013C9C4(&D_8018EF54); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018EC7C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018EC7C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018EF68[])(void); + D_8018EF68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018EC7C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018EC7C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018EF70[])(void); + D_8018EF70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018EC60; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018EC60); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018EC7C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018EF78[])(void); + D_8018EF78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018EC7C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018EC7C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018EF80[])(void); + D_8018EF80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018EC7C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018EF88; + extern s32 D_8018EF98; + extern s32 D_8018EFA8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018EF88); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018EF98); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018EC7C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018EFA8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018EFB8[])(void); + D_8018EFB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018EC7C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018EC7C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018EC7C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018EC7C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018EFC4[])(void); + D_8018EFC4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018EC7C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018EC7C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018EC7C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018EC7C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018EFD8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018EFD8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018EC7C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018EC7C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018EC7C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018EC7C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018F054[])(void); + D_8018F054[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018EC7C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018EC7C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018F064[])(void); + D_8018F064[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018EC7C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018EC7C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018EC7C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018EC7C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018EC7C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018EC7C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018EC7C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018F06C[])(void); + D_8018F06C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018EC7C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018EC7C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018EC7C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018EC7C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018F078[])(void); + D_8018F078[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018EC7C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018EC7C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018EC7C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018EC7C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018F088[])(void); + +void func_80160EA4(void *a0) { + D_8018F088[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018EC7C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018EC7C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018F0B8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018F0B8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018F11C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018F11C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801F6230[]; + extern u8 D_8018F0E8[]; + extern u8 D_8018F108[]; + extern u8 D_801F623C[]; + extern u8 D_801F6264[]; + extern u8 D_801F627C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801F6230[0] = p; + func_80024054(&D_8018F0E8, &D_801F623C); + func_8001CE28(p, &D_801F623C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801F6230[1] = p; + func_80024054(&D_8018F108, &D_801F6264); + func_8001CE28(p, &D_801F6264); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801F6230[2] = p; + func_800242D0((s16)func_801620C4(), &D_801F627C, 0x84); + func_8001CE68(p, &D_801F627C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801F627C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801F6230[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801F6230; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018F11C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018F11C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018F11C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018F11C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801F6230[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801F6230; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018F140[])(void); + +void func_80162330(void *a0) { + D_8018F140[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801F6288[i] via `extern int D_801F6288[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018F14C[]; + extern s32 D_8018F164; + extern u8 D_801F6294[]; + extern u8 D_801F62BC[]; + extern u8 D_801F62D8[]; + extern int D_801F6288[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801F6288[0] = (s32)item; + func_80024054(D_8018F14C, D_801F6294); + func_8001CE28(item, D_801F6294); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801F6288[1] = (s32)item; + func_80024054(((u8 *)&D_8018F164), D_801F62BC); + func_8001CE28(item, D_801F62BC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801F6288[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801F62D8, 0x84); + func_8001CE68(item, D_801F62D8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801F62D8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801F6288[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801F6288; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_801627E8); + + +extern void (*D_8018F188[])(void); + +void func_80162834(void *a0) { + D_8018F188[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018F178; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018F178, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801F5A20[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801F5A20, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801F5A20[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801F5A20, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018F190[])(void); + +void func_80163A58(void *a0) { + D_8018F190[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801F5A28; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801F5A28; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018F1E4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018F1E4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018F1AC; +extern s16 D_8018F1E0; +extern s16 D_8018F1DE; +extern s16 D_8018F1DC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018F1AC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018F1E0 = 0x80; + D_8018F1DE = 0x80; + D_8018F1DC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018F1E0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018F1E0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018F1E0 - 8; + D_8018F1E0 = nv; + D_8018F1DE = nv; + D_8018F1DC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018F1F0[])(void); + +void func_80164BA0(void *a0) { + D_8018F1F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801F62E8; +extern u8 D_801F62E9; +extern u8 D_801F62EA; +extern u8 D_801F62EB; +extern u8 D_801F62EC; +extern u8 D_801F62ED; +extern u8 D_801F62EE; +extern u8 D_801F62EF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801F62E8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801F62E9 = 0xf0; + *(u8 *)base = 0xf0; + D_801F62EA = 0xc0; + D_801F62EE = 0; + D_801F62ED = 0; + D_801F62EC = 0; + D_801F62EF = 0; + D_801F62EB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801F62E8; +extern u8 D_801F62E9; +extern u8 D_801F62EA; + +s32 func_80164E40(void) { + u8 *p = &D_801F62E8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801F62E9 != 0) { + D_801F62E9 -= 0x10; + } + if (D_801F62EA != 0) { + D_801F62EA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018F200[])(void); + +void func_80164EA4(void *a0) { + D_8018F200[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801F6334[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801F6334[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801F6328[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801F6328[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801F6328[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801F6328; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801F6328; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018F214[]; + extern u32 D_8018F234, D_8018F238, D_8018F23C, D_8018F240; + extern u32 D_8018F234, D_8018F238, D_8018F23C, D_8018F240; + extern u32 D_8018F234, D_8018F238, D_8018F23C, D_8018F240; + extern u32 D_8018F234, D_8018F238, D_8018F23C, D_8018F240; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018F214[0x00], p); + ApplyMatrixSV(mat, &D_8018F214[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018F214[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018F214[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018F23C; + *(u32 *)(prim + 0x24) = D_8018F234; + *(u32 *)(prim + 0x28) = D_8018F240; + *(u32 *)(prim + 0x2c) = D_8018F238; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018F244[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018F244[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018F244[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018F244[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018F2C0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018F2C0[a1 & 0x7F]; +} + + + +extern s32 D_8018F2E0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018F2E0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018F35C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018F35C[a1 & 0x7F]; +} + + + +extern u8 D_8018F37C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018F37C[a1 & 0x7F]; +} + + + +extern u8 D_8018F39C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018F39C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018F3BC[])(void); + D_8018F3BC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018F438[])(void); + +void func_80165AC8(void) { + D_8018F438[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018F4B4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018F4B4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801F5A30; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801F5A30, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018F4C0[])(void); + +void func_80166018(void *a0) { + D_8018F4C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018F4C8[])(void); + +void func_801663FC(void *a0) { + D_8018F4C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018F590[])(void); + +void func_80166618(void *a0) { + D_8018F590[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018F5A0[])(void); + +void func_80166654(void *a0) { + D_8018F5A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801F63A8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801F63A8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801F63A8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801F63A8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801F63A8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801F63A8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801F63A8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018F4E4[]; + extern u8 D_8018F4D0[]; + extern u8 D_8018F4F8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018F4E4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018F4D0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018F4F8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80167714); + + +extern void (*D_8018F5B0[])(void); + +void func_801678B4(void *a0) { + D_8018F5B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018F5BC[])(void); + +void func_80167A9C(void *a0) { + D_8018F5BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018F6C8; + extern u8 D_8018F6DC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018F6C8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018F6DC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018F51C[]; +extern u8 D_8018F530[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018F51C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018F530; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018F5D4[])(void); + +void func_80168744(void *a0) { + D_8018F5D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018F5C4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018F5C4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018F5C4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018F5DC[])(void); + +void func_801689D8(void *a0) { + D_8018F5DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018F5E4[])(void); + +void func_80168AA8(void *a0) { + D_8018F5E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018F5EC[])(void); + +void func_80168D58(void *a0) { + D_8018F5EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018F5F4[])(void); + +void func_8016901C(void *a0) { + D_8018F5F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_006/nonmatchings/ov_SC03_006_jr_8015C32C", func_80169228); + + +extern void (*D_8018F5FC[])(void); + +void func_801693CC(void *a0) { + D_8018F5FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018F604[])(void); + +void func_80169830(void *a0) { + D_8018F604[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018F6B8[])(void); + +void func_80169B80(void *a0) { + D_8018F6B8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018F60C[]; + extern u8 D_8018F67C[]; + extern u8 D_8018F6AC[]; + extern u8 D_801F7770[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018F6AC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018F60C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801F7770; + RotMatrixYXZ(rot, D_801F7770); + func_80048D9C(D_801F7770, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018F67C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018F6C0[])(void); + +void func_80169F00(void *a0) { + D_8018F6C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018F670[]; +extern char D_8018F630[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018F670, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018F630); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018F6F8[])(void); + +void func_8016A020(void *a0) { + D_8018F6F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018F6C8; + extern u8 D_8018F6DC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018F6C8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018F6DC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018F704[])(void); + +void func_8016A700(void *a0) { + D_8018F704[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018F74C[])(void); + +void func_8016AB30(void *a0) { + D_8018F74C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_007/ov_SC03_007_jr_8015AE2C.c b/src/ov_SC03_007/ov_SC03_007_jr_8015AE2C.c index 8d4309350..53095da41 100644 --- a/src/ov_SC03_007/ov_SC03_007_jr_8015AE2C.c +++ b/src/ov_SC03_007/ov_SC03_007_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80189C00[])(void); - -void func_8015C714(void *a0) { - D_80189C00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80189A74[])(void*); - extern int D_80189A18; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80189A74)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80189A74)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189A18); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80189A74[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80189A74[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80189A74[])(void*); - extern int D_80189A18; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80189A74)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189A18); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80189A74)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80189C10[])(void); - D_80189C10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80189A74[])(struct Ent_8015CD20 *); - extern u8 D_80189A28; - extern u8 D_80189C18; - extern u8 D_80189C28; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80189A74[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189A28); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189C18); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189C28); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80189A74[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80189C48[])(void); - D_80189C48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80189C38; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80189C38 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80189A74[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80189CA4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80189CA4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80188D88[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80188D88; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80189CAC[])(void); - D_80189CAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80189CB8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80189CB8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80189CB8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80189CB8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80189A74[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80189CB8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80189A38[]; - extern u8 D_80189A48[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189A38); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189A48); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80189CB8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80189CB8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80189CB8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80189CEC[])(void); - D_80189CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80189A74[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80189CF4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80189D0C[])(void); - D_80189D0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80189A74[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80189CF4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80189D2C[])(void); - D_80189D2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80189A74[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80189A74)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80189D3C; -extern u16 D_80189D3E; -extern u16 D_80189D40; -extern s32 D_80189D44; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80189D3C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80189D3E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80189D40 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80189D44, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80189D4C; - -void func_8015E588(void) { - func_8013C9C4(&D_80189D4C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80189A74[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80189A74)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80189D60[])(void); - D_80189D60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80189A74[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80189A74[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80189D68[])(void); - D_80189D68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80189A58; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80189A58); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80189A74[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80189D70[])(void); - D_80189D70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80189A74[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80189A74[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80189D78[])(void); - D_80189D78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80189A74[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80189D80; - extern s32 D_80189D90; - extern s32 D_80189DA0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80189A74[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189D80); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189D90); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80189A74[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189DA0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80189DB0[])(void); - D_80189DB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80189A74[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80189A74[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80189A74[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80189A74[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80189DBC[])(void); - D_80189DBC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80189A74[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80189A74[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80189A74[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80189A74[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80189DD0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80189DD0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80189A74[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80189A74)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80189A74[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80189A74[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80189E4C[])(void); - D_80189E4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80189A74[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80189A74)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80189E5C[])(void); - D_80189E5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80189A74[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80189A74[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80189A74[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80189A74[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80189A74[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80189A74[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80189A74[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80189E64[])(void); - D_80189E64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80189A74[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80189A74)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80189A74[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80189A74)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80189E70[])(void); - D_80189E70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80189A74 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80189A74[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80189A74[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80189A74[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80189E80[])(void); - -void func_80160EA4(void *a0) { - D_80189E80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80189A74[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80189A74[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80189EB0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80189EB0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80189F14; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80189F14); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E8B88[]; - extern u8 D_80189EE0[]; - extern u8 D_80189F00[]; - extern u8 D_801E8B94[]; - extern u8 D_801E8BBC[]; - extern u8 D_801E8BD4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E8B88[0] = p; - func_80024054(&D_80189EE0, &D_801E8B94); - func_8001CE28(p, &D_801E8B94); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E8B88[1] = p; - func_80024054(&D_80189F00, &D_801E8BBC); - func_8001CE28(p, &D_801E8BBC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E8B88[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E8BD4, 0x84); - func_8001CE68(p, &D_801E8BD4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E8BD4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E8B88[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E8B88; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80189F14; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80189F14; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80189F14; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80189F14; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E8B88[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E8B88; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80189F38[])(void); - -void func_80162330(void *a0) { - D_80189F38[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E8BE0[i] via `extern int D_801E8BE0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80189F44[]; - extern s32 D_80189F5C; - extern u8 D_801E8BEC[]; - extern u8 D_801E8C14[]; - extern u8 D_801E8C30[]; - extern int D_801E8BE0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E8BE0[0] = (s32)item; - func_80024054(D_80189F44, D_801E8BEC); - func_8001CE28(item, D_801E8BEC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E8BE0[1] = (s32)item; - func_80024054(((u8 *)&D_80189F5C), D_801E8C14); - func_8001CE28(item, D_801E8C14); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E8BE0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E8C30, 0x84); - func_8001CE68(item, D_801E8C30); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E8C30, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E8BE0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E8BE0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_801627E8); - - -extern void (*D_80189F80[])(void); - -void func_80162834(void *a0) { - D_80189F80[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80189F70; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80189F70, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E83A8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E83A8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E83A8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E83A8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80189F88[])(void); - -void func_80163A58(void *a0) { - D_80189F88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E83B0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E83B0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80189FDC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80189FDC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80189FA4; -extern s16 D_80189FD8; -extern s16 D_80189FD6; -extern s16 D_80189FD4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80189FA4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80189FD8 = 0x80; - D_80189FD6 = 0x80; - D_80189FD4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80189FD8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80189FD8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80189FD8 - 8; - D_80189FD8 = nv; - D_80189FD6 = nv; - D_80189FD4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80189FE8[])(void); - -void func_80164BA0(void *a0) { - D_80189FE8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E8C40; -extern u8 D_801E8C41; -extern u8 D_801E8C42; -extern u8 D_801E8C43; -extern u8 D_801E8C44; -extern u8 D_801E8C45; -extern u8 D_801E8C46; -extern u8 D_801E8C47; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E8C40; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E8C41 = 0xf0; - *(u8 *)base = 0xf0; - D_801E8C42 = 0xc0; - D_801E8C46 = 0; - D_801E8C45 = 0; - D_801E8C44 = 0; - D_801E8C47 = 0; - D_801E8C43 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E8C40; -extern u8 D_801E8C41; -extern u8 D_801E8C42; - -s32 func_80164E40(void) { - u8 *p = &D_801E8C40; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E8C41 != 0) { - D_801E8C41 -= 0x10; - } - if (D_801E8C42 != 0) { - D_801E8C42 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80189FF8[])(void); - -void func_80164EA4(void *a0) { - D_80189FF8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E8C8C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E8C8C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E8C80[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E8C80[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E8C80[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E8C80; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E8C80; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018A00C[]; - extern u32 D_8018A02C, D_8018A030, D_8018A034, D_8018A038; - extern u32 D_8018A02C, D_8018A030, D_8018A034, D_8018A038; - extern u32 D_8018A02C, D_8018A030, D_8018A034, D_8018A038; - extern u32 D_8018A02C, D_8018A030, D_8018A034, D_8018A038; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018A00C[0x00], p); - ApplyMatrixSV(mat, &D_8018A00C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018A00C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018A00C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018A034; - *(u32 *)(prim + 0x24) = D_8018A02C; - *(u32 *)(prim + 0x28) = D_8018A038; - *(u32 *)(prim + 0x2c) = D_8018A030; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018A03C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018A03C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018A03C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018A03C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018A0B8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018A0B8[a1 & 0x7F]; -} - - - -extern s32 D_8018A0D8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018A0D8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018A154[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018A154[a1 & 0x7F]; -} - - - -extern u8 D_8018A174[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018A174[a1 & 0x7F]; -} - - - -extern u8 D_8018A194[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018A194[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018A1B4[])(void); - D_8018A1B4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018A230[])(void); - -void func_80165AC8(void) { - D_8018A230[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018A2AC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018A2AC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E83B8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E83B8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018A2B8[])(void); - -void func_80166018(void *a0) { - D_8018A2B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018A2C0[])(void); - -void func_801663FC(void *a0) { - D_8018A2C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018A388[])(void); - -void func_80166618(void *a0) { - D_8018A388[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018A398[])(void); - -void func_80166654(void *a0) { - D_8018A398[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E8D00[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E8D00[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E8D00). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E8D00[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E8D00)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E8D00[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E8D00[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018A2DC[]; - extern u8 D_8018A2C8[]; - extern u8 D_8018A2F0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018A2DC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018A2C8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018A2F0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80167714); - - -extern void (*D_8018A3A8[])(void); - -void func_801678B4(void *a0) { - D_8018A3A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018A3B4[])(void); - -void func_80167A9C(void *a0) { - D_8018A3B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018A4C0; - extern u8 D_8018A4D4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018A4C0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018A4D4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018A314[]; -extern u8 D_8018A328[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018A314; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018A328; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018A3CC[])(void); - -void func_80168744(void *a0) { - D_8018A3CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018A3BC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018A3BC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018A3BC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018A3D4[])(void); - -void func_801689D8(void *a0) { - D_8018A3D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018A3DC[])(void); - -void func_80168AA8(void *a0) { - D_8018A3DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018A3E4[])(void); - -void func_80168D58(void *a0) { - D_8018A3E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018A3EC[])(void); - -void func_8016901C(void *a0) { - D_8018A3EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015AE2C", func_80169228); - - -extern void (*D_8018A3F4[])(void); - -void func_801693CC(void *a0) { - D_8018A3F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018A3FC[])(void); - -void func_80169830(void *a0) { - D_8018A3FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018A4B0[])(void); - -void func_80169B80(void *a0) { - D_8018A4B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018A404[]; - extern u8 D_8018A474[]; - extern u8 D_8018A4A4[]; - extern u8 D_801EB180[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018A4A4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018A404[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801EB180; - RotMatrixYXZ(rot, D_801EB180); - func_80048D9C(D_801EB180, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018A474); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018A4B8[])(void); - -void func_80169F00(void *a0) { - D_8018A4B8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018A468[]; -extern char D_8018A428[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018A468, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018A428); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018A4F0[])(void); - -void func_8016A020(void *a0) { - D_8018A4F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018A4C0; - extern u8 D_8018A4D4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018A4C0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018A4D4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018A4FC[])(void); - -void func_8016A700(void *a0) { - D_8018A4FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018A544[])(void); - -void func_8016AB30(void *a0) { - D_8018A544[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c b/src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c new file mode 100644 index 000000000..48d3d085e --- /dev/null +++ b/src/ov_SC03_007/ov_SC03_007_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80189910; +extern u8 D_80189880; +extern u8 D_8018985C; +extern u8 D_80189838; +extern u8 D_801898EC; +extern u8 D_801898C8; +extern u8 D_801898A4; +extern u8 D_80189814; +extern void func_80145934(void); +extern u8 D_801899A0; +extern u8 D_8018997C; +extern u8 D_80189958; +extern u8 D_80189934; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80188D98[]; +extern unsigned char D_80188DC8[]; +extern unsigned char D_80188E18[]; +extern unsigned char D_80188E48[]; +extern unsigned char D_80188E78[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80188EC8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80188F90[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80189018[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80189020; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E8B30; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E8B34; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80189050; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801890F8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018911C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018910C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80189130[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018913C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018914C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80189164[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80189154; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80189178[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80189194[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80189184; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801891A8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801891BC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801891D0; +extern void (*D_801891F8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801891D8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80189244[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80189248[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801896AC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801896BC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E8B68; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801896E4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801896C4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801896D4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80189724[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018972C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801896F8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80189738[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80189708; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E8B70; +extern s32 D_801E8B7C; +extern s32 D_801E8B80; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80189774[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80189748[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E8B78; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801899C4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801897E4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80189A68[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80189BBC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801899D8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80189BC4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801899E8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80189A08; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80189BCC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80189BF4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80189A74[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80189C00[])(void); + +void func_8015C714(void *a0) { + D_80189C00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80189A74[])(void*); + extern int D_80189A18; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80189A74)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80189A74)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189A18); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80189A74[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80189A74[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80189A74[])(void*); + extern int D_80189A18; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80189A74)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189A18); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80189A74)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80189C10[])(void); + D_80189C10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80189A74[])(struct Ent_8015CD20 *); + extern u8 D_80189A28; + extern u8 D_80189C18; + extern u8 D_80189C28; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80189A74[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189A28); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189C18); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189C28); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80189A74[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80189C48[])(void); + D_80189C48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80189C38; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80189C38 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80189A74[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80189CA4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80189CA4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80188D88[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80188D88; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80189CAC[])(void); + D_80189CAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80189CB8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80189CB8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80189CB8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80189CB8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80189A74[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80189CB8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80189A38[]; + extern u8 D_80189A48[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189A38); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189A48); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80189CB8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80189CB8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80189CB8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80189CEC[])(void); + D_80189CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80189A74[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80189CF4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80189D0C[])(void); + D_80189D0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80189A74[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80189CF4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80189CF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80189D2C[])(void); + D_80189D2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80189A74[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80189A74)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80189D3C; +extern u16 D_80189D3E; +extern u16 D_80189D40; +extern s32 D_80189D44; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80189D3C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80189D3E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80189D40 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80189D44, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80189D4C; + +void func_8015E588(void) { + func_8013C9C4(&D_80189D4C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80189A74[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80189A74)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80189D60[])(void); + D_80189D60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80189A74[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80189A74[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80189D68[])(void); + D_80189D68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80189A58; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80189A58); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80189A74[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80189D70[])(void); + D_80189D70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80189A74[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80189A74[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80189D78[])(void); + D_80189D78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80189A74[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80189D80; + extern s32 D_80189D90; + extern s32 D_80189DA0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189D80); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189D90); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80189A74[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189DA0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80189DB0[])(void); + D_80189DB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80189A74[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80189A74[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80189A74[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80189A74[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80189DBC[])(void); + D_80189DBC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80189A74[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80189A74[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80189A74[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80189A74[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80189DD0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80189DD0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80189A74[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80189A74)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80189A74[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80189A74[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80189E4C[])(void); + D_80189E4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80189A74[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80189A74)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80189E5C[])(void); + D_80189E5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80189A74[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80189A74[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80189A74[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80189A74[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80189A74[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80189A74[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80189A74[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80189E64[])(void); + D_80189E64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80189A74[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80189A74)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80189A74[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80189A74)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80189E70[])(void); + D_80189E70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80189A74 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80189A74[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80189A74[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80189A74[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80189E80[])(void); + +void func_80160EA4(void *a0) { + D_80189E80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80189A74[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80189A74[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80189EB0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80189EB0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80189F14; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80189F14); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E8B88[]; + extern u8 D_80189EE0[]; + extern u8 D_80189F00[]; + extern u8 D_801E8B94[]; + extern u8 D_801E8BBC[]; + extern u8 D_801E8BD4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E8B88[0] = p; + func_80024054(&D_80189EE0, &D_801E8B94); + func_8001CE28(p, &D_801E8B94); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E8B88[1] = p; + func_80024054(&D_80189F00, &D_801E8BBC); + func_8001CE28(p, &D_801E8BBC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E8B88[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E8BD4, 0x84); + func_8001CE68(p, &D_801E8BD4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E8BD4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E8B88[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E8B88; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80189F14; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80189F14; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80189F14; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80189F14; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E8B88[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E8B88; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80189F38[])(void); + +void func_80162330(void *a0) { + D_80189F38[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E8BE0[i] via `extern int D_801E8BE0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80189F44[]; + extern s32 D_80189F5C; + extern u8 D_801E8BEC[]; + extern u8 D_801E8C14[]; + extern u8 D_801E8C30[]; + extern int D_801E8BE0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E8BE0[0] = (s32)item; + func_80024054(D_80189F44, D_801E8BEC); + func_8001CE28(item, D_801E8BEC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E8BE0[1] = (s32)item; + func_80024054(((u8 *)&D_80189F5C), D_801E8C14); + func_8001CE28(item, D_801E8C14); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E8BE0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E8C30, 0x84); + func_8001CE68(item, D_801E8C30); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E8C30, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E8BE0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E8BE0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_801627E8); + + +extern void (*D_80189F80[])(void); + +void func_80162834(void *a0) { + D_80189F80[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80189F70; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80189F70, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E83A8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E83A8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E83A8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E83A8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80189F88[])(void); + +void func_80163A58(void *a0) { + D_80189F88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E83B0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E83B0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80189FDC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80189FDC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80189FA4; +extern s16 D_80189FD8; +extern s16 D_80189FD6; +extern s16 D_80189FD4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80189FA4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80189FD8 = 0x80; + D_80189FD6 = 0x80; + D_80189FD4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80189FD8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80189FD8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80189FD8 - 8; + D_80189FD8 = nv; + D_80189FD6 = nv; + D_80189FD4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80189FE8[])(void); + +void func_80164BA0(void *a0) { + D_80189FE8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E8C40; +extern u8 D_801E8C41; +extern u8 D_801E8C42; +extern u8 D_801E8C43; +extern u8 D_801E8C44; +extern u8 D_801E8C45; +extern u8 D_801E8C46; +extern u8 D_801E8C47; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E8C40; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E8C41 = 0xf0; + *(u8 *)base = 0xf0; + D_801E8C42 = 0xc0; + D_801E8C46 = 0; + D_801E8C45 = 0; + D_801E8C44 = 0; + D_801E8C47 = 0; + D_801E8C43 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E8C40; +extern u8 D_801E8C41; +extern u8 D_801E8C42; + +s32 func_80164E40(void) { + u8 *p = &D_801E8C40; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E8C41 != 0) { + D_801E8C41 -= 0x10; + } + if (D_801E8C42 != 0) { + D_801E8C42 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80189FF8[])(void); + +void func_80164EA4(void *a0) { + D_80189FF8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E8C8C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E8C8C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E8C80[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E8C80[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E8C80[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E8C80; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E8C80; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018A00C[]; + extern u32 D_8018A02C, D_8018A030, D_8018A034, D_8018A038; + extern u32 D_8018A02C, D_8018A030, D_8018A034, D_8018A038; + extern u32 D_8018A02C, D_8018A030, D_8018A034, D_8018A038; + extern u32 D_8018A02C, D_8018A030, D_8018A034, D_8018A038; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018A00C[0x00], p); + ApplyMatrixSV(mat, &D_8018A00C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018A00C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018A00C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018A034; + *(u32 *)(prim + 0x24) = D_8018A02C; + *(u32 *)(prim + 0x28) = D_8018A038; + *(u32 *)(prim + 0x2c) = D_8018A030; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018A03C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018A03C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018A03C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018A03C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018A0B8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018A0B8[a1 & 0x7F]; +} + + + +extern s32 D_8018A0D8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018A0D8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018A154[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018A154[a1 & 0x7F]; +} + + + +extern u8 D_8018A174[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018A174[a1 & 0x7F]; +} + + + +extern u8 D_8018A194[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018A194[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018A1B4[])(void); + D_8018A1B4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018A230[])(void); + +void func_80165AC8(void) { + D_8018A230[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018A2AC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018A2AC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E83B8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E83B8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018A2B8[])(void); + +void func_80166018(void *a0) { + D_8018A2B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018A2C0[])(void); + +void func_801663FC(void *a0) { + D_8018A2C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018A388[])(void); + +void func_80166618(void *a0) { + D_8018A388[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018A398[])(void); + +void func_80166654(void *a0) { + D_8018A398[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E8D00[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E8D00[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E8D00). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E8D00[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E8D00)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E8D00[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E8D00[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018A2DC[]; + extern u8 D_8018A2C8[]; + extern u8 D_8018A2F0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018A2DC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018A2C8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018A2F0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80167714); + + +extern void (*D_8018A3A8[])(void); + +void func_801678B4(void *a0) { + D_8018A3A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018A3B4[])(void); + +void func_80167A9C(void *a0) { + D_8018A3B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018A4C0; + extern u8 D_8018A4D4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018A4C0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018A4D4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018A314[]; +extern u8 D_8018A328[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018A314; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018A328; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018A3CC[])(void); + +void func_80168744(void *a0) { + D_8018A3CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018A3BC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018A3BC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018A3BC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018A3D4[])(void); + +void func_801689D8(void *a0) { + D_8018A3D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018A3DC[])(void); + +void func_80168AA8(void *a0) { + D_8018A3DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018A3E4[])(void); + +void func_80168D58(void *a0) { + D_8018A3E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018A3EC[])(void); + +void func_8016901C(void *a0) { + D_8018A3EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_007/nonmatchings/ov_SC03_007_jr_8015C32C", func_80169228); + + +extern void (*D_8018A3F4[])(void); + +void func_801693CC(void *a0) { + D_8018A3F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018A3FC[])(void); + +void func_80169830(void *a0) { + D_8018A3FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018A4B0[])(void); + +void func_80169B80(void *a0) { + D_8018A4B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018A404[]; + extern u8 D_8018A474[]; + extern u8 D_8018A4A4[]; + extern u8 D_801EB180[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018A4A4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018A404[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801EB180; + RotMatrixYXZ(rot, D_801EB180); + func_80048D9C(D_801EB180, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018A474); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018A4B8[])(void); + +void func_80169F00(void *a0) { + D_8018A4B8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018A468[]; +extern char D_8018A428[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018A468, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018A428); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018A4F0[])(void); + +void func_8016A020(void *a0) { + D_8018A4F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018A4C0; + extern u8 D_8018A4D4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018A4C0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018A4D4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018A4FC[])(void); + +void func_8016A700(void *a0) { + D_8018A4FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018A544[])(void); + +void func_8016AB30(void *a0) { + D_8018A544[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_010/ov_SC03_010_jr_8015AE2C.c b/src/ov_SC03_010/ov_SC03_010_jr_8015AE2C.c index c1a4e5b75..01587bcc6 100644 --- a/src/ov_SC03_010/ov_SC03_010_jr_8015AE2C.c +++ b/src/ov_SC03_010/ov_SC03_010_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80182720[])(void); - -void func_8015C714(void *a0) { - D_80182720[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80182594[])(void*); - extern int D_80182538; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80182594)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80182594)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182538); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80182594[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80182594[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80182594[])(void*); - extern int D_80182538; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80182594)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182538); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80182594)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80182730[])(void); - D_80182730[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80182594[])(struct Ent_8015CD20 *); - extern u8 D_80182548; - extern u8 D_80182738; - extern u8 D_80182748; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80182594[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182548); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182738); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182748); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80182594[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80182768[])(void); - D_80182768[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80182758; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80182758 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80182594[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801827C4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801827C4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801818A8[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801818A8; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801827CC[])(void); - D_801827CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801827D8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801827D8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801827D8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801827D8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80182594[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801827D8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80182558[]; - extern u8 D_80182568[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182558); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182568); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801827D8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801827D8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801827D8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018280C[])(void); - D_8018280C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182594[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182814[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018282C[])(void); - D_8018282C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182594[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182814[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018284C[])(void); - D_8018284C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80182594[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182594)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018285C; -extern u16 D_8018285E; -extern u16 D_80182860; -extern s32 D_80182864; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018285C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018285E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80182860 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182864, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018286C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018286C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80182594[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182594)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80182880[])(void); - D_80182880[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80182594[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80182594[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80182888[])(void); - D_80182888[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80182578; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182578); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80182594[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80182890[])(void); - D_80182890[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80182594[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80182594[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80182898[])(void); - D_80182898[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80182594[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801828A0; - extern s32 D_801828B0; - extern s32 D_801828C0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80182594[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828A0); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828B0); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80182594[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828C0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801828D0[])(void); - D_801828D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80182594[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80182594[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80182594[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182594[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801828DC[])(void); - D_801828DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80182594[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182594[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80182594[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182594[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801828F0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801828F0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80182594[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80182594)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80182594[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182594[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018296C[])(void); - D_8018296C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80182594[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80182594)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018297C[])(void); - D_8018297C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80182594[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80182594[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80182594[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80182594[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80182594[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80182594[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80182594[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80182984[])(void); - D_80182984[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80182594[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80182594)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80182594[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80182594)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80182990[])(void); - D_80182990[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182594 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80182594[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80182594[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80182594[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801829A0[])(void); - -void func_80160EA4(void *a0) { - D_801829A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80182594[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80182594[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801829D0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801829D0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80182A34; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80182A34); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019EDE8[]; - extern u8 D_80182A00[]; - extern u8 D_80182A20[]; - extern u8 D_8019EDF4[]; - extern u8 D_8019EE1C[]; - extern u8 D_8019EE34[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019EDE8[0] = p; - func_80024054(&D_80182A00, &D_8019EDF4); - func_8001CE28(p, &D_8019EDF4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019EDE8[1] = p; - func_80024054(&D_80182A20, &D_8019EE1C); - func_8001CE28(p, &D_8019EE1C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019EDE8[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019EE34, 0x84); - func_8001CE68(p, &D_8019EE34); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019EE34, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019EDE8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019EDE8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80182A34; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80182A34; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80182A34; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80182A34; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019EDE8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019EDE8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80182A58[])(void); - -void func_80162330(void *a0) { - D_80182A58[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019EE40[i] via `extern int D_8019EE40[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80182A64[]; - extern s32 D_80182A7C; - extern u8 D_8019EE4C[]; - extern u8 D_8019EE74[]; - extern u8 D_8019EE90[]; - extern int D_8019EE40[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019EE40[0] = (s32)item; - func_80024054(D_80182A64, D_8019EE4C); - func_8001CE28(item, D_8019EE4C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019EE40[1] = (s32)item; - func_80024054(((u8 *)&D_80182A7C), D_8019EE74); - func_8001CE28(item, D_8019EE74); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019EE40[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019EE90, 0x84); - func_8001CE68(item, D_8019EE90); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019EE90, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019EE40[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019EE40; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_801627E8); - - -extern void (*D_80182AA0[])(void); - -void func_80162834(void *a0) { - D_80182AA0[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80182A90; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80182A90, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019E684[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019E684, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019E684[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019E684, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80182AA8[])(void); - -void func_80163A58(void *a0) { - D_80182AA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019E68C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019E68C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80182AFC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80182AFC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80182AC4; -extern s16 D_80182AF8; -extern s16 D_80182AF6; -extern s16 D_80182AF4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80182AC4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80182AF8 = 0x80; - D_80182AF6 = 0x80; - D_80182AF4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80182AF8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182AF8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80182AF8 - 8; - D_80182AF8 = nv; - D_80182AF6 = nv; - D_80182AF4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80182B08[])(void); - -void func_80164BA0(void *a0) { - D_80182B08[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019EEA0; -extern u8 D_8019EEA1; -extern u8 D_8019EEA2; -extern u8 D_8019EEA3; -extern u8 D_8019EEA4; -extern u8 D_8019EEA5; -extern u8 D_8019EEA6; -extern u8 D_8019EEA7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019EEA0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019EEA1 = 0xf0; - *(u8 *)base = 0xf0; - D_8019EEA2 = 0xc0; - D_8019EEA6 = 0; - D_8019EEA5 = 0; - D_8019EEA4 = 0; - D_8019EEA7 = 0; - D_8019EEA3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019EEA0; -extern u8 D_8019EEA1; -extern u8 D_8019EEA2; - -s32 func_80164E40(void) { - u8 *p = &D_8019EEA0; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019EEA1 != 0) { - D_8019EEA1 -= 0x10; - } - if (D_8019EEA2 != 0) { - D_8019EEA2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80182B18[])(void); - -void func_80164EA4(void *a0) { - D_80182B18[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019EEEC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019EEEC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019EEE0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019EEE0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019EEE0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019EEE0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019EEE0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80182B2C[]; - extern u32 D_80182B4C, D_80182B50, D_80182B54, D_80182B58; - extern u32 D_80182B4C, D_80182B50, D_80182B54, D_80182B58; - extern u32 D_80182B4C, D_80182B50, D_80182B54, D_80182B58; - extern u32 D_80182B4C, D_80182B50, D_80182B54, D_80182B58; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80182B2C[0x00], p); - ApplyMatrixSV(mat, &D_80182B2C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80182B2C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80182B2C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80182B54; - *(u32 *)(prim + 0x24) = D_80182B4C; - *(u32 *)(prim + 0x28) = D_80182B58; - *(u32 *)(prim + 0x2c) = D_80182B50; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80182B5C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80182B5C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80182B5C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80182B5C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80182BD8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80182BD8[a1 & 0x7F]; -} - - - -extern s32 D_80182BF8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80182BF8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80182C74[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80182C74[a1 & 0x7F]; -} - - - -extern u8 D_80182C94[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182C94[a1 & 0x7F]; -} - - - -extern u8 D_80182CB4[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182CB4[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80182CD4[])(void); - D_80182CD4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80182D50[])(void); - -void func_80165AC8(void) { - D_80182D50[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80182DCC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80182DCC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019E694; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019E694, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80182DD8[])(void); - -void func_80166018(void *a0) { - D_80182DD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80182DE0[])(void); - -void func_801663FC(void *a0) { - D_80182DE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182EA8[])(void); - -void func_80166618(void *a0) { - D_80182EA8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182EB8[])(void); - -void func_80166654(void *a0) { - D_80182EB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019EF60[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019EF60[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019EF60). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019EF60[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019EF60)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019EF60[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019EF60[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80182DFC[]; - extern u8 D_80182DE8[]; - extern u8 D_80182E10[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80182DFC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80182DE8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182E10; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80167714); - - -extern void (*D_80182EC8[])(void); - -void func_801678B4(void *a0) { - D_80182EC8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80182ED4[])(void); - -void func_80167A9C(void *a0) { - D_80182ED4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80182FE0; - extern u8 D_80182FF4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80182FE0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182FF4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80182E34[]; -extern u8 D_80182E48[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80182E34; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80182E48; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80182EEC[])(void); - -void func_80168744(void *a0) { - D_80182EEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80182EDC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80182EDC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80182EDC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80182EF4[])(void); - -void func_801689D8(void *a0) { - D_80182EF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80182EFC[])(void); - -void func_80168AA8(void *a0) { - D_80182EFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80182F04[])(void); - -void func_80168D58(void *a0) { - D_80182F04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80182F0C[])(void); - -void func_8016901C(void *a0) { - D_80182F0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015AE2C", func_80169228); - - -extern void (*D_80182F14[])(void); - -void func_801693CC(void *a0) { - D_80182F14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80182F1C[])(void); - -void func_80169830(void *a0) { - D_80182F1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80182FD0[])(void); - -void func_80169B80(void *a0) { - D_80182FD0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80182F24[]; - extern u8 D_80182F94[]; - extern u8 D_80182FC4[]; - extern u8 D_801A0088[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80182FC4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80182F24[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A0088; - RotMatrixYXZ(rot, D_801A0088); - func_80048D9C(D_801A0088, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182F94); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80182FD8[])(void); - -void func_80169F00(void *a0) { - D_80182FD8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80182F88[]; -extern char D_80182F48[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80182F88, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182F48); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80183010[])(void); - -void func_8016A020(void *a0) { - D_80183010[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80182FE0; - extern u8 D_80182FF4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80182FE0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182FF4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018301C[])(void); - -void func_8016A700(void *a0) { - D_8018301C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80183064[])(void); - -void func_8016AB30(void *a0) { - D_80183064[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c b/src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c new file mode 100644 index 000000000..5d018f837 --- /dev/null +++ b/src/ov_SC03_010/ov_SC03_010_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80182430; +extern u8 D_801823A0; +extern u8 D_8018237C; +extern u8 D_80182358; +extern u8 D_8018240C; +extern u8 D_801823E8; +extern u8 D_801823C4; +extern u8 D_80182334; +extern void func_80145934(void); +extern u8 D_801824C0; +extern u8 D_8018249C; +extern u8 D_80182478; +extern u8 D_80182454; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801818B8[]; +extern unsigned char D_801818E8[]; +extern unsigned char D_80181938[]; +extern unsigned char D_80181968[]; +extern unsigned char D_80181998[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801819E8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80181AB0[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80181B38[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80181B40; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019ED90; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019ED94; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80181B70; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80181C18[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80181C3C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80181C2C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80181C50[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80181C5C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80181C6C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181C84[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80181C74; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181C98[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181CB4[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181CA4; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181CC8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80181CDC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80181CF0; +extern void (*D_80181D18[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80181CF8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80181D64[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80181D68[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801821CC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801821DC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019EDC8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80182204[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801821E4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801821F4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80182244[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018224C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80182218; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80182258[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80182228; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019EDD0; +extern s32 D_8019EDDC; +extern s32 D_8019EDE0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80182294[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80182268[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019EDD8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801824E4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80182304[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80182588[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801826DC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801824F8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801826E4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80182508; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80182528; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801826EC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80182714[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80182594[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80182594[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80182594[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80182594[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80182594[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80182594[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80182594[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80182594[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80182720[])(void); + +void func_8015C714(void *a0) { + D_80182720[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80182594[])(void*); + extern int D_80182538; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80182594)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80182594)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182538); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80182594[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80182594[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80182594[])(void*); + extern int D_80182538; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80182594)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182538); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80182594)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80182730[])(void); + D_80182730[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80182594[])(struct Ent_8015CD20 *); + extern u8 D_80182548; + extern u8 D_80182738; + extern u8 D_80182748; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80182594[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182548); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182738); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182748); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80182594[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80182768[])(void); + D_80182768[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80182758; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80182758 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80182594[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801827C4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801827C4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801818A8[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801818A8; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801827CC[])(void); + D_801827CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801827D8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801827D8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801827D8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801827D8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80182594[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801827D8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80182558[]; + extern u8 D_80182568[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182558); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182568); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801827D8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801827D8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801827D8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018280C[])(void); + D_8018280C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182594[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182814[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018282C[])(void); + D_8018282C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182594[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182814[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182814[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018284C[])(void); + D_8018284C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80182594[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182594)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018285C; +extern u16 D_8018285E; +extern u16 D_80182860; +extern s32 D_80182864; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018285C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018285E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80182860 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182864, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018286C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018286C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80182594[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182594)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80182880[])(void); + D_80182880[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80182594[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80182594[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80182888[])(void); + D_80182888[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80182578; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182578); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80182594[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80182890[])(void); + D_80182890[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80182594[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80182594[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80182898[])(void); + D_80182898[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80182594[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801828A0; + extern s32 D_801828B0; + extern s32 D_801828C0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80182594[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828A0); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828B0); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80182594[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828C0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801828D0[])(void); + D_801828D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80182594[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80182594[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80182594[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182594[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801828DC[])(void); + D_801828DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80182594[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182594[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80182594[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182594[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801828F0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801828F0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80182594[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80182594)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80182594[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182594[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018296C[])(void); + D_8018296C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80182594[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80182594)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018297C[])(void); + D_8018297C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80182594[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80182594[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80182594[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80182594[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80182594[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80182594[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80182594[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80182984[])(void); + D_80182984[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80182594[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80182594)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80182594[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80182594)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80182990[])(void); + D_80182990[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182594 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80182594[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80182594[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80182594[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801829A0[])(void); + +void func_80160EA4(void *a0) { + D_801829A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80182594[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80182594[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801829D0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801829D0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80182A34; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80182A34); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019EDE8[]; + extern u8 D_80182A00[]; + extern u8 D_80182A20[]; + extern u8 D_8019EDF4[]; + extern u8 D_8019EE1C[]; + extern u8 D_8019EE34[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019EDE8[0] = p; + func_80024054(&D_80182A00, &D_8019EDF4); + func_8001CE28(p, &D_8019EDF4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019EDE8[1] = p; + func_80024054(&D_80182A20, &D_8019EE1C); + func_8001CE28(p, &D_8019EE1C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019EDE8[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019EE34, 0x84); + func_8001CE68(p, &D_8019EE34); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019EE34, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019EDE8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019EDE8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80182A34; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80182A34; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80182A34; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80182A34; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019EDE8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019EDE8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80182A58[])(void); + +void func_80162330(void *a0) { + D_80182A58[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019EE40[i] via `extern int D_8019EE40[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80182A64[]; + extern s32 D_80182A7C; + extern u8 D_8019EE4C[]; + extern u8 D_8019EE74[]; + extern u8 D_8019EE90[]; + extern int D_8019EE40[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019EE40[0] = (s32)item; + func_80024054(D_80182A64, D_8019EE4C); + func_8001CE28(item, D_8019EE4C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019EE40[1] = (s32)item; + func_80024054(((u8 *)&D_80182A7C), D_8019EE74); + func_8001CE28(item, D_8019EE74); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019EE40[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019EE90, 0x84); + func_8001CE68(item, D_8019EE90); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019EE90, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019EE40[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019EE40; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_801627E8); + + +extern void (*D_80182AA0[])(void); + +void func_80162834(void *a0) { + D_80182AA0[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80182A90; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80182A90, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019E684[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019E684, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019E684[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019E684, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80182AA8[])(void); + +void func_80163A58(void *a0) { + D_80182AA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019E68C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019E68C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80182AFC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80182AFC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80182AC4; +extern s16 D_80182AF8; +extern s16 D_80182AF6; +extern s16 D_80182AF4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80182AC4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80182AF8 = 0x80; + D_80182AF6 = 0x80; + D_80182AF4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80182AF8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182AF8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80182AF8 - 8; + D_80182AF8 = nv; + D_80182AF6 = nv; + D_80182AF4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80182B08[])(void); + +void func_80164BA0(void *a0) { + D_80182B08[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019EEA0; +extern u8 D_8019EEA1; +extern u8 D_8019EEA2; +extern u8 D_8019EEA3; +extern u8 D_8019EEA4; +extern u8 D_8019EEA5; +extern u8 D_8019EEA6; +extern u8 D_8019EEA7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019EEA0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019EEA1 = 0xf0; + *(u8 *)base = 0xf0; + D_8019EEA2 = 0xc0; + D_8019EEA6 = 0; + D_8019EEA5 = 0; + D_8019EEA4 = 0; + D_8019EEA7 = 0; + D_8019EEA3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019EEA0; +extern u8 D_8019EEA1; +extern u8 D_8019EEA2; + +s32 func_80164E40(void) { + u8 *p = &D_8019EEA0; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019EEA1 != 0) { + D_8019EEA1 -= 0x10; + } + if (D_8019EEA2 != 0) { + D_8019EEA2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80182B18[])(void); + +void func_80164EA4(void *a0) { + D_80182B18[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019EEEC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019EEEC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019EEE0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019EEE0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019EEE0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019EEE0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019EEE0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80182B2C[]; + extern u32 D_80182B4C, D_80182B50, D_80182B54, D_80182B58; + extern u32 D_80182B4C, D_80182B50, D_80182B54, D_80182B58; + extern u32 D_80182B4C, D_80182B50, D_80182B54, D_80182B58; + extern u32 D_80182B4C, D_80182B50, D_80182B54, D_80182B58; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80182B2C[0x00], p); + ApplyMatrixSV(mat, &D_80182B2C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80182B2C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80182B2C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80182B54; + *(u32 *)(prim + 0x24) = D_80182B4C; + *(u32 *)(prim + 0x28) = D_80182B58; + *(u32 *)(prim + 0x2c) = D_80182B50; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80182B5C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80182B5C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80182B5C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80182B5C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80182BD8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80182BD8[a1 & 0x7F]; +} + + + +extern s32 D_80182BF8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80182BF8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80182C74[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80182C74[a1 & 0x7F]; +} + + + +extern u8 D_80182C94[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182C94[a1 & 0x7F]; +} + + + +extern u8 D_80182CB4[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182CB4[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80182CD4[])(void); + D_80182CD4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80182D50[])(void); + +void func_80165AC8(void) { + D_80182D50[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80182DCC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80182DCC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019E694; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019E694, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80182DD8[])(void); + +void func_80166018(void *a0) { + D_80182DD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80182DE0[])(void); + +void func_801663FC(void *a0) { + D_80182DE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182EA8[])(void); + +void func_80166618(void *a0) { + D_80182EA8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182EB8[])(void); + +void func_80166654(void *a0) { + D_80182EB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019EF60[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019EF60[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019EF60). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019EF60[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019EF60)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019EF60[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019EF60[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80182DFC[]; + extern u8 D_80182DE8[]; + extern u8 D_80182E10[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80182DFC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80182DE8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182E10; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80167714); + + +extern void (*D_80182EC8[])(void); + +void func_801678B4(void *a0) { + D_80182EC8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80182ED4[])(void); + +void func_80167A9C(void *a0) { + D_80182ED4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80182FE0; + extern u8 D_80182FF4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80182FE0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182FF4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80182E34[]; +extern u8 D_80182E48[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80182E34; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80182E48; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80182EEC[])(void); + +void func_80168744(void *a0) { + D_80182EEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80182EDC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80182EDC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80182EDC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80182EF4[])(void); + +void func_801689D8(void *a0) { + D_80182EF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80182EFC[])(void); + +void func_80168AA8(void *a0) { + D_80182EFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80182F04[])(void); + +void func_80168D58(void *a0) { + D_80182F04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80182F0C[])(void); + +void func_8016901C(void *a0) { + D_80182F0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_010/nonmatchings/ov_SC03_010_jr_8015C32C", func_80169228); + + +extern void (*D_80182F14[])(void); + +void func_801693CC(void *a0) { + D_80182F14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80182F1C[])(void); + +void func_80169830(void *a0) { + D_80182F1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80182FD0[])(void); + +void func_80169B80(void *a0) { + D_80182FD0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80182F24[]; + extern u8 D_80182F94[]; + extern u8 D_80182FC4[]; + extern u8 D_801A0088[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80182FC4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80182F24[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A0088; + RotMatrixYXZ(rot, D_801A0088); + func_80048D9C(D_801A0088, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182F94); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80182FD8[])(void); + +void func_80169F00(void *a0) { + D_80182FD8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80182F88[]; +extern char D_80182F48[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80182F88, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182F48); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80183010[])(void); + +void func_8016A020(void *a0) { + D_80183010[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80182FE0; + extern u8 D_80182FF4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80182FE0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182FF4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018301C[])(void); + +void func_8016A700(void *a0) { + D_8018301C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80183064[])(void); + +void func_8016AB30(void *a0) { + D_80183064[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_011/ov_SC03_011_jr_8015AE2C.c b/src/ov_SC03_011/ov_SC03_011_jr_8015AE2C.c index bc026b87b..5c41cbf1b 100644 --- a/src/ov_SC03_011/ov_SC03_011_jr_8015AE2C.c +++ b/src/ov_SC03_011/ov_SC03_011_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80183A90[])(void); - -void func_8015C714(void *a0) { - D_80183A90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80183904[])(void*); - extern int D_801838A8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80183904)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80183904)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801838A8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80183904[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80183904[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80183904[])(void*); - extern int D_801838A8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80183904)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801838A8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80183904)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80183AA0[])(void); - D_80183AA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80183904[])(struct Ent_8015CD20 *); - extern u8 D_801838B8; - extern u8 D_80183AA8; - extern u8 D_80183AB8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80183904[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801838B8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183AA8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183AB8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80183904[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80183AD8[])(void); - D_80183AD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80183AC8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80183AC8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80183904[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80183B34; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80183B34, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80182C18[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80182C18; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80183B3C[])(void); - D_80183B3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80183B48[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80183B48[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80183B48[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80183B48[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80183904[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80183B48[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801838C8[]; - extern u8 D_801838D8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801838C8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801838D8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80183B48[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183B48[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183B48[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80183B7C[])(void); - D_80183B7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80183904[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80183B84[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80183B9C[])(void); - D_80183B9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80183904[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80183B84[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80183BBC[])(void); - D_80183BBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80183904[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80183904)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80183BCC; -extern u16 D_80183BCE; -extern u16 D_80183BD0; -extern s32 D_80183BD4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80183BCC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80183BCE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80183BD0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80183BD4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80183BDC; - -void func_8015E588(void) { - func_8013C9C4(&D_80183BDC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80183904[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80183904)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80183BF0[])(void); - D_80183BF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80183904[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80183904[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80183BF8[])(void); - D_80183BF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801838E8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801838E8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80183904[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80183C00[])(void); - D_80183C00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80183904[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80183904[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80183C08[])(void); - D_80183C08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80183904[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80183C10; - extern s32 D_80183C20; - extern s32 D_80183C30; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80183904[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183C10); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183C20); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80183904[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183C30); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80183C40[])(void); - D_80183C40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80183904[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80183904[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80183904[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80183904[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80183C4C[])(void); - D_80183C4C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80183904[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80183904[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80183904[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80183904[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80183C60[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80183C60[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80183904[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80183904)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80183904[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80183904[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80183CDC[])(void); - D_80183CDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80183904[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80183904)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80183CEC[])(void); - D_80183CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80183904[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80183904[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80183904[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80183904[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80183904[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80183904[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80183904[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80183CF4[])(void); - D_80183CF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80183904[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80183904)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80183904[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80183904)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80183D00[])(void); - D_80183D00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80183904 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80183904[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80183904[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80183904[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80183D10[])(void); - -void func_80160EA4(void *a0) { - D_80183D10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80183904[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80183904[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80183D40[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80183D40[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80183DA4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80183DA4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A1080[]; - extern u8 D_80183D70[]; - extern u8 D_80183D90[]; - extern u8 D_801A108C[]; - extern u8 D_801A10B4[]; - extern u8 D_801A10CC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A1080[0] = p; - func_80024054(&D_80183D70, &D_801A108C); - func_8001CE28(p, &D_801A108C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A1080[1] = p; - func_80024054(&D_80183D90, &D_801A10B4); - func_8001CE28(p, &D_801A10B4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A1080[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A10CC, 0x84); - func_8001CE68(p, &D_801A10CC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A10CC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A1080[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A1080; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80183DA4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80183DA4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80183DA4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80183DA4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A1080[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A1080; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80183DC8[])(void); - -void func_80162330(void *a0) { - D_80183DC8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A10D8[i] via `extern int D_801A10D8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80183DD4[]; - extern s32 D_80183DEC; - extern u8 D_801A10E4[]; - extern u8 D_801A110C[]; - extern u8 D_801A1128[]; - extern int D_801A10D8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A10D8[0] = (s32)item; - func_80024054(D_80183DD4, D_801A10E4); - func_8001CE28(item, D_801A10E4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A10D8[1] = (s32)item; - func_80024054(((u8 *)&D_80183DEC), D_801A110C); - func_8001CE28(item, D_801A110C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A10D8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A1128, 0x84); - func_8001CE68(item, D_801A1128); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A1128, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A10D8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A10D8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_801627E8); - - -extern void (*D_80183E10[])(void); - -void func_80162834(void *a0) { - D_80183E10[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80183E00; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80183E00, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801A08F4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801A08F4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801A08F4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801A08F4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80183E18[])(void); - -void func_80163A58(void *a0) { - D_80183E18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801A08FC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801A08FC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80183E6C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80183E6C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80183E34; -extern s16 D_80183E68; -extern s16 D_80183E66; -extern s16 D_80183E64; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80183E34; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80183E68 = 0x80; - D_80183E66 = 0x80; - D_80183E64 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80183E68 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80183E68` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80183E68 - 8; - D_80183E68 = nv; - D_80183E66 = nv; - D_80183E64 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80183E78[])(void); - -void func_80164BA0(void *a0) { - D_80183E78[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A1138; -extern u8 D_801A1139; -extern u8 D_801A113A; -extern u8 D_801A113B; -extern u8 D_801A113C; -extern u8 D_801A113D; -extern u8 D_801A113E; -extern u8 D_801A113F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A1138; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A1139 = 0xf0; - *(u8 *)base = 0xf0; - D_801A113A = 0xc0; - D_801A113E = 0; - D_801A113D = 0; - D_801A113C = 0; - D_801A113F = 0; - D_801A113B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A1138; -extern u8 D_801A1139; -extern u8 D_801A113A; - -s32 func_80164E40(void) { - u8 *p = &D_801A1138; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A1139 != 0) { - D_801A1139 -= 0x10; - } - if (D_801A113A != 0) { - D_801A113A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80183E88[])(void); - -void func_80164EA4(void *a0) { - D_80183E88[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A1184[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A1184[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A1178[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A1178[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A1178[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A1178; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A1178; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80183E9C[]; - extern u32 D_80183EBC, D_80183EC0, D_80183EC4, D_80183EC8; - extern u32 D_80183EBC, D_80183EC0, D_80183EC4, D_80183EC8; - extern u32 D_80183EBC, D_80183EC0, D_80183EC4, D_80183EC8; - extern u32 D_80183EBC, D_80183EC0, D_80183EC4, D_80183EC8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80183E9C[0x00], p); - ApplyMatrixSV(mat, &D_80183E9C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80183E9C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80183E9C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80183EC4; - *(u32 *)(prim + 0x24) = D_80183EBC; - *(u32 *)(prim + 0x28) = D_80183EC8; - *(u32 *)(prim + 0x2c) = D_80183EC0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80183ECC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80183ECC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80183ECC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80183ECC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80183F48[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80183F48[a1 & 0x7F]; -} - - - -extern s32 D_80183F68[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80183F68[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80183FE4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80183FE4[a1 & 0x7F]; -} - - - -extern u8 D_80184004[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80184004[a1 & 0x7F]; -} - - - -extern u8 D_80184024[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80184024[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80184044[])(void); - D_80184044[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801840C0[])(void); - -void func_80165AC8(void) { - D_801840C0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018413C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018413C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801A0904; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801A0904, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80184148[])(void); - -void func_80166018(void *a0) { - D_80184148[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80184150[])(void); - -void func_801663FC(void *a0) { - D_80184150[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80184218[])(void); - -void func_80166618(void *a0) { - D_80184218[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80184228[])(void); - -void func_80166654(void *a0) { - D_80184228[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A11F8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A11F8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A11F8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A11F8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A11F8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A11F8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A11F8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018416C[]; - extern u8 D_80184158[]; - extern u8 D_80184180[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018416C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80184158; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80184180; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80167714); - - -extern void (*D_80184238[])(void); - -void func_801678B4(void *a0) { - D_80184238[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80184244[])(void); - -void func_80167A9C(void *a0) { - D_80184244[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80184350; - extern u8 D_80184364[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80184350); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184364; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801841A4[]; -extern u8 D_801841B8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801841A4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801841B8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018425C[])(void); - -void func_80168744(void *a0) { - D_8018425C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018424C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018424C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018424C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80184264[])(void); - -void func_801689D8(void *a0) { - D_80184264[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018426C[])(void); - -void func_80168AA8(void *a0) { - D_8018426C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80184274[])(void); - -void func_80168D58(void *a0) { - D_80184274[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018427C[])(void); - -void func_8016901C(void *a0) { - D_8018427C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015AE2C", func_80169228); - - -extern void (*D_80184284[])(void); - -void func_801693CC(void *a0) { - D_80184284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018428C[])(void); - -void func_80169830(void *a0) { - D_8018428C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80184340[])(void); - -void func_80169B80(void *a0) { - D_80184340[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80184294[]; - extern u8 D_80184304[]; - extern u8 D_80184334[]; - extern u8 D_801A22B8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80184334, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80184294[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A22B8; - RotMatrixYXZ(rot, D_801A22B8); - func_80048D9C(D_801A22B8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80184304); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80184348[])(void); - -void func_80169F00(void *a0) { - D_80184348[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801842F8[]; -extern char D_801842B8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801842F8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801842B8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80184380[])(void); - -void func_8016A020(void *a0) { - D_80184380[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80184350; - extern u8 D_80184364[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80184350); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184364; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018438C[])(void); - -void func_8016A700(void *a0) { - D_8018438C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801843D4[])(void); - -void func_8016AB30(void *a0) { - D_801843D4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c b/src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c new file mode 100644 index 000000000..3eabec347 --- /dev/null +++ b/src/ov_SC03_011/ov_SC03_011_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801837A0; +extern u8 D_80183710; +extern u8 D_801836EC; +extern u8 D_801836C8; +extern u8 D_8018377C; +extern u8 D_80183758; +extern u8 D_80183734; +extern u8 D_801836A4; +extern void func_80145934(void); +extern u8 D_80183830; +extern u8 D_8018380C; +extern u8 D_801837E8; +extern u8 D_801837C4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80182C28[]; +extern unsigned char D_80182C58[]; +extern unsigned char D_80182CA8[]; +extern unsigned char D_80182CD8[]; +extern unsigned char D_80182D08[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80182D58[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80182E20[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80182EA8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80182EB0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A1028; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A102C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80182EE0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80182F88[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80182FAC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80182F9C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80182FC0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80182FCC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80182FDC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80182FF4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80182FE4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80183008[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80183024[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80183014; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80183038[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018304C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80183060; +extern void (*D_80183088[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80183068; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801830D4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801830D8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018353C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018354C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A1060; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80183574[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80183554; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80183564; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801835B4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801835BC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80183588; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801835C8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80183598; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A1068; +extern s32 D_801A1074; +extern s32 D_801A1078; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80183604[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801835D8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A1070; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80183854[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80183674[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801838F8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80183A4C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80183868; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80183A54[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80183878; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80183898; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80183A5C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80183A84[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80183904[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80183904[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80183904[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80183904[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80183904[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80183904[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80183904[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80183904[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80183A90[])(void); + +void func_8015C714(void *a0) { + D_80183A90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80183904[])(void*); + extern int D_801838A8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80183904)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80183904)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801838A8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80183904[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80183904[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80183904[])(void*); + extern int D_801838A8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80183904)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801838A8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80183904)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80183AA0[])(void); + D_80183AA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80183904[])(struct Ent_8015CD20 *); + extern u8 D_801838B8; + extern u8 D_80183AA8; + extern u8 D_80183AB8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80183904[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801838B8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183AA8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183AB8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80183904[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80183AD8[])(void); + D_80183AD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80183AC8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80183AC8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80183904[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80183B34; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80183B34, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80182C18[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80182C18; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80183B3C[])(void); + D_80183B3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80183B48[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80183B48[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80183B48[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80183B48[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80183904[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80183B48[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801838C8[]; + extern u8 D_801838D8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801838C8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801838D8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80183B48[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183B48[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183B48[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80183B7C[])(void); + D_80183B7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80183904[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80183B84[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80183B9C[])(void); + D_80183B9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80183904[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80183B84[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80183B84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80183BBC[])(void); + D_80183BBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80183904[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80183904)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80183BCC; +extern u16 D_80183BCE; +extern u16 D_80183BD0; +extern s32 D_80183BD4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80183BCC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80183BCE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80183BD0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80183BD4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80183BDC; + +void func_8015E588(void) { + func_8013C9C4(&D_80183BDC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80183904[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80183904)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80183BF0[])(void); + D_80183BF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80183904[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80183904[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80183BF8[])(void); + D_80183BF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801838E8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801838E8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80183904[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80183C00[])(void); + D_80183C00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80183904[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80183904[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80183C08[])(void); + D_80183C08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80183904[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80183C10; + extern s32 D_80183C20; + extern s32 D_80183C30; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80183904[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183C10); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183C20); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80183904[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183C30); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80183C40[])(void); + D_80183C40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80183904[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80183904[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80183904[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80183904[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80183C4C[])(void); + D_80183C4C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80183904[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80183904[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80183904[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80183904[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80183C60[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80183C60[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80183904[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80183904)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80183904[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80183904[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80183CDC[])(void); + D_80183CDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80183904[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80183904)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80183CEC[])(void); + D_80183CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80183904[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80183904[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80183904[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80183904[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80183904[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80183904[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80183904[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80183CF4[])(void); + D_80183CF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80183904[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80183904)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80183904[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80183904)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80183D00[])(void); + D_80183D00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80183904 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80183904[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80183904[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80183904[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80183D10[])(void); + +void func_80160EA4(void *a0) { + D_80183D10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80183904[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80183904[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80183D40[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80183D40[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80183DA4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80183DA4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A1080[]; + extern u8 D_80183D70[]; + extern u8 D_80183D90[]; + extern u8 D_801A108C[]; + extern u8 D_801A10B4[]; + extern u8 D_801A10CC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A1080[0] = p; + func_80024054(&D_80183D70, &D_801A108C); + func_8001CE28(p, &D_801A108C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A1080[1] = p; + func_80024054(&D_80183D90, &D_801A10B4); + func_8001CE28(p, &D_801A10B4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A1080[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A10CC, 0x84); + func_8001CE68(p, &D_801A10CC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A10CC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A1080[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A1080; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80183DA4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80183DA4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80183DA4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80183DA4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A1080[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A1080; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80183DC8[])(void); + +void func_80162330(void *a0) { + D_80183DC8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A10D8[i] via `extern int D_801A10D8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80183DD4[]; + extern s32 D_80183DEC; + extern u8 D_801A10E4[]; + extern u8 D_801A110C[]; + extern u8 D_801A1128[]; + extern int D_801A10D8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A10D8[0] = (s32)item; + func_80024054(D_80183DD4, D_801A10E4); + func_8001CE28(item, D_801A10E4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A10D8[1] = (s32)item; + func_80024054(((u8 *)&D_80183DEC), D_801A110C); + func_8001CE28(item, D_801A110C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A10D8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A1128, 0x84); + func_8001CE68(item, D_801A1128); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A1128, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A10D8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A10D8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_801627E8); + + +extern void (*D_80183E10[])(void); + +void func_80162834(void *a0) { + D_80183E10[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80183E00; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80183E00, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801A08F4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801A08F4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801A08F4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801A08F4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80183E18[])(void); + +void func_80163A58(void *a0) { + D_80183E18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801A08FC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801A08FC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80183E6C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80183E6C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80183E34; +extern s16 D_80183E68; +extern s16 D_80183E66; +extern s16 D_80183E64; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80183E34; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80183E68 = 0x80; + D_80183E66 = 0x80; + D_80183E64 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80183E68 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80183E68` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80183E68 - 8; + D_80183E68 = nv; + D_80183E66 = nv; + D_80183E64 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80183E78[])(void); + +void func_80164BA0(void *a0) { + D_80183E78[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A1138; +extern u8 D_801A1139; +extern u8 D_801A113A; +extern u8 D_801A113B; +extern u8 D_801A113C; +extern u8 D_801A113D; +extern u8 D_801A113E; +extern u8 D_801A113F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A1138; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A1139 = 0xf0; + *(u8 *)base = 0xf0; + D_801A113A = 0xc0; + D_801A113E = 0; + D_801A113D = 0; + D_801A113C = 0; + D_801A113F = 0; + D_801A113B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A1138; +extern u8 D_801A1139; +extern u8 D_801A113A; + +s32 func_80164E40(void) { + u8 *p = &D_801A1138; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A1139 != 0) { + D_801A1139 -= 0x10; + } + if (D_801A113A != 0) { + D_801A113A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80183E88[])(void); + +void func_80164EA4(void *a0) { + D_80183E88[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A1184[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A1184[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A1178[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A1178[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A1178[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A1178; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A1178; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80183E9C[]; + extern u32 D_80183EBC, D_80183EC0, D_80183EC4, D_80183EC8; + extern u32 D_80183EBC, D_80183EC0, D_80183EC4, D_80183EC8; + extern u32 D_80183EBC, D_80183EC0, D_80183EC4, D_80183EC8; + extern u32 D_80183EBC, D_80183EC0, D_80183EC4, D_80183EC8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80183E9C[0x00], p); + ApplyMatrixSV(mat, &D_80183E9C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80183E9C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80183E9C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80183EC4; + *(u32 *)(prim + 0x24) = D_80183EBC; + *(u32 *)(prim + 0x28) = D_80183EC8; + *(u32 *)(prim + 0x2c) = D_80183EC0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80183ECC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80183ECC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80183ECC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80183ECC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80183F48[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80183F48[a1 & 0x7F]; +} + + + +extern s32 D_80183F68[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80183F68[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80183FE4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80183FE4[a1 & 0x7F]; +} + + + +extern u8 D_80184004[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80184004[a1 & 0x7F]; +} + + + +extern u8 D_80184024[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80184024[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80184044[])(void); + D_80184044[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801840C0[])(void); + +void func_80165AC8(void) { + D_801840C0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018413C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018413C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801A0904; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801A0904, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80184148[])(void); + +void func_80166018(void *a0) { + D_80184148[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80184150[])(void); + +void func_801663FC(void *a0) { + D_80184150[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80184218[])(void); + +void func_80166618(void *a0) { + D_80184218[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80184228[])(void); + +void func_80166654(void *a0) { + D_80184228[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A11F8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A11F8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A11F8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A11F8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A11F8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A11F8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A11F8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018416C[]; + extern u8 D_80184158[]; + extern u8 D_80184180[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018416C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80184158; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80184180; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80167714); + + +extern void (*D_80184238[])(void); + +void func_801678B4(void *a0) { + D_80184238[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80184244[])(void); + +void func_80167A9C(void *a0) { + D_80184244[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80184350; + extern u8 D_80184364[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80184350); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184364; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801841A4[]; +extern u8 D_801841B8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801841A4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801841B8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018425C[])(void); + +void func_80168744(void *a0) { + D_8018425C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018424C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018424C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018424C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80184264[])(void); + +void func_801689D8(void *a0) { + D_80184264[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018426C[])(void); + +void func_80168AA8(void *a0) { + D_8018426C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80184274[])(void); + +void func_80168D58(void *a0) { + D_80184274[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018427C[])(void); + +void func_8016901C(void *a0) { + D_8018427C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_011/nonmatchings/ov_SC03_011_jr_8015C32C", func_80169228); + + +extern void (*D_80184284[])(void); + +void func_801693CC(void *a0) { + D_80184284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018428C[])(void); + +void func_80169830(void *a0) { + D_8018428C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80184340[])(void); + +void func_80169B80(void *a0) { + D_80184340[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80184294[]; + extern u8 D_80184304[]; + extern u8 D_80184334[]; + extern u8 D_801A22B8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80184334, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80184294[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A22B8; + RotMatrixYXZ(rot, D_801A22B8); + func_80048D9C(D_801A22B8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80184304); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80184348[])(void); + +void func_80169F00(void *a0) { + D_80184348[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801842F8[]; +extern char D_801842B8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801842F8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801842B8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80184380[])(void); + +void func_8016A020(void *a0) { + D_80184380[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80184350; + extern u8 D_80184364[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80184350); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184364; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018438C[])(void); + +void func_8016A700(void *a0) { + D_8018438C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801843D4[])(void); + +void func_8016AB30(void *a0) { + D_801843D4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_012/ov_SC03_012_jr_8015AE2C.c b/src/ov_SC03_012/ov_SC03_012_jr_8015AE2C.c index 2471bdff0..d895bf5b6 100644 --- a/src/ov_SC03_012/ov_SC03_012_jr_8015AE2C.c +++ b/src/ov_SC03_012/ov_SC03_012_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80180970[])(void); - -void func_8015C714(void *a0) { - D_80180970[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801807E4[])(void*); - extern int D_80180788; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801807E4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801807E4)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180788); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801807E4[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801807E4[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801807E4[])(void*); - extern int D_80180788; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801807E4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180788); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801807E4)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80180980[])(void); - D_80180980[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801807E4[])(struct Ent_8015CD20 *); - extern u8 D_80180798; - extern u8 D_80180988; - extern u8 D_80180998; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801807E4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180798); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180988); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180998); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801807E4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801809B8[])(void); - D_801809B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801809A8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801809A8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801807E4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80180A14; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80180A14, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8017FAF8[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8017FAF8; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80180A1C[])(void); - D_80180A1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80180A28[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80180A28[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80180A28[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80180A28[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801807E4[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80180A28[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801807A8[]; - extern u8 D_801807B8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801807A8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801807B8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80180A28[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180A28[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180A28[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80180A5C[])(void); - D_80180A5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801807E4[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180A64[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80180A7C[])(void); - D_80180A7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801807E4[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180A64[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80180A9C[])(void); - D_80180A9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801807E4[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801807E4)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80180AAC; -extern u16 D_80180AAE; -extern u16 D_80180AB0; -extern s32 D_80180AB4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80180AAC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80180AAE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80180AB0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180AB4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80180ABC; - -void func_8015E588(void) { - func_8013C9C4(&D_80180ABC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801807E4[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801807E4)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80180AD0[])(void); - D_80180AD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801807E4[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801807E4[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80180AD8[])(void); - D_80180AD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801807C8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801807C8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801807E4[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80180AE0[])(void); - D_80180AE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801807E4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801807E4[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80180AE8[])(void); - D_80180AE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801807E4[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80180AF0; - extern s32 D_80180B00; - extern s32 D_80180B10; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801807E4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180AF0); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B00); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801807E4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B10); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80180B20[])(void); - D_80180B20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801807E4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801807E4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801807E4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801807E4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80180B2C[])(void); - D_80180B2C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801807E4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801807E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801807E4[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801807E4[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80180B40[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80180B40[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801807E4[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801807E4)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801807E4[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801807E4[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80180BBC[])(void); - D_80180BBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801807E4[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801807E4)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80180BCC[])(void); - D_80180BCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801807E4[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801807E4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801807E4[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801807E4[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801807E4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801807E4[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801807E4[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80180BD4[])(void); - D_80180BD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801807E4[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801807E4)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801807E4[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801807E4)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80180BE0[])(void); - D_80180BE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801807E4 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801807E4[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801807E4[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801807E4[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80180BF0[])(void); - -void func_80160EA4(void *a0) { - D_80180BF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801807E4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801807E4[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80180C20[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80180C20[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80180C84; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80180C84); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80193EA0[]; - extern u8 D_80180C50[]; - extern u8 D_80180C70[]; - extern u8 D_80193EAC[]; - extern u8 D_80193ED4[]; - extern u8 D_80193EEC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80193EA0[0] = p; - func_80024054(&D_80180C50, &D_80193EAC); - func_8001CE28(p, &D_80193EAC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80193EA0[1] = p; - func_80024054(&D_80180C70, &D_80193ED4); - func_8001CE28(p, &D_80193ED4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80193EA0[2] = p; - func_800242D0((s16)func_801620C4(), &D_80193EEC, 0x84); - func_8001CE68(p, &D_80193EEC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80193EEC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80193EA0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80193EA0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80180C84; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80180C84; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80180C84; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80180C84; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80193EA0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80193EA0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80180CA8[])(void); - -void func_80162330(void *a0) { - D_80180CA8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80193EF8[i] via `extern int D_80193EF8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80180CB4[]; - extern s32 D_80180CCC; - extern u8 D_80193F04[]; - extern u8 D_80193F2C[]; - extern u8 D_80193F48[]; - extern int D_80193EF8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80193EF8[0] = (s32)item; - func_80024054(D_80180CB4, D_80193F04); - func_8001CE28(item, D_80193F04); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80193EF8[1] = (s32)item; - func_80024054(((u8 *)&D_80180CCC), D_80193F2C); - func_8001CE28(item, D_80193F2C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80193EF8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80193F48, 0x84); - func_8001CE68(item, D_80193F48); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80193F48, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80193EF8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80193EF8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_801627E8); - - -extern void (*D_80180CF0[])(void); - -void func_80162834(void *a0) { - D_80180CF0[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80180CE0; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80180CE0, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80193750[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80193750, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80193750[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80193750, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80180CF8[])(void); - -void func_80163A58(void *a0) { - D_80180CF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80193758; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80193758; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80180D4C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80180D4C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80180D14; -extern s16 D_80180D48; -extern s16 D_80180D46; -extern s16 D_80180D44; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80180D14; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80180D48 = 0x80; - D_80180D46 = 0x80; - D_80180D44 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80180D48 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180D48` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80180D48 - 8; - D_80180D48 = nv; - D_80180D46 = nv; - D_80180D44 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80180D58[])(void); - -void func_80164BA0(void *a0) { - D_80180D58[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80193F58; -extern u8 D_80193F59; -extern u8 D_80193F5A; -extern u8 D_80193F5B; -extern u8 D_80193F5C; -extern u8 D_80193F5D; -extern u8 D_80193F5E; -extern u8 D_80193F5F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80193F58; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80193F59 = 0xf0; - *(u8 *)base = 0xf0; - D_80193F5A = 0xc0; - D_80193F5E = 0; - D_80193F5D = 0; - D_80193F5C = 0; - D_80193F5F = 0; - D_80193F5B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80193F58; -extern u8 D_80193F59; -extern u8 D_80193F5A; - -s32 func_80164E40(void) { - u8 *p = &D_80193F58; - if (*p != 0) { - *p -= 0x10; - } - if (D_80193F59 != 0) { - D_80193F59 -= 0x10; - } - if (D_80193F5A != 0) { - D_80193F5A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80180D68[])(void); - -void func_80164EA4(void *a0) { - D_80180D68[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80193FA4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80193FA4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80193F98[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80193F98[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80193F98[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80193F98; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80193F98; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80180D7C[]; - extern u32 D_80180D9C, D_80180DA0, D_80180DA4, D_80180DA8; - extern u32 D_80180D9C, D_80180DA0, D_80180DA4, D_80180DA8; - extern u32 D_80180D9C, D_80180DA0, D_80180DA4, D_80180DA8; - extern u32 D_80180D9C, D_80180DA0, D_80180DA4, D_80180DA8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80180D7C[0x00], p); - ApplyMatrixSV(mat, &D_80180D7C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80180D7C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80180D7C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80180DA4; - *(u32 *)(prim + 0x24) = D_80180D9C; - *(u32 *)(prim + 0x28) = D_80180DA8; - *(u32 *)(prim + 0x2c) = D_80180DA0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80180DAC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80180DAC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80180DAC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80180DAC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80180E28[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80180E28[a1 & 0x7F]; -} - - - -extern s32 D_80180E48[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80180E48[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80180EC4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80180EC4[a1 & 0x7F]; -} - - - -extern u8 D_80180EE4[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80180EE4[a1 & 0x7F]; -} - - - -extern u8 D_80180F04[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80180F04[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80180F24[])(void); - D_80180F24[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80180FA0[])(void); - -void func_80165AC8(void) { - D_80180FA0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018101C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018101C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80193760; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80193760, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80181028[])(void); - -void func_80166018(void *a0) { - D_80181028[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181030[])(void); - -void func_801663FC(void *a0) { - D_80181030[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801810F8[])(void); - -void func_80166618(void *a0) { - D_801810F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181108[])(void); - -void func_80166654(void *a0) { - D_80181108[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80194018[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80194018[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80194018). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80194018[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80194018)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80194018[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80194018[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018104C[]; - extern u8 D_80181038[]; - extern u8 D_80181060[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018104C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80181038; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80181060; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80167714); - - -extern void (*D_80181118[])(void); - -void func_801678B4(void *a0) { - D_80181118[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181124[])(void); - -void func_80167A9C(void *a0) { - D_80181124[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181230; - extern u8 D_80181244[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181230); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181244; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80181084[]; -extern u8 D_80181098[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80181084; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181098; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018113C[])(void); - -void func_80168744(void *a0) { - D_8018113C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018112C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018112C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018112C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181144[])(void); - -void func_801689D8(void *a0) { - D_80181144[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018114C[])(void); - -void func_80168AA8(void *a0) { - D_8018114C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181154[])(void); - -void func_80168D58(void *a0) { - D_80181154[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018115C[])(void); - -void func_8016901C(void *a0) { - D_8018115C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015AE2C", func_80169228); - - -extern void (*D_80181164[])(void); - -void func_801693CC(void *a0) { - D_80181164[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018116C[])(void); - -void func_80169830(void *a0) { - D_8018116C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181220[])(void); - -void func_80169B80(void *a0) { - D_80181220[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181174[]; - extern u8 D_801811E4[]; - extern u8 D_80181214[]; - extern u8 D_80195018[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181214, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181174[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80195018; - RotMatrixYXZ(rot, D_80195018); - func_80048D9C(D_80195018, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801811E4); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181228[])(void); - -void func_80169F00(void *a0) { - D_80181228[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801811D8[]; -extern char D_80181198[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801811D8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181198); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181260[])(void); - -void func_8016A020(void *a0) { - D_80181260[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181230; - extern u8 D_80181244[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181230); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181244; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018126C[])(void); - -void func_8016A700(void *a0) { - D_8018126C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801812B4[])(void); - -void func_8016AB30(void *a0) { - D_801812B4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c b/src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c new file mode 100644 index 000000000..1818f29d6 --- /dev/null +++ b/src/ov_SC03_012/ov_SC03_012_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180680; +extern u8 D_801805F0; +extern u8 D_801805CC; +extern u8 D_801805A8; +extern u8 D_8018065C; +extern u8 D_80180638; +extern u8 D_80180614; +extern u8 D_80180584; +extern void func_80145934(void); +extern u8 D_80180710; +extern u8 D_801806EC; +extern u8 D_801806C8; +extern u8 D_801806A4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8017FB08[]; +extern unsigned char D_8017FB38[]; +extern unsigned char D_8017FB88[]; +extern unsigned char D_8017FBB8[]; +extern unsigned char D_8017FBE8[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8017FC38[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8017FD00[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8017FD88[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8017FD90; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80193E48; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_80193E4C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8017FDC0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8017FE68[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8017FE8C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8017FE7C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8017FEA0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8017FEAC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8017FEBC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8017FED4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8017FEC4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8017FEE8[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8017FF04[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8017FEF4; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8017FF18[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8017FF2C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8017FF40; +extern void (*D_8017FF68[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8017FF48; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8017FFB4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8017FFB8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018041C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018042C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80193E80; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180454[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180434; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180444; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180494[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018049C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180468; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801804A8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180478; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80193E88; +extern s32 D_80193E94; +extern s32 D_80193E98; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801804E4[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801804B8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80193E90; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80180734[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180554[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801807D8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018092C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80180748; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80180934[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80180758; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80180778; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018093C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80180964[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801807E4[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80180970[])(void); + +void func_8015C714(void *a0) { + D_80180970[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801807E4[])(void*); + extern int D_80180788; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801807E4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801807E4)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180788); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801807E4[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801807E4[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801807E4[])(void*); + extern int D_80180788; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801807E4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180788); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801807E4)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80180980[])(void); + D_80180980[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801807E4[])(struct Ent_8015CD20 *); + extern u8 D_80180798; + extern u8 D_80180988; + extern u8 D_80180998; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801807E4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180798); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180988); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180998); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801807E4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801809B8[])(void); + D_801809B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801809A8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801809A8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801807E4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80180A14; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80180A14, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8017FAF8[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8017FAF8; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80180A1C[])(void); + D_80180A1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80180A28[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80180A28[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80180A28[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80180A28[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801807E4[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80180A28[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801807A8[]; + extern u8 D_801807B8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801807A8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801807B8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80180A28[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180A28[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180A28[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80180A5C[])(void); + D_80180A5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801807E4[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180A64[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80180A7C[])(void); + D_80180A7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801807E4[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180A64[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180A64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80180A9C[])(void); + D_80180A9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801807E4[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801807E4)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80180AAC; +extern u16 D_80180AAE; +extern u16 D_80180AB0; +extern s32 D_80180AB4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80180AAC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80180AAE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80180AB0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180AB4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80180ABC; + +void func_8015E588(void) { + func_8013C9C4(&D_80180ABC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801807E4[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801807E4)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80180AD0[])(void); + D_80180AD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801807E4[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801807E4[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80180AD8[])(void); + D_80180AD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801807C8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801807C8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801807E4[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80180AE0[])(void); + D_80180AE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801807E4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801807E4[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80180AE8[])(void); + D_80180AE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801807E4[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80180AF0; + extern s32 D_80180B00; + extern s32 D_80180B10; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180AF0); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B00); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801807E4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B10); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80180B20[])(void); + D_80180B20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801807E4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801807E4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801807E4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801807E4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80180B2C[])(void); + D_80180B2C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801807E4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801807E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801807E4[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801807E4[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80180B40[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80180B40[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801807E4[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801807E4)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801807E4[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801807E4[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80180BBC[])(void); + D_80180BBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801807E4[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801807E4)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80180BCC[])(void); + D_80180BCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801807E4[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801807E4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801807E4[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801807E4[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801807E4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801807E4[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801807E4[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80180BD4[])(void); + D_80180BD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801807E4[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801807E4)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801807E4[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801807E4)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80180BE0[])(void); + D_80180BE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801807E4 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801807E4[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801807E4[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801807E4[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80180BF0[])(void); + +void func_80160EA4(void *a0) { + D_80180BF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801807E4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801807E4[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80180C20[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80180C20[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80180C84; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80180C84); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80193EA0[]; + extern u8 D_80180C50[]; + extern u8 D_80180C70[]; + extern u8 D_80193EAC[]; + extern u8 D_80193ED4[]; + extern u8 D_80193EEC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80193EA0[0] = p; + func_80024054(&D_80180C50, &D_80193EAC); + func_8001CE28(p, &D_80193EAC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80193EA0[1] = p; + func_80024054(&D_80180C70, &D_80193ED4); + func_8001CE28(p, &D_80193ED4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80193EA0[2] = p; + func_800242D0((s16)func_801620C4(), &D_80193EEC, 0x84); + func_8001CE68(p, &D_80193EEC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80193EEC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80193EA0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80193EA0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80180C84; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80180C84; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80180C84; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80180C84; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80193EA0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80193EA0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80180CA8[])(void); + +void func_80162330(void *a0) { + D_80180CA8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80193EF8[i] via `extern int D_80193EF8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80180CB4[]; + extern s32 D_80180CCC; + extern u8 D_80193F04[]; + extern u8 D_80193F2C[]; + extern u8 D_80193F48[]; + extern int D_80193EF8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80193EF8[0] = (s32)item; + func_80024054(D_80180CB4, D_80193F04); + func_8001CE28(item, D_80193F04); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80193EF8[1] = (s32)item; + func_80024054(((u8 *)&D_80180CCC), D_80193F2C); + func_8001CE28(item, D_80193F2C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80193EF8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80193F48, 0x84); + func_8001CE68(item, D_80193F48); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80193F48, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80193EF8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80193EF8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_801627E8); + + +extern void (*D_80180CF0[])(void); + +void func_80162834(void *a0) { + D_80180CF0[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80180CE0; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80180CE0, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80193750[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80193750, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80193750[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80193750, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80180CF8[])(void); + +void func_80163A58(void *a0) { + D_80180CF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80193758; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80193758; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80180D4C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80180D4C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80180D14; +extern s16 D_80180D48; +extern s16 D_80180D46; +extern s16 D_80180D44; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80180D14; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80180D48 = 0x80; + D_80180D46 = 0x80; + D_80180D44 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80180D48 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180D48` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80180D48 - 8; + D_80180D48 = nv; + D_80180D46 = nv; + D_80180D44 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80180D58[])(void); + +void func_80164BA0(void *a0) { + D_80180D58[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80193F58; +extern u8 D_80193F59; +extern u8 D_80193F5A; +extern u8 D_80193F5B; +extern u8 D_80193F5C; +extern u8 D_80193F5D; +extern u8 D_80193F5E; +extern u8 D_80193F5F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80193F58; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80193F59 = 0xf0; + *(u8 *)base = 0xf0; + D_80193F5A = 0xc0; + D_80193F5E = 0; + D_80193F5D = 0; + D_80193F5C = 0; + D_80193F5F = 0; + D_80193F5B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80193F58; +extern u8 D_80193F59; +extern u8 D_80193F5A; + +s32 func_80164E40(void) { + u8 *p = &D_80193F58; + if (*p != 0) { + *p -= 0x10; + } + if (D_80193F59 != 0) { + D_80193F59 -= 0x10; + } + if (D_80193F5A != 0) { + D_80193F5A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80180D68[])(void); + +void func_80164EA4(void *a0) { + D_80180D68[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80193FA4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80193FA4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80193F98[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80193F98[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80193F98[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80193F98; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80193F98; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80180D7C[]; + extern u32 D_80180D9C, D_80180DA0, D_80180DA4, D_80180DA8; + extern u32 D_80180D9C, D_80180DA0, D_80180DA4, D_80180DA8; + extern u32 D_80180D9C, D_80180DA0, D_80180DA4, D_80180DA8; + extern u32 D_80180D9C, D_80180DA0, D_80180DA4, D_80180DA8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80180D7C[0x00], p); + ApplyMatrixSV(mat, &D_80180D7C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80180D7C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80180D7C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80180DA4; + *(u32 *)(prim + 0x24) = D_80180D9C; + *(u32 *)(prim + 0x28) = D_80180DA8; + *(u32 *)(prim + 0x2c) = D_80180DA0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80180DAC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80180DAC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80180DAC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80180DAC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80180E28[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80180E28[a1 & 0x7F]; +} + + + +extern s32 D_80180E48[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80180E48[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80180EC4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80180EC4[a1 & 0x7F]; +} + + + +extern u8 D_80180EE4[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80180EE4[a1 & 0x7F]; +} + + + +extern u8 D_80180F04[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80180F04[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80180F24[])(void); + D_80180F24[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80180FA0[])(void); + +void func_80165AC8(void) { + D_80180FA0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018101C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018101C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80193760; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80193760, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80181028[])(void); + +void func_80166018(void *a0) { + D_80181028[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181030[])(void); + +void func_801663FC(void *a0) { + D_80181030[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801810F8[])(void); + +void func_80166618(void *a0) { + D_801810F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181108[])(void); + +void func_80166654(void *a0) { + D_80181108[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80194018[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80194018[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80194018). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80194018[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80194018)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80194018[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80194018[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018104C[]; + extern u8 D_80181038[]; + extern u8 D_80181060[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018104C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80181038; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80181060; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80167714); + + +extern void (*D_80181118[])(void); + +void func_801678B4(void *a0) { + D_80181118[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181124[])(void); + +void func_80167A9C(void *a0) { + D_80181124[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181230; + extern u8 D_80181244[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181230); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181244; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80181084[]; +extern u8 D_80181098[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80181084; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181098; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018113C[])(void); + +void func_80168744(void *a0) { + D_8018113C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018112C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018112C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018112C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181144[])(void); + +void func_801689D8(void *a0) { + D_80181144[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018114C[])(void); + +void func_80168AA8(void *a0) { + D_8018114C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181154[])(void); + +void func_80168D58(void *a0) { + D_80181154[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018115C[])(void); + +void func_8016901C(void *a0) { + D_8018115C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_012/nonmatchings/ov_SC03_012_jr_8015C32C", func_80169228); + + +extern void (*D_80181164[])(void); + +void func_801693CC(void *a0) { + D_80181164[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018116C[])(void); + +void func_80169830(void *a0) { + D_8018116C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181220[])(void); + +void func_80169B80(void *a0) { + D_80181220[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181174[]; + extern u8 D_801811E4[]; + extern u8 D_80181214[]; + extern u8 D_80195018[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181214, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181174[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80195018; + RotMatrixYXZ(rot, D_80195018); + func_80048D9C(D_80195018, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801811E4); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181228[])(void); + +void func_80169F00(void *a0) { + D_80181228[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801811D8[]; +extern char D_80181198[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801811D8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181198); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181260[])(void); + +void func_8016A020(void *a0) { + D_80181260[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181230; + extern u8 D_80181244[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181230); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181244; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018126C[])(void); + +void func_8016A700(void *a0) { + D_8018126C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801812B4[])(void); + +void func_8016AB30(void *a0) { + D_801812B4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_013/ov_SC03_013_jr_8015AE2C.c b/src/ov_SC03_013/ov_SC03_013_jr_8015AE2C.c index 8562b363b..3b39e25e9 100644 --- a/src/ov_SC03_013/ov_SC03_013_jr_8015AE2C.c +++ b/src/ov_SC03_013/ov_SC03_013_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80183758[])(void); - -void func_8015C714(void *a0) { - D_80183758[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801835CC[])(void*); - extern int D_80183570; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801835CC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801835CC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183570); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801835CC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801835CC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801835CC[])(void*); - extern int D_80183570; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801835CC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183570); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801835CC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80183768[])(void); - D_80183768[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801835CC[])(struct Ent_8015CD20 *); - extern u8 D_80183580; - extern u8 D_80183770; - extern u8 D_80183780; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801835CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183580); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183770); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183780); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801835CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801837A0[])(void); - D_801837A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80183790; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80183790 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801835CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801837FC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801837FC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801828E0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801828E0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80183804[])(void); - D_80183804[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80183810[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80183810[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80183810[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80183810[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801835CC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80183810[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80183590[]; - extern u8 D_801835A0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183590); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801835A0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80183810[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183810[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183810[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80183844[])(void); - D_80183844[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801835CC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018384C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80183864[])(void); - D_80183864[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801835CC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018384C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80183884[])(void); - D_80183884[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801835CC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801835CC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80183894; -extern u16 D_80183896; -extern u16 D_80183898; -extern s32 D_8018389C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80183894 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80183896 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80183898 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018389C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801838A4; - -void func_8015E588(void) { - func_8013C9C4(&D_801838A4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801835CC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801835CC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801838B8[])(void); - D_801838B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801835CC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801835CC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801838C0[])(void); - D_801838C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801835B0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801835B0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801835CC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801838C8[])(void); - D_801838C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801835CC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801835CC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801838D0[])(void); - D_801838D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801835CC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801838D8; - extern s32 D_801838E8; - extern s32 D_801838F8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801835CC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838D8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838E8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801835CC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838F8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80183908[])(void); - D_80183908[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801835CC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801835CC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801835CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801835CC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80183914[])(void); - D_80183914[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801835CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801835CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801835CC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801835CC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80183928[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80183928[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801835CC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801835CC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801835CC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801835CC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801839A4[])(void); - D_801839A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801835CC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801835CC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801839B4[])(void); - D_801839B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801835CC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801835CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801835CC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801835CC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801835CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801835CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801835CC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801839BC[])(void); - D_801839BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801835CC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801835CC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801835CC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801835CC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801839C8[])(void); - D_801839C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801835CC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801835CC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801835CC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801835CC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801839D8[])(void); - -void func_80160EA4(void *a0) { - D_801839D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801835CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801835CC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80183A08[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80183A08[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80183A6C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80183A6C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801AC170[]; - extern u8 D_80183A38[]; - extern u8 D_80183A58[]; - extern u8 D_801AC17C[]; - extern u8 D_801AC1A4[]; - extern u8 D_801AC1BC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801AC170[0] = p; - func_80024054(&D_80183A38, &D_801AC17C); - func_8001CE28(p, &D_801AC17C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801AC170[1] = p; - func_80024054(&D_80183A58, &D_801AC1A4); - func_8001CE28(p, &D_801AC1A4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801AC170[2] = p; - func_800242D0((s16)func_801620C4(), &D_801AC1BC, 0x84); - func_8001CE68(p, &D_801AC1BC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801AC1BC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801AC170[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801AC170; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80183A6C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80183A6C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80183A6C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80183A6C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801AC170[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801AC170; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80183A90[])(void); - -void func_80162330(void *a0) { - D_80183A90[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801AC1C8[i] via `extern int D_801AC1C8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80183A9C[]; - extern s32 D_80183AB4; - extern u8 D_801AC1D4[]; - extern u8 D_801AC1FC[]; - extern u8 D_801AC218[]; - extern int D_801AC1C8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801AC1C8[0] = (s32)item; - func_80024054(D_80183A9C, D_801AC1D4); - func_8001CE28(item, D_801AC1D4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801AC1C8[1] = (s32)item; - func_80024054(((u8 *)&D_80183AB4), D_801AC1FC); - func_8001CE28(item, D_801AC1FC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801AC1C8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801AC218, 0x84); - func_8001CE68(item, D_801AC218); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801AC218, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801AC1C8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801AC1C8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_801627E8); - - -extern void (*D_80183AD8[])(void); - -void func_80162834(void *a0) { - D_80183AD8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80183AC8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80183AC8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801AB9E8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801AB9E8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801AB9E8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801AB9E8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80183AE0[])(void); - -void func_80163A58(void *a0) { - D_80183AE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801AB9F0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801AB9F0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80183B34[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80183B34[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80183AFC; -extern s16 D_80183B30; -extern s16 D_80183B2E; -extern s16 D_80183B2C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80183AFC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80183B30 = 0x80; - D_80183B2E = 0x80; - D_80183B2C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80183B30 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80183B30` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80183B30 - 8; - D_80183B30 = nv; - D_80183B2E = nv; - D_80183B2C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80183B40[])(void); - -void func_80164BA0(void *a0) { - D_80183B40[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801AC228; -extern u8 D_801AC229; -extern u8 D_801AC22A; -extern u8 D_801AC22B; -extern u8 D_801AC22C; -extern u8 D_801AC22D; -extern u8 D_801AC22E; -extern u8 D_801AC22F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801AC228; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801AC229 = 0xf0; - *(u8 *)base = 0xf0; - D_801AC22A = 0xc0; - D_801AC22E = 0; - D_801AC22D = 0; - D_801AC22C = 0; - D_801AC22F = 0; - D_801AC22B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801AC228; -extern u8 D_801AC229; -extern u8 D_801AC22A; - -s32 func_80164E40(void) { - u8 *p = &D_801AC228; - if (*p != 0) { - *p -= 0x10; - } - if (D_801AC229 != 0) { - D_801AC229 -= 0x10; - } - if (D_801AC22A != 0) { - D_801AC22A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80183B50[])(void); - -void func_80164EA4(void *a0) { - D_80183B50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801AC274[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801AC274[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801AC268[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801AC268[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801AC268[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801AC268; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801AC268; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80183B64[]; - extern u32 D_80183B84, D_80183B88, D_80183B8C, D_80183B90; - extern u32 D_80183B84, D_80183B88, D_80183B8C, D_80183B90; - extern u32 D_80183B84, D_80183B88, D_80183B8C, D_80183B90; - extern u32 D_80183B84, D_80183B88, D_80183B8C, D_80183B90; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80183B64[0x00], p); - ApplyMatrixSV(mat, &D_80183B64[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80183B64[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80183B64[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80183B8C; - *(u32 *)(prim + 0x24) = D_80183B84; - *(u32 *)(prim + 0x28) = D_80183B90; - *(u32 *)(prim + 0x2c) = D_80183B88; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80183B94[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80183B94[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80183B94[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80183B94[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80183C10[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80183C10[a1 & 0x7F]; -} - - - -extern s32 D_80183C30[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80183C30[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80183CAC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80183CAC[a1 & 0x7F]; -} - - - -extern u8 D_80183CCC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80183CCC[a1 & 0x7F]; -} - - - -extern u8 D_80183CEC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80183CEC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80183D0C[])(void); - D_80183D0C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80183D88[])(void); - -void func_80165AC8(void) { - D_80183D88[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80183E04[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80183E04[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801AB9F8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801AB9F8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80183E10[])(void); - -void func_80166018(void *a0) { - D_80183E10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80183E18[])(void); - -void func_801663FC(void *a0) { - D_80183E18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80183EE0[])(void); - -void func_80166618(void *a0) { - D_80183EE0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80183EF0[])(void); - -void func_80166654(void *a0) { - D_80183EF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801AC2E8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801AC2E8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801AC2E8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801AC2E8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801AC2E8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801AC2E8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801AC2E8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80183E34[]; - extern u8 D_80183E20[]; - extern u8 D_80183E48[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80183E34; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80183E20; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80183E48; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80167714); - - -extern void (*D_80183F00[])(void); - -void func_801678B4(void *a0) { - D_80183F00[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80183F0C[])(void); - -void func_80167A9C(void *a0) { - D_80183F0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80184018; - extern u8 D_8018402C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80184018); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018402C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80183E6C[]; -extern u8 D_80183E80[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80183E6C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80183E80; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80183F24[])(void); - -void func_80168744(void *a0) { - D_80183F24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80183F14 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80183F14[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80183F14; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80183F2C[])(void); - -void func_801689D8(void *a0) { - D_80183F2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80183F34[])(void); - -void func_80168AA8(void *a0) { - D_80183F34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80183F3C[])(void); - -void func_80168D58(void *a0) { - D_80183F3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80183F44[])(void); - -void func_8016901C(void *a0) { - D_80183F44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015AE2C", func_80169228); - - -extern void (*D_80183F4C[])(void); - -void func_801693CC(void *a0) { - D_80183F4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80183F54[])(void); - -void func_80169830(void *a0) { - D_80183F54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80184008[])(void); - -void func_80169B80(void *a0) { - D_80184008[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80183F5C[]; - extern u8 D_80183FCC[]; - extern u8 D_80183FFC[]; - extern u8 D_801AD410[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80183FFC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80183F5C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801AD410; - RotMatrixYXZ(rot, D_801AD410); - func_80048D9C(D_801AD410, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80183FCC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80184010[])(void); - -void func_80169F00(void *a0) { - D_80184010[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80183FC0[]; -extern char D_80183F80[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80183FC0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183F80); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80184048[])(void); - -void func_8016A020(void *a0) { - D_80184048[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80184018; - extern u8 D_8018402C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80184018); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018402C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80184054[])(void); - -void func_8016A700(void *a0) { - D_80184054[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018409C[])(void); - -void func_8016AB30(void *a0) { - D_8018409C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c b/src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c new file mode 100644 index 000000000..bc951a7c0 --- /dev/null +++ b/src/ov_SC03_013/ov_SC03_013_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80183468; +extern u8 D_801833D8; +extern u8 D_801833B4; +extern u8 D_80183390; +extern u8 D_80183444; +extern u8 D_80183420; +extern u8 D_801833FC; +extern u8 D_8018336C; +extern void func_80145934(void); +extern u8 D_801834F8; +extern u8 D_801834D4; +extern u8 D_801834B0; +extern u8 D_8018348C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801828F0[]; +extern unsigned char D_80182920[]; +extern unsigned char D_80182970[]; +extern unsigned char D_801829A0[]; +extern unsigned char D_801829D0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80182A20[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80182AE8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80182B70[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80182B78; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801AC118; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801AC11C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80182BA8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80182C50[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80182C74[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80182C64; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80182C88[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80182C94[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80182CA4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80182CBC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80182CAC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80182CD0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80182CEC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80182CDC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80182D00[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80182D14[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80182D28; +extern void (*D_80182D50[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80182D30; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80182D9C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80182DA0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80183204[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80183214[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801AC150; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018323C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018321C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018322C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018327C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80183284[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80183250; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80183290[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80183260; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801AC158; +extern s32 D_801AC164; +extern s32 D_801AC168; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801832CC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801832A0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801AC160; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018351C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018333C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801835C0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80183714[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80183530; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018371C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80183540; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80183560; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80183724[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018374C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801835CC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80183758[])(void); + +void func_8015C714(void *a0) { + D_80183758[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801835CC[])(void*); + extern int D_80183570; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801835CC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801835CC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183570); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801835CC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801835CC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801835CC[])(void*); + extern int D_80183570; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801835CC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183570); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801835CC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80183768[])(void); + D_80183768[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801835CC[])(struct Ent_8015CD20 *); + extern u8 D_80183580; + extern u8 D_80183770; + extern u8 D_80183780; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801835CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183580); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183770); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183780); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801835CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801837A0[])(void); + D_801837A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80183790; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80183790 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801835CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801837FC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801837FC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801828E0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801828E0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80183804[])(void); + D_80183804[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80183810[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80183810[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80183810[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80183810[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801835CC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80183810[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80183590[]; + extern u8 D_801835A0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183590); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801835A0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80183810[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183810[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183810[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80183844[])(void); + D_80183844[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801835CC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018384C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80183864[])(void); + D_80183864[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801835CC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018384C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018384C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80183884[])(void); + D_80183884[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801835CC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801835CC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80183894; +extern u16 D_80183896; +extern u16 D_80183898; +extern s32 D_8018389C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80183894 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80183896 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80183898 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018389C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801838A4; + +void func_8015E588(void) { + func_8013C9C4(&D_801838A4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801835CC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801835CC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801838B8[])(void); + D_801838B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801835CC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801835CC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801838C0[])(void); + D_801838C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801835B0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801835B0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801835CC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801838C8[])(void); + D_801838C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801835CC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801835CC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801838D0[])(void); + D_801838D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801835CC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801838D8; + extern s32 D_801838E8; + extern s32 D_801838F8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838D8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838E8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801835CC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838F8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80183908[])(void); + D_80183908[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801835CC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801835CC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801835CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801835CC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80183914[])(void); + D_80183914[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801835CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801835CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801835CC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801835CC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80183928[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80183928[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801835CC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801835CC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801835CC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801835CC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801839A4[])(void); + D_801839A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801835CC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801835CC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801839B4[])(void); + D_801839B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801835CC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801835CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801835CC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801835CC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801835CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801835CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801835CC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801839BC[])(void); + D_801839BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801835CC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801835CC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801835CC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801835CC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801839C8[])(void); + D_801839C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801835CC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801835CC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801835CC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801835CC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801839D8[])(void); + +void func_80160EA4(void *a0) { + D_801839D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801835CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801835CC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80183A08[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80183A08[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80183A6C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80183A6C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801AC170[]; + extern u8 D_80183A38[]; + extern u8 D_80183A58[]; + extern u8 D_801AC17C[]; + extern u8 D_801AC1A4[]; + extern u8 D_801AC1BC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801AC170[0] = p; + func_80024054(&D_80183A38, &D_801AC17C); + func_8001CE28(p, &D_801AC17C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801AC170[1] = p; + func_80024054(&D_80183A58, &D_801AC1A4); + func_8001CE28(p, &D_801AC1A4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801AC170[2] = p; + func_800242D0((s16)func_801620C4(), &D_801AC1BC, 0x84); + func_8001CE68(p, &D_801AC1BC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801AC1BC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801AC170[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801AC170; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80183A6C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80183A6C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80183A6C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80183A6C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801AC170[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801AC170; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80183A90[])(void); + +void func_80162330(void *a0) { + D_80183A90[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801AC1C8[i] via `extern int D_801AC1C8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80183A9C[]; + extern s32 D_80183AB4; + extern u8 D_801AC1D4[]; + extern u8 D_801AC1FC[]; + extern u8 D_801AC218[]; + extern int D_801AC1C8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801AC1C8[0] = (s32)item; + func_80024054(D_80183A9C, D_801AC1D4); + func_8001CE28(item, D_801AC1D4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801AC1C8[1] = (s32)item; + func_80024054(((u8 *)&D_80183AB4), D_801AC1FC); + func_8001CE28(item, D_801AC1FC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801AC1C8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801AC218, 0x84); + func_8001CE68(item, D_801AC218); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801AC218, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801AC1C8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801AC1C8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_801627E8); + + +extern void (*D_80183AD8[])(void); + +void func_80162834(void *a0) { + D_80183AD8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80183AC8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80183AC8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801AB9E8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801AB9E8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801AB9E8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801AB9E8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80183AE0[])(void); + +void func_80163A58(void *a0) { + D_80183AE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801AB9F0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801AB9F0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80183B34[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80183B34[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80183AFC; +extern s16 D_80183B30; +extern s16 D_80183B2E; +extern s16 D_80183B2C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80183AFC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80183B30 = 0x80; + D_80183B2E = 0x80; + D_80183B2C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80183B30 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80183B30` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80183B30 - 8; + D_80183B30 = nv; + D_80183B2E = nv; + D_80183B2C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80183B40[])(void); + +void func_80164BA0(void *a0) { + D_80183B40[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801AC228; +extern u8 D_801AC229; +extern u8 D_801AC22A; +extern u8 D_801AC22B; +extern u8 D_801AC22C; +extern u8 D_801AC22D; +extern u8 D_801AC22E; +extern u8 D_801AC22F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801AC228; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801AC229 = 0xf0; + *(u8 *)base = 0xf0; + D_801AC22A = 0xc0; + D_801AC22E = 0; + D_801AC22D = 0; + D_801AC22C = 0; + D_801AC22F = 0; + D_801AC22B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801AC228; +extern u8 D_801AC229; +extern u8 D_801AC22A; + +s32 func_80164E40(void) { + u8 *p = &D_801AC228; + if (*p != 0) { + *p -= 0x10; + } + if (D_801AC229 != 0) { + D_801AC229 -= 0x10; + } + if (D_801AC22A != 0) { + D_801AC22A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80183B50[])(void); + +void func_80164EA4(void *a0) { + D_80183B50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801AC274[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801AC274[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801AC268[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801AC268[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801AC268[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801AC268; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801AC268; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80183B64[]; + extern u32 D_80183B84, D_80183B88, D_80183B8C, D_80183B90; + extern u32 D_80183B84, D_80183B88, D_80183B8C, D_80183B90; + extern u32 D_80183B84, D_80183B88, D_80183B8C, D_80183B90; + extern u32 D_80183B84, D_80183B88, D_80183B8C, D_80183B90; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80183B64[0x00], p); + ApplyMatrixSV(mat, &D_80183B64[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80183B64[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80183B64[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80183B8C; + *(u32 *)(prim + 0x24) = D_80183B84; + *(u32 *)(prim + 0x28) = D_80183B90; + *(u32 *)(prim + 0x2c) = D_80183B88; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80183B94[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80183B94[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80183B94[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80183B94[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80183C10[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80183C10[a1 & 0x7F]; +} + + + +extern s32 D_80183C30[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80183C30[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80183CAC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80183CAC[a1 & 0x7F]; +} + + + +extern u8 D_80183CCC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80183CCC[a1 & 0x7F]; +} + + + +extern u8 D_80183CEC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80183CEC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80183D0C[])(void); + D_80183D0C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80183D88[])(void); + +void func_80165AC8(void) { + D_80183D88[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80183E04[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80183E04[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801AB9F8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801AB9F8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80183E10[])(void); + +void func_80166018(void *a0) { + D_80183E10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80183E18[])(void); + +void func_801663FC(void *a0) { + D_80183E18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80183EE0[])(void); + +void func_80166618(void *a0) { + D_80183EE0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80183EF0[])(void); + +void func_80166654(void *a0) { + D_80183EF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801AC2E8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801AC2E8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801AC2E8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801AC2E8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801AC2E8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801AC2E8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801AC2E8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80183E34[]; + extern u8 D_80183E20[]; + extern u8 D_80183E48[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80183E34; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80183E20; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80183E48; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80167714); + + +extern void (*D_80183F00[])(void); + +void func_801678B4(void *a0) { + D_80183F00[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80183F0C[])(void); + +void func_80167A9C(void *a0) { + D_80183F0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80184018; + extern u8 D_8018402C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80184018); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018402C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80183E6C[]; +extern u8 D_80183E80[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80183E6C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80183E80; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80183F24[])(void); + +void func_80168744(void *a0) { + D_80183F24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80183F14 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80183F14[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80183F14; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80183F2C[])(void); + +void func_801689D8(void *a0) { + D_80183F2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80183F34[])(void); + +void func_80168AA8(void *a0) { + D_80183F34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80183F3C[])(void); + +void func_80168D58(void *a0) { + D_80183F3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80183F44[])(void); + +void func_8016901C(void *a0) { + D_80183F44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_013/nonmatchings/ov_SC03_013_jr_8015C32C", func_80169228); + + +extern void (*D_80183F4C[])(void); + +void func_801693CC(void *a0) { + D_80183F4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80183F54[])(void); + +void func_80169830(void *a0) { + D_80183F54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80184008[])(void); + +void func_80169B80(void *a0) { + D_80184008[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80183F5C[]; + extern u8 D_80183FCC[]; + extern u8 D_80183FFC[]; + extern u8 D_801AD410[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80183FFC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80183F5C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801AD410; + RotMatrixYXZ(rot, D_801AD410); + func_80048D9C(D_801AD410, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80183FCC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80184010[])(void); + +void func_80169F00(void *a0) { + D_80184010[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80183FC0[]; +extern char D_80183F80[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80183FC0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183F80); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80184048[])(void); + +void func_8016A020(void *a0) { + D_80184048[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80184018; + extern u8 D_8018402C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80184018); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018402C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80184054[])(void); + +void func_8016A700(void *a0) { + D_80184054[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018409C[])(void); + +void func_8016AB30(void *a0) { + D_8018409C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_014/ov_SC03_014_jr_8015AE2C.c b/src/ov_SC03_014/ov_SC03_014_jr_8015AE2C.c index ad4350787..f8cef4f33 100644 --- a/src/ov_SC03_014/ov_SC03_014_jr_8015AE2C.c +++ b/src/ov_SC03_014/ov_SC03_014_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018DD94[])(void); - -void func_8015C714(void *a0) { - D_8018DD94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018DC08[])(void*); - extern int D_8018DBAC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DBAC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018DC08[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018DC08[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018DC08[])(void*); - extern int D_8018DBAC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DBAC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018DDA4[])(void); - D_8018DDA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018DC08[])(struct Ent_8015CD20 *); - extern u8 D_8018DBBC; - extern u8 D_8018DDAC; - extern u8 D_8018DDBC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018DC08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DBBC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DDAC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DDBC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018DC08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018DDDC[])(void); - D_8018DDDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018DDCC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018DDCC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018DC08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018DE38; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018DE38, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018CF1C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018CF1C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018DE40[])(void); - D_8018DE40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018DE4C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018DE4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018DE4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018DE4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018DC08[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018DE4C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018DBCC[]; - extern u8 D_8018DBDC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DBCC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DBDC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018DE80[])(void); - D_8018DE80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018DC08[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018DE88[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018DEA0[])(void); - D_8018DEA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018DC08[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018DE88[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018DEC0[])(void); - D_8018DEC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018DC08[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018DC08)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018DED0; -extern u16 D_8018DED2; -extern u16 D_8018DED4; -extern s32 D_8018DED8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018DED0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018DED2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018DED4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018DED8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018DEE0; - -void func_8015E588(void) { - func_8013C9C4(&D_8018DEE0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018DC08[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018DC08)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018DEF4[])(void); - D_8018DEF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018DC08[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018DC08[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018DEFC[])(void); - D_8018DEFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018DBEC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018DBEC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018DC08[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018DF04[])(void); - D_8018DF04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018DC08[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018DC08[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018DF0C[])(void); - D_8018DF0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018DC08[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018DF14; - extern s32 D_8018DF24; - extern s32 D_8018DF34; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018DC08[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF14); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF24); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018DC08[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF34); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018DF44[])(void); - D_8018DF44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018DC08[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018DC08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018DF50[])(void); - D_8018DF50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018DC08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018DC08[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018DC08[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018DF64[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018DF64[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018DC08[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018DC08)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018DC08[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018DC08[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018DFE0[])(void); - D_8018DFE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018DC08[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018DC08)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018DFF0[])(void); - D_8018DFF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018DC08[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018DC08[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018DC08[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018DC08[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018DC08[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018DC08[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018DC08[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018DFF8[])(void); - D_8018DFF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018DC08[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018DC08)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018DC08[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018E004[])(void); - D_8018E004[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018DC08 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018DC08[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018DC08[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018DC08[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018E014[])(void); - -void func_80160EA4(void *a0) { - D_8018E014[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018DC08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018DC08[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018E044[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018E044[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018E0A8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018E0A8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E96F0[]; - extern u8 D_8018E074[]; - extern u8 D_8018E094[]; - extern u8 D_801E96FC[]; - extern u8 D_801E9724[]; - extern u8 D_801E973C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E96F0[0] = p; - func_80024054(&D_8018E074, &D_801E96FC); - func_8001CE28(p, &D_801E96FC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E96F0[1] = p; - func_80024054(&D_8018E094, &D_801E9724); - func_8001CE28(p, &D_801E9724); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E96F0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E973C, 0x84); - func_8001CE68(p, &D_801E973C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E973C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E96F0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E96F0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018E0A8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018E0A8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018E0A8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018E0A8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E96F0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E96F0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018E0CC[])(void); - -void func_80162330(void *a0) { - D_8018E0CC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E9748[i] via `extern int D_801E9748[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018E0D8[]; - extern s32 D_8018E0F0; - extern u8 D_801E9754[]; - extern u8 D_801E977C[]; - extern u8 D_801E9798[]; - extern int D_801E9748[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E9748[0] = (s32)item; - func_80024054(D_8018E0D8, D_801E9754); - func_8001CE28(item, D_801E9754); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E9748[1] = (s32)item; - func_80024054(((u8 *)&D_8018E0F0), D_801E977C); - func_8001CE28(item, D_801E977C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E9748[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E9798, 0x84); - func_8001CE68(item, D_801E9798); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E9798, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E9748[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E9748; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018E114[])(void); - -void func_80162834(void *a0) { - D_8018E114[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018E104; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018E104, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E8DBC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E8DBC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E8DBC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E8DBC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018E11C[])(void); - -void func_80163A58(void *a0) { - D_8018E11C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E8DC4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E8DC4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018E170[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018E170[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018E138; -extern s16 D_8018E16C; -extern s16 D_8018E16A; -extern s16 D_8018E168; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018E138; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018E16C = 0x80; - D_8018E16A = 0x80; - D_8018E168 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018E16C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E16C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018E16C - 8; - D_8018E16C = nv; - D_8018E16A = nv; - D_8018E168 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018E17C[])(void); - -void func_80164BA0(void *a0) { - D_8018E17C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E97A8; -extern u8 D_801E97A9; -extern u8 D_801E97AA; -extern u8 D_801E97AB; -extern u8 D_801E97AC; -extern u8 D_801E97AD; -extern u8 D_801E97AE; -extern u8 D_801E97AF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E97A8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E97A9 = 0xf0; - *(u8 *)base = 0xf0; - D_801E97AA = 0xc0; - D_801E97AE = 0; - D_801E97AD = 0; - D_801E97AC = 0; - D_801E97AF = 0; - D_801E97AB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E97A8; -extern u8 D_801E97A9; -extern u8 D_801E97AA; - -s32 func_80164E40(void) { - u8 *p = &D_801E97A8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E97A9 != 0) { - D_801E97A9 -= 0x10; - } - if (D_801E97AA != 0) { - D_801E97AA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018E18C[])(void); - -void func_80164EA4(void *a0) { - D_8018E18C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E97F4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E97F4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E97E8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E97E8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E97E8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E97E8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E97E8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018E1A0[]; - extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; - extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; - extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; - extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018E1A0[0x00], p); - ApplyMatrixSV(mat, &D_8018E1A0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018E1A0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018E1A0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018E1C8; - *(u32 *)(prim + 0x24) = D_8018E1C0; - *(u32 *)(prim + 0x28) = D_8018E1CC; - *(u32 *)(prim + 0x2c) = D_8018E1C4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018E1D0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018E1D0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018E1D0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018E1D0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018E24C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018E24C[a1 & 0x7F]; -} - - - -extern s32 D_8018E26C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018E26C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018E2E8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018E2E8[a1 & 0x7F]; -} - - - -extern u8 D_8018E308[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018E308[a1 & 0x7F]; -} - - - -extern u8 D_8018E328[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018E328[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018E348[])(void); - D_8018E348[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018E3C4[])(void); - -void func_80165AC8(void) { - D_8018E3C4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018E440[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018E440[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E8DCC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E8DCC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018E44C[])(void); - -void func_80166018(void *a0) { - D_8018E44C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018E454[])(void); - -void func_801663FC(void *a0) { - D_8018E454[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018E51C[])(void); - -void func_80166618(void *a0) { - D_8018E51C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018E52C[])(void); - -void func_80166654(void *a0) { - D_8018E52C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E9868[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E9868[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E9868). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E9868[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E9868)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E9868[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E9868[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018E470[]; - extern u8 D_8018E45C[]; - extern u8 D_8018E484[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018E470; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018E45C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018E484; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80167714); - - -extern void (*D_8018E53C[])(void); - -void func_801678B4(void *a0) { - D_8018E53C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018E548[])(void); - -void func_80167A9C(void *a0) { - D_8018E548[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018E654; - extern u8 D_8018E668[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018E654); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018E668; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018E4A8[]; -extern u8 D_8018E4BC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018E4A8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018E4BC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018E560[])(void); - -void func_80168744(void *a0) { - D_8018E560[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018E550 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018E550[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018E550; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018E568[])(void); - -void func_801689D8(void *a0) { - D_8018E568[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018E570[])(void); - -void func_80168AA8(void *a0) { - D_8018E570[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018E578[])(void); - -void func_80168D58(void *a0) { - D_8018E578[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018E580[])(void); - -void func_8016901C(void *a0) { - D_8018E580[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015AE2C", func_80169228); - - -extern void (*D_8018E588[])(void); - -void func_801693CC(void *a0) { - D_8018E588[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018E590[])(void); - -void func_80169830(void *a0) { - D_8018E590[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018E644[])(void); - -void func_80169B80(void *a0) { - D_8018E644[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018E598[]; - extern u8 D_8018E608[]; - extern u8 D_8018E638[]; - extern u8 D_801EAEF8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018E638, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018E598[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801EAEF8; - RotMatrixYXZ(rot, D_801EAEF8); - func_80048D9C(D_801EAEF8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018E608); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018E64C[])(void); - -void func_80169F00(void *a0) { - D_8018E64C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018E5FC[]; -extern char D_8018E5BC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018E5FC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018E5BC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018E684[])(void); - -void func_8016A020(void *a0) { - D_8018E684[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018E654; - extern u8 D_8018E668[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018E654); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018E668; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018E690[])(void); - -void func_8016A700(void *a0) { - D_8018E690[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018E6D8[])(void); - -void func_8016AB30(void *a0) { - D_8018E6D8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c b/src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c new file mode 100644 index 000000000..8b5f7256f --- /dev/null +++ b/src/ov_SC03_014/ov_SC03_014_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018DAA4; +extern u8 D_8018DA14; +extern u8 D_8018D9F0; +extern u8 D_8018D9CC; +extern u8 D_8018DA80; +extern u8 D_8018DA5C; +extern u8 D_8018DA38; +extern u8 D_8018D9A8; +extern void func_80145934(void); +extern u8 D_8018DB34; +extern u8 D_8018DB10; +extern u8 D_8018DAEC; +extern u8 D_8018DAC8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018CF2C[]; +extern unsigned char D_8018CF5C[]; +extern unsigned char D_8018CFAC[]; +extern unsigned char D_8018CFDC[]; +extern unsigned char D_8018D00C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018D05C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018D124[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018D1AC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018D1B4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E9698; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E969C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018D1E4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018D28C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018D2B0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018D2A0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018D2C4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018D2D0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018D2E0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018D2F8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018D2E8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018D30C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018D328[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018D318; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018D33C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018D350[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018D364; +extern void (*D_8018D38C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018D36C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018D3D8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018D3DC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018D840[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018D850[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E96D0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018D878[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018D858; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018D868; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018D8B8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018D8C0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018D88C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018D8CC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018D89C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E96D8; +extern s32 D_801E96E4; +extern s32 D_801E96E8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018D908[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018D8DC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E96E0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018DB58[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018D978[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018DBFC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018DD50[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018DB6C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018DD58[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018DB7C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018DB9C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018DD60[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018DD88[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018DC08[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018DD94[])(void); + +void func_8015C714(void *a0) { + D_8018DD94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018DC08[])(void*); + extern int D_8018DBAC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DBAC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018DC08[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018DC08[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018DC08[])(void*); + extern int D_8018DBAC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DBAC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018DDA4[])(void); + D_8018DDA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018DC08[])(struct Ent_8015CD20 *); + extern u8 D_8018DBBC; + extern u8 D_8018DDAC; + extern u8 D_8018DDBC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018DC08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DBBC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DDAC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DDBC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018DC08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018DDDC[])(void); + D_8018DDDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018DDCC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018DDCC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018DC08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018DE38; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018DE38, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018CF1C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018CF1C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018DE40[])(void); + D_8018DE40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018DE4C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018DE4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018DE4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018DE4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018DC08[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018DE4C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018DBCC[]; + extern u8 D_8018DBDC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DBCC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DBDC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018DE80[])(void); + D_8018DE80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018DC08[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018DE88[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018DEA0[])(void); + D_8018DEA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018DC08[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018DE88[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018DEC0[])(void); + D_8018DEC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018DC08[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018DC08)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018DED0; +extern u16 D_8018DED2; +extern u16 D_8018DED4; +extern s32 D_8018DED8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018DED0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018DED2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018DED4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018DED8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018DEE0; + +void func_8015E588(void) { + func_8013C9C4(&D_8018DEE0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018DC08[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018DC08)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018DEF4[])(void); + D_8018DEF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018DC08[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018DC08[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018DEFC[])(void); + D_8018DEFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018DBEC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018DBEC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018DC08[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018DF04[])(void); + D_8018DF04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018DC08[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018DC08[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018DF0C[])(void); + D_8018DF0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018DC08[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018DF14; + extern s32 D_8018DF24; + extern s32 D_8018DF34; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF14); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF24); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF34); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018DF44[])(void); + D_8018DF44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018DC08[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018DC08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018DF50[])(void); + D_8018DF50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018DC08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018DC08[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018DC08[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018DF64[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018DF64[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018DC08[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018DC08)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018DC08[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018DC08[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018DFE0[])(void); + D_8018DFE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018DC08[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018DC08)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018DFF0[])(void); + D_8018DFF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018DC08[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018DC08[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018DC08[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018DC08[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018DC08[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018DC08[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018DC08[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018DFF8[])(void); + D_8018DFF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018DC08[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018DC08)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018DC08[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018E004[])(void); + D_8018E004[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018DC08 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018DC08[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018DC08[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018DC08[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018E014[])(void); + +void func_80160EA4(void *a0) { + D_8018E014[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018DC08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018DC08[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018E044[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018E044[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018E0A8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018E0A8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E96F0[]; + extern u8 D_8018E074[]; + extern u8 D_8018E094[]; + extern u8 D_801E96FC[]; + extern u8 D_801E9724[]; + extern u8 D_801E973C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E96F0[0] = p; + func_80024054(&D_8018E074, &D_801E96FC); + func_8001CE28(p, &D_801E96FC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E96F0[1] = p; + func_80024054(&D_8018E094, &D_801E9724); + func_8001CE28(p, &D_801E9724); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E96F0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E973C, 0x84); + func_8001CE68(p, &D_801E973C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E973C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E96F0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E96F0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018E0A8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018E0A8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018E0A8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018E0A8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E96F0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E96F0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018E0CC[])(void); + +void func_80162330(void *a0) { + D_8018E0CC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E9748[i] via `extern int D_801E9748[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018E0D8[]; + extern s32 D_8018E0F0; + extern u8 D_801E9754[]; + extern u8 D_801E977C[]; + extern u8 D_801E9798[]; + extern int D_801E9748[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E9748[0] = (s32)item; + func_80024054(D_8018E0D8, D_801E9754); + func_8001CE28(item, D_801E9754); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E9748[1] = (s32)item; + func_80024054(((u8 *)&D_8018E0F0), D_801E977C); + func_8001CE28(item, D_801E977C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E9748[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E9798, 0x84); + func_8001CE68(item, D_801E9798); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E9798, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E9748[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E9748; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_801627E8); + + +extern void (*D_8018E114[])(void); + +void func_80162834(void *a0) { + D_8018E114[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018E104; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018E104, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E8DBC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E8DBC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E8DBC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E8DBC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018E11C[])(void); + +void func_80163A58(void *a0) { + D_8018E11C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E8DC4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E8DC4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018E170[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018E170[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018E138; +extern s16 D_8018E16C; +extern s16 D_8018E16A; +extern s16 D_8018E168; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018E138; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018E16C = 0x80; + D_8018E16A = 0x80; + D_8018E168 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018E16C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E16C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018E16C - 8; + D_8018E16C = nv; + D_8018E16A = nv; + D_8018E168 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018E17C[])(void); + +void func_80164BA0(void *a0) { + D_8018E17C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E97A8; +extern u8 D_801E97A9; +extern u8 D_801E97AA; +extern u8 D_801E97AB; +extern u8 D_801E97AC; +extern u8 D_801E97AD; +extern u8 D_801E97AE; +extern u8 D_801E97AF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E97A8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E97A9 = 0xf0; + *(u8 *)base = 0xf0; + D_801E97AA = 0xc0; + D_801E97AE = 0; + D_801E97AD = 0; + D_801E97AC = 0; + D_801E97AF = 0; + D_801E97AB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E97A8; +extern u8 D_801E97A9; +extern u8 D_801E97AA; + +s32 func_80164E40(void) { + u8 *p = &D_801E97A8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E97A9 != 0) { + D_801E97A9 -= 0x10; + } + if (D_801E97AA != 0) { + D_801E97AA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018E18C[])(void); + +void func_80164EA4(void *a0) { + D_8018E18C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E97F4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E97F4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E97E8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E97E8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E97E8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E97E8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E97E8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018E1A0[]; + extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; + extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; + extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; + extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018E1A0[0x00], p); + ApplyMatrixSV(mat, &D_8018E1A0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018E1A0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018E1A0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018E1C8; + *(u32 *)(prim + 0x24) = D_8018E1C0; + *(u32 *)(prim + 0x28) = D_8018E1CC; + *(u32 *)(prim + 0x2c) = D_8018E1C4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018E1D0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018E1D0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018E1D0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018E1D0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018E24C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018E24C[a1 & 0x7F]; +} + + + +extern s32 D_8018E26C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018E26C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018E2E8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018E2E8[a1 & 0x7F]; +} + + + +extern u8 D_8018E308[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018E308[a1 & 0x7F]; +} + + + +extern u8 D_8018E328[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018E328[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018E348[])(void); + D_8018E348[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018E3C4[])(void); + +void func_80165AC8(void) { + D_8018E3C4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018E440[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018E440[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E8DCC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E8DCC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018E44C[])(void); + +void func_80166018(void *a0) { + D_8018E44C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018E454[])(void); + +void func_801663FC(void *a0) { + D_8018E454[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018E51C[])(void); + +void func_80166618(void *a0) { + D_8018E51C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018E52C[])(void); + +void func_80166654(void *a0) { + D_8018E52C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E9868[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E9868[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E9868). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E9868[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E9868)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E9868[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E9868[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018E470[]; + extern u8 D_8018E45C[]; + extern u8 D_8018E484[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018E470; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018E45C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018E484; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80167714); + + +extern void (*D_8018E53C[])(void); + +void func_801678B4(void *a0) { + D_8018E53C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018E548[])(void); + +void func_80167A9C(void *a0) { + D_8018E548[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018E654; + extern u8 D_8018E668[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018E654); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018E668; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018E4A8[]; +extern u8 D_8018E4BC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018E4A8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018E4BC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018E560[])(void); + +void func_80168744(void *a0) { + D_8018E560[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018E550 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018E550[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018E550; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018E568[])(void); + +void func_801689D8(void *a0) { + D_8018E568[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018E570[])(void); + +void func_80168AA8(void *a0) { + D_8018E570[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018E578[])(void); + +void func_80168D58(void *a0) { + D_8018E578[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018E580[])(void); + +void func_8016901C(void *a0) { + D_8018E580[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_014/nonmatchings/ov_SC03_014_jr_8015C32C", func_80169228); + + +extern void (*D_8018E588[])(void); + +void func_801693CC(void *a0) { + D_8018E588[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018E590[])(void); + +void func_80169830(void *a0) { + D_8018E590[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018E644[])(void); + +void func_80169B80(void *a0) { + D_8018E644[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018E598[]; + extern u8 D_8018E608[]; + extern u8 D_8018E638[]; + extern u8 D_801EAEF8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018E638, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018E598[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801EAEF8; + RotMatrixYXZ(rot, D_801EAEF8); + func_80048D9C(D_801EAEF8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018E608); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018E64C[])(void); + +void func_80169F00(void *a0) { + D_8018E64C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018E5FC[]; +extern char D_8018E5BC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018E5FC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018E5BC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018E684[])(void); + +void func_8016A020(void *a0) { + D_8018E684[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018E654; + extern u8 D_8018E668[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018E654); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018E668; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018E690[])(void); + +void func_8016A700(void *a0) { + D_8018E690[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018E6D8[])(void); + +void func_8016AB30(void *a0) { + D_8018E6D8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_015/ov_SC03_015_jr_8015AE2C.c b/src/ov_SC03_015/ov_SC03_015_jr_8015AE2C.c index 5986ae7ad..d5d047cd0 100644 --- a/src/ov_SC03_015/ov_SC03_015_jr_8015AE2C.c +++ b/src/ov_SC03_015/ov_SC03_015_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018DD94[])(void); - -void func_8015C714(void *a0) { - D_8018DD94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018DC08[])(void*); - extern int D_8018DBAC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DBAC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018DC08[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018DC08[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018DC08[])(void*); - extern int D_8018DBAC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DBAC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018DDA4[])(void); - D_8018DDA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018DC08[])(struct Ent_8015CD20 *); - extern u8 D_8018DBBC; - extern u8 D_8018DDAC; - extern u8 D_8018DDBC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018DC08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DBBC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DDAC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DDBC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018DC08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018DDDC[])(void); - D_8018DDDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018DDCC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018DDCC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018DC08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018DE38; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018DE38, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018CF1C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018CF1C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018DE40[])(void); - D_8018DE40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018DE4C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018DE4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018DE4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018DE4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018DC08[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018DE4C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018DBCC[]; - extern u8 D_8018DBDC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DBCC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DBDC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018DE80[])(void); - D_8018DE80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018DC08[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018DE88[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018DEA0[])(void); - D_8018DEA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018DC08[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018DE88[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018DEC0[])(void); - D_8018DEC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018DC08[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018DC08)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018DED0; -extern u16 D_8018DED2; -extern u16 D_8018DED4; -extern s32 D_8018DED8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018DED0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018DED2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018DED4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018DED8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018DEE0; - -void func_8015E588(void) { - func_8013C9C4(&D_8018DEE0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018DC08[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018DC08)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018DEF4[])(void); - D_8018DEF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018DC08[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018DC08[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018DEFC[])(void); - D_8018DEFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018DBEC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018DBEC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018DC08[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018DF04[])(void); - D_8018DF04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018DC08[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018DC08[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018DF0C[])(void); - D_8018DF0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018DC08[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018DF14; - extern s32 D_8018DF24; - extern s32 D_8018DF34; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018DC08[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF14); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF24); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018DC08[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF34); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018DF44[])(void); - D_8018DF44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018DC08[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018DC08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018DC08[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018DF50[])(void); - D_8018DF50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018DC08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018DC08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018DC08[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018DC08[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018DF64[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018DF64[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018DC08[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018DC08)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018DC08[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018DC08[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018DFE0[])(void); - D_8018DFE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018DC08[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018DC08)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018DFF0[])(void); - D_8018DFF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018DC08[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018DC08[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018DC08[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018DC08[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018DC08[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018DC08[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018DC08[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018DFF8[])(void); - D_8018DFF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018DC08[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018DC08)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018DC08[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018DC08)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018E004[])(void); - D_8018E004[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018DC08 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018DC08[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018DC08[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018DC08[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018E014[])(void); - -void func_80160EA4(void *a0) { - D_8018E014[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018DC08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018DC08[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018E044[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018E044[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018E0A8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018E0A8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E96F0[]; - extern u8 D_8018E074[]; - extern u8 D_8018E094[]; - extern u8 D_801E96FC[]; - extern u8 D_801E9724[]; - extern u8 D_801E973C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E96F0[0] = p; - func_80024054(&D_8018E074, &D_801E96FC); - func_8001CE28(p, &D_801E96FC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E96F0[1] = p; - func_80024054(&D_8018E094, &D_801E9724); - func_8001CE28(p, &D_801E9724); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E96F0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E973C, 0x84); - func_8001CE68(p, &D_801E973C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E973C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E96F0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E96F0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018E0A8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018E0A8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018E0A8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018E0A8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E96F0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E96F0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018E0CC[])(void); - -void func_80162330(void *a0) { - D_8018E0CC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E9748[i] via `extern int D_801E9748[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018E0D8[]; - extern s32 D_8018E0F0; - extern u8 D_801E9754[]; - extern u8 D_801E977C[]; - extern u8 D_801E9798[]; - extern int D_801E9748[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E9748[0] = (s32)item; - func_80024054(D_8018E0D8, D_801E9754); - func_8001CE28(item, D_801E9754); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E9748[1] = (s32)item; - func_80024054(((u8 *)&D_8018E0F0), D_801E977C); - func_8001CE28(item, D_801E977C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E9748[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E9798, 0x84); - func_8001CE68(item, D_801E9798); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E9798, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E9748[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E9748; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018E114[])(void); - -void func_80162834(void *a0) { - D_8018E114[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018E104; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018E104, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E8DBC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E8DBC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E8DBC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E8DBC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018E11C[])(void); - -void func_80163A58(void *a0) { - D_8018E11C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E8DC4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E8DC4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018E170[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018E170[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018E138; -extern s16 D_8018E16C; -extern s16 D_8018E16A; -extern s16 D_8018E168; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018E138; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018E16C = 0x80; - D_8018E16A = 0x80; - D_8018E168 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018E16C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E16C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018E16C - 8; - D_8018E16C = nv; - D_8018E16A = nv; - D_8018E168 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018E17C[])(void); - -void func_80164BA0(void *a0) { - D_8018E17C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E97A8; -extern u8 D_801E97A9; -extern u8 D_801E97AA; -extern u8 D_801E97AB; -extern u8 D_801E97AC; -extern u8 D_801E97AD; -extern u8 D_801E97AE; -extern u8 D_801E97AF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E97A8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E97A9 = 0xf0; - *(u8 *)base = 0xf0; - D_801E97AA = 0xc0; - D_801E97AE = 0; - D_801E97AD = 0; - D_801E97AC = 0; - D_801E97AF = 0; - D_801E97AB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E97A8; -extern u8 D_801E97A9; -extern u8 D_801E97AA; - -s32 func_80164E40(void) { - u8 *p = &D_801E97A8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E97A9 != 0) { - D_801E97A9 -= 0x10; - } - if (D_801E97AA != 0) { - D_801E97AA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018E18C[])(void); - -void func_80164EA4(void *a0) { - D_8018E18C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E97F4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E97F4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E97E8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E97E8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E97E8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E97E8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E97E8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018E1A0[]; - extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; - extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; - extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; - extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018E1A0[0x00], p); - ApplyMatrixSV(mat, &D_8018E1A0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018E1A0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018E1A0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018E1C8; - *(u32 *)(prim + 0x24) = D_8018E1C0; - *(u32 *)(prim + 0x28) = D_8018E1CC; - *(u32 *)(prim + 0x2c) = D_8018E1C4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018E1D0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018E1D0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018E1D0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018E1D0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018E24C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018E24C[a1 & 0x7F]; -} - - - -extern s32 D_8018E26C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018E26C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018E2E8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018E2E8[a1 & 0x7F]; -} - - - -extern u8 D_8018E308[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018E308[a1 & 0x7F]; -} - - - -extern u8 D_8018E328[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018E328[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018E348[])(void); - D_8018E348[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018E3C4[])(void); - -void func_80165AC8(void) { - D_8018E3C4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018E440[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018E440[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E8DCC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E8DCC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018E44C[])(void); - -void func_80166018(void *a0) { - D_8018E44C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018E454[])(void); - -void func_801663FC(void *a0) { - D_8018E454[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018E51C[])(void); - -void func_80166618(void *a0) { - D_8018E51C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018E52C[])(void); - -void func_80166654(void *a0) { - D_8018E52C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E9868[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E9868[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E9868). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E9868[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E9868)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E9868[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E9868[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018E470[]; - extern u8 D_8018E45C[]; - extern u8 D_8018E484[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018E470; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018E45C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018E484; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80167714); - - -extern void (*D_8018E53C[])(void); - -void func_801678B4(void *a0) { - D_8018E53C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018E548[])(void); - -void func_80167A9C(void *a0) { - D_8018E548[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018E654; - extern u8 D_8018E668[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018E654); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018E668; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018E4A8[]; -extern u8 D_8018E4BC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018E4A8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018E4BC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018E560[])(void); - -void func_80168744(void *a0) { - D_8018E560[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018E550 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018E550[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018E550; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018E568[])(void); - -void func_801689D8(void *a0) { - D_8018E568[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018E570[])(void); - -void func_80168AA8(void *a0) { - D_8018E570[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018E578[])(void); - -void func_80168D58(void *a0) { - D_8018E578[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018E580[])(void); - -void func_8016901C(void *a0) { - D_8018E580[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015AE2C", func_80169228); - - -extern void (*D_8018E588[])(void); - -void func_801693CC(void *a0) { - D_8018E588[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018E590[])(void); - -void func_80169830(void *a0) { - D_8018E590[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018E644[])(void); - -void func_80169B80(void *a0) { - D_8018E644[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018E598[]; - extern u8 D_8018E608[]; - extern u8 D_8018E638[]; - extern u8 D_801EAEF8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018E638, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018E598[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801EAEF8; - RotMatrixYXZ(rot, D_801EAEF8); - func_80048D9C(D_801EAEF8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018E608); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018E64C[])(void); - -void func_80169F00(void *a0) { - D_8018E64C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018E5FC[]; -extern char D_8018E5BC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018E5FC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018E5BC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018E684[])(void); - -void func_8016A020(void *a0) { - D_8018E684[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018E654; - extern u8 D_8018E668[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018E654); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018E668; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018E690[])(void); - -void func_8016A700(void *a0) { - D_8018E690[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018E6D8[])(void); - -void func_8016AB30(void *a0) { - D_8018E6D8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c b/src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c new file mode 100644 index 000000000..0985bc8b5 --- /dev/null +++ b/src/ov_SC03_015/ov_SC03_015_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018DAA4; +extern u8 D_8018DA14; +extern u8 D_8018D9F0; +extern u8 D_8018D9CC; +extern u8 D_8018DA80; +extern u8 D_8018DA5C; +extern u8 D_8018DA38; +extern u8 D_8018D9A8; +extern void func_80145934(void); +extern u8 D_8018DB34; +extern u8 D_8018DB10; +extern u8 D_8018DAEC; +extern u8 D_8018DAC8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018CF2C[]; +extern unsigned char D_8018CF5C[]; +extern unsigned char D_8018CFAC[]; +extern unsigned char D_8018CFDC[]; +extern unsigned char D_8018D00C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018D05C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018D124[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018D1AC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018D1B4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E9698; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E969C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018D1E4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018D28C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018D2B0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018D2A0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018D2C4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018D2D0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018D2E0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018D2F8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018D2E8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018D30C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018D328[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018D318; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018D33C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018D350[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018D364; +extern void (*D_8018D38C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018D36C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018D3D8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018D3DC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018D840[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018D850[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E96D0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018D878[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018D858; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018D868; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018D8B8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018D8C0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018D88C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018D8CC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018D89C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E96D8; +extern s32 D_801E96E4; +extern s32 D_801E96E8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018D908[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018D8DC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E96E0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018DB58[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018D978[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018DBFC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018DD50[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018DB6C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018DD58[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018DB7C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018DB9C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018DD60[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018DD88[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018DC08[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018DD94[])(void); + +void func_8015C714(void *a0) { + D_8018DD94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018DC08[])(void*); + extern int D_8018DBAC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DBAC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018DC08[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018DC08[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018DC08[])(void*); + extern int D_8018DBAC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018DBAC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018DDA4[])(void); + D_8018DDA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018DC08[])(struct Ent_8015CD20 *); + extern u8 D_8018DBBC; + extern u8 D_8018DDAC; + extern u8 D_8018DDBC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018DC08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DBBC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DDAC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018DDBC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018DC08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018DDDC[])(void); + D_8018DDDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018DDCC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018DDCC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018DC08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018DE38; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018DE38, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018CF1C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018CF1C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018DE40[])(void); + D_8018DE40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018DE4C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018DE4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018DE4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018DE4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018DC08[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018DE4C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018DBCC[]; + extern u8 D_8018DBDC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DBCC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018DBDC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018DE4C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018DE80[])(void); + D_8018DE80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018DC08[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018DE88[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018DEA0[])(void); + D_8018DEA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018DC08[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018DE88[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018DE88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018DEC0[])(void); + D_8018DEC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018DC08[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018DC08)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018DED0; +extern u16 D_8018DED2; +extern u16 D_8018DED4; +extern s32 D_8018DED8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018DED0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018DED2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018DED4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018DED8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018DEE0; + +void func_8015E588(void) { + func_8013C9C4(&D_8018DEE0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018DC08[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018DC08)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018DEF4[])(void); + D_8018DEF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018DC08[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018DC08[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018DEFC[])(void); + D_8018DEFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018DBEC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018DBEC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018DC08[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018DF04[])(void); + D_8018DF04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018DC08[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018DC08[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018DF0C[])(void); + D_8018DF0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018DC08[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018DF14; + extern s32 D_8018DF24; + extern s32 D_8018DF34; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF14); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF24); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018DC08[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018DF34); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018DF44[])(void); + D_8018DF44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018DC08[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018DC08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018DC08[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018DF50[])(void); + D_8018DF50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018DC08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018DC08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018DC08[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018DC08[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018DF64[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018DF64[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018DC08[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018DC08)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018DC08[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018DC08[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018DFE0[])(void); + D_8018DFE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018DC08[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018DC08)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018DFF0[])(void); + D_8018DFF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018DC08[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018DC08[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018DC08[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018DC08[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018DC08[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018DC08[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018DC08[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018DFF8[])(void); + D_8018DFF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018DC08[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018DC08)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018DC08[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018DC08)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018E004[])(void); + D_8018E004[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018DC08 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018DC08[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018DC08[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018DC08[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018E014[])(void); + +void func_80160EA4(void *a0) { + D_8018E014[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018DC08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018DC08[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018E044[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018E044[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018E0A8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018E0A8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E96F0[]; + extern u8 D_8018E074[]; + extern u8 D_8018E094[]; + extern u8 D_801E96FC[]; + extern u8 D_801E9724[]; + extern u8 D_801E973C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E96F0[0] = p; + func_80024054(&D_8018E074, &D_801E96FC); + func_8001CE28(p, &D_801E96FC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E96F0[1] = p; + func_80024054(&D_8018E094, &D_801E9724); + func_8001CE28(p, &D_801E9724); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E96F0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E973C, 0x84); + func_8001CE68(p, &D_801E973C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E973C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E96F0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E96F0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018E0A8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018E0A8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018E0A8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018E0A8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E96F0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E96F0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018E0CC[])(void); + +void func_80162330(void *a0) { + D_8018E0CC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E9748[i] via `extern int D_801E9748[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018E0D8[]; + extern s32 D_8018E0F0; + extern u8 D_801E9754[]; + extern u8 D_801E977C[]; + extern u8 D_801E9798[]; + extern int D_801E9748[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E9748[0] = (s32)item; + func_80024054(D_8018E0D8, D_801E9754); + func_8001CE28(item, D_801E9754); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E9748[1] = (s32)item; + func_80024054(((u8 *)&D_8018E0F0), D_801E977C); + func_8001CE28(item, D_801E977C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E9748[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E9798, 0x84); + func_8001CE68(item, D_801E9798); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E9798, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E9748[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E9748; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_801627E8); + + +extern void (*D_8018E114[])(void); + +void func_80162834(void *a0) { + D_8018E114[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018E104; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018E104, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E8DBC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E8DBC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E8DBC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E8DBC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018E11C[])(void); + +void func_80163A58(void *a0) { + D_8018E11C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E8DC4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E8DC4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018E170[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018E170[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018E138; +extern s16 D_8018E16C; +extern s16 D_8018E16A; +extern s16 D_8018E168; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018E138; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018E16C = 0x80; + D_8018E16A = 0x80; + D_8018E168 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018E16C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E16C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018E16C - 8; + D_8018E16C = nv; + D_8018E16A = nv; + D_8018E168 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018E17C[])(void); + +void func_80164BA0(void *a0) { + D_8018E17C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E97A8; +extern u8 D_801E97A9; +extern u8 D_801E97AA; +extern u8 D_801E97AB; +extern u8 D_801E97AC; +extern u8 D_801E97AD; +extern u8 D_801E97AE; +extern u8 D_801E97AF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E97A8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E97A9 = 0xf0; + *(u8 *)base = 0xf0; + D_801E97AA = 0xc0; + D_801E97AE = 0; + D_801E97AD = 0; + D_801E97AC = 0; + D_801E97AF = 0; + D_801E97AB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E97A8; +extern u8 D_801E97A9; +extern u8 D_801E97AA; + +s32 func_80164E40(void) { + u8 *p = &D_801E97A8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E97A9 != 0) { + D_801E97A9 -= 0x10; + } + if (D_801E97AA != 0) { + D_801E97AA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018E18C[])(void); + +void func_80164EA4(void *a0) { + D_8018E18C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E97F4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E97F4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E97E8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E97E8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E97E8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E97E8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E97E8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018E1A0[]; + extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; + extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; + extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; + extern u32 D_8018E1C0, D_8018E1C4, D_8018E1C8, D_8018E1CC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018E1A0[0x00], p); + ApplyMatrixSV(mat, &D_8018E1A0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018E1A0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018E1A0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018E1C8; + *(u32 *)(prim + 0x24) = D_8018E1C0; + *(u32 *)(prim + 0x28) = D_8018E1CC; + *(u32 *)(prim + 0x2c) = D_8018E1C4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018E1D0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018E1D0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018E1D0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018E1D0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018E24C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018E24C[a1 & 0x7F]; +} + + + +extern s32 D_8018E26C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018E26C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018E2E8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018E2E8[a1 & 0x7F]; +} + + + +extern u8 D_8018E308[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018E308[a1 & 0x7F]; +} + + + +extern u8 D_8018E328[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018E328[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018E348[])(void); + D_8018E348[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018E3C4[])(void); + +void func_80165AC8(void) { + D_8018E3C4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018E440[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018E440[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E8DCC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E8DCC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018E44C[])(void); + +void func_80166018(void *a0) { + D_8018E44C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018E454[])(void); + +void func_801663FC(void *a0) { + D_8018E454[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018E51C[])(void); + +void func_80166618(void *a0) { + D_8018E51C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018E52C[])(void); + +void func_80166654(void *a0) { + D_8018E52C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E9868[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E9868[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E9868). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E9868[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E9868)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E9868[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E9868[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018E470[]; + extern u8 D_8018E45C[]; + extern u8 D_8018E484[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018E470; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018E45C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018E484; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80167714); + + +extern void (*D_8018E53C[])(void); + +void func_801678B4(void *a0) { + D_8018E53C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018E548[])(void); + +void func_80167A9C(void *a0) { + D_8018E548[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018E654; + extern u8 D_8018E668[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018E654); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018E668; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018E4A8[]; +extern u8 D_8018E4BC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018E4A8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018E4BC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018E560[])(void); + +void func_80168744(void *a0) { + D_8018E560[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018E550 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018E550[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018E550; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018E568[])(void); + +void func_801689D8(void *a0) { + D_8018E568[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018E570[])(void); + +void func_80168AA8(void *a0) { + D_8018E570[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018E578[])(void); + +void func_80168D58(void *a0) { + D_8018E578[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018E580[])(void); + +void func_8016901C(void *a0) { + D_8018E580[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_015/nonmatchings/ov_SC03_015_jr_8015C32C", func_80169228); + + +extern void (*D_8018E588[])(void); + +void func_801693CC(void *a0) { + D_8018E588[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018E590[])(void); + +void func_80169830(void *a0) { + D_8018E590[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018E644[])(void); + +void func_80169B80(void *a0) { + D_8018E644[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018E598[]; + extern u8 D_8018E608[]; + extern u8 D_8018E638[]; + extern u8 D_801EAEF8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018E638, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018E598[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801EAEF8; + RotMatrixYXZ(rot, D_801EAEF8); + func_80048D9C(D_801EAEF8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018E608); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018E64C[])(void); + +void func_80169F00(void *a0) { + D_8018E64C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018E5FC[]; +extern char D_8018E5BC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018E5FC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018E5BC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018E684[])(void); + +void func_8016A020(void *a0) { + D_8018E684[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018E654; + extern u8 D_8018E668[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018E654); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018E668; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018E690[])(void); + +void func_8016A700(void *a0) { + D_8018E690[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018E6D8[])(void); + +void func_8016AB30(void *a0) { + D_8018E6D8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_023/ov_SC03_023_jr_8015AE2C.c b/src/ov_SC03_023/ov_SC03_023_jr_8015AE2C.c index 518a06764..85b69aa82 100644 --- a/src/ov_SC03_023/ov_SC03_023_jr_8015AE2C.c +++ b/src/ov_SC03_023/ov_SC03_023_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181710[])(void); - -void func_8015C714(void *a0) { - D_80181710[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181584[])(void*); - extern int D_80181528; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181584)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181584)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181528); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181584[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181584[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181584[])(void*); - extern int D_80181528; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181584)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181528); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181584)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181720[])(void); - D_80181720[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181584[])(struct Ent_8015CD20 *); - extern u8 D_80181538; - extern u8 D_80181728; - extern u8 D_80181738; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181584[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181538); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181728); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181738); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181584[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181758[])(void); - D_80181758[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181748; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181748 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181584[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801817B4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801817B4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180898[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180898; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801817BC[])(void); - D_801817BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801817C8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801817C8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801817C8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801817C8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181584[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801817C8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80181548[]; - extern u8 D_80181558[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181548); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181558); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801817C8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801817C8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801817C8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801817FC[])(void); - D_801817FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181584[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181804[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018181C[])(void); - D_8018181C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181584[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181804[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018183C[])(void); - D_8018183C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181584[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181584)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018184C; -extern u16 D_8018184E; -extern u16 D_80181850; -extern s32 D_80181854; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018184C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018184E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181850 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181854, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018185C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018185C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181584[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181584)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181870[])(void); - D_80181870[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181584[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181584[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181878[])(void); - D_80181878[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80181568; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181568); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181584[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181880[])(void); - D_80181880[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181584[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181584[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181888[])(void); - D_80181888[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181584[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181890; - extern s32 D_801818A0; - extern s32 D_801818B0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181584[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181890); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801818A0); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181584[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801818B0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801818C0[])(void); - D_801818C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181584[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181584[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181584[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181584[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801818CC[])(void); - D_801818CC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181584[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181584[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181584[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181584[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801818E0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801818E0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181584[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181584)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181584[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181584[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018195C[])(void); - D_8018195C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181584[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181584)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018196C[])(void); - D_8018196C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181584[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181584[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181584[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181584[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181584[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181584[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181584[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181974[])(void); - D_80181974[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181584[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181584)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181584[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181584)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181980[])(void); - D_80181980[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181584 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181584[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181584[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181584[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181990[])(void); - -void func_80160EA4(void *a0) { - D_80181990[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181584[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181584[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801819C0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801819C0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181A24; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181A24); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80197AC8[]; - extern u8 D_801819F0[]; - extern u8 D_80181A10[]; - extern u8 D_80197AD4[]; - extern u8 D_80197AFC[]; - extern u8 D_80197B14[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80197AC8[0] = p; - func_80024054(&D_801819F0, &D_80197AD4); - func_8001CE28(p, &D_80197AD4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80197AC8[1] = p; - func_80024054(&D_80181A10, &D_80197AFC); - func_8001CE28(p, &D_80197AFC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80197AC8[2] = p; - func_800242D0((s16)func_801620C4(), &D_80197B14, 0x84); - func_8001CE68(p, &D_80197B14); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80197B14, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80197AC8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80197AC8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181A24; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181A24; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181A24; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181A24; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80197AC8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80197AC8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181A48[])(void); - -void func_80162330(void *a0) { - D_80181A48[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80197B20[i] via `extern int D_80197B20[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181A54[]; - extern s32 D_80181A6C; - extern u8 D_80197B2C[]; - extern u8 D_80197B54[]; - extern u8 D_80197B70[]; - extern int D_80197B20[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80197B20[0] = (s32)item; - func_80024054(D_80181A54, D_80197B2C); - func_8001CE28(item, D_80197B2C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80197B20[1] = (s32)item; - func_80024054(((u8 *)&D_80181A6C), D_80197B54); - func_8001CE28(item, D_80197B54); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80197B20[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80197B70, 0x84); - func_8001CE68(item, D_80197B70); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80197B70, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80197B20[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80197B20; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181A90[])(void); - -void func_80162834(void *a0) { - D_80181A90[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181A80; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181A80, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80197394[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80197394, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80197394[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80197394, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181A98[])(void); - -void func_80163A58(void *a0) { - D_80181A98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019739C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019739C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80181AEC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80181AEC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181AB4; -extern s16 D_80181AE8; -extern s16 D_80181AE6; -extern s16 D_80181AE4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181AB4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181AE8 = 0x80; - D_80181AE6 = 0x80; - D_80181AE4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181AE8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181AE8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181AE8 - 8; - D_80181AE8 = nv; - D_80181AE6 = nv; - D_80181AE4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181AF8[])(void); - -void func_80164BA0(void *a0) { - D_80181AF8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80197B80; -extern u8 D_80197B81; -extern u8 D_80197B82; -extern u8 D_80197B83; -extern u8 D_80197B84; -extern u8 D_80197B85; -extern u8 D_80197B86; -extern u8 D_80197B87; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80197B80; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80197B81 = 0xf0; - *(u8 *)base = 0xf0; - D_80197B82 = 0xc0; - D_80197B86 = 0; - D_80197B85 = 0; - D_80197B84 = 0; - D_80197B87 = 0; - D_80197B83 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80197B80; -extern u8 D_80197B81; -extern u8 D_80197B82; - -s32 func_80164E40(void) { - u8 *p = &D_80197B80; - if (*p != 0) { - *p -= 0x10; - } - if (D_80197B81 != 0) { - D_80197B81 -= 0x10; - } - if (D_80197B82 != 0) { - D_80197B82 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181B08[])(void); - -void func_80164EA4(void *a0) { - D_80181B08[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80197BCC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80197BCC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80197BC0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80197BC0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80197BC0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80197BC0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80197BC0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181B1C[]; - extern u32 D_80181B3C, D_80181B40, D_80181B44, D_80181B48; - extern u32 D_80181B3C, D_80181B40, D_80181B44, D_80181B48; - extern u32 D_80181B3C, D_80181B40, D_80181B44, D_80181B48; - extern u32 D_80181B3C, D_80181B40, D_80181B44, D_80181B48; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181B1C[0x00], p); - ApplyMatrixSV(mat, &D_80181B1C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181B1C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181B1C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181B44; - *(u32 *)(prim + 0x24) = D_80181B3C; - *(u32 *)(prim + 0x28) = D_80181B48; - *(u32 *)(prim + 0x2c) = D_80181B40; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181B4C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181B4C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181B4C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181B4C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80181BC8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80181BC8[a1 & 0x7F]; -} - - - -extern s32 D_80181BE8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181BE8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181C64[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181C64[a1 & 0x7F]; -} - - - -extern u8 D_80181C84[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80181C84[a1 & 0x7F]; -} - - - -extern u8 D_80181CA4[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181CA4[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80181CC4[])(void); - D_80181CC4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80181D40[])(void); - -void func_80165AC8(void) { - D_80181D40[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181DBC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181DBC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801973A4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801973A4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80181DC8[])(void); - -void func_80166018(void *a0) { - D_80181DC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181DD0[])(void); - -void func_801663FC(void *a0) { - D_80181DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80181E98[])(void); - -void func_80166618(void *a0) { - D_80181E98[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181EA8[])(void); - -void func_80166654(void *a0) { - D_80181EA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80197C40[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80197C40[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80197C40). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80197C40[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80197C40)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80197C40[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80197C40[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80181DEC[]; - extern u8 D_80181DD8[]; - extern u8 D_80181E00[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80181DEC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80181DD8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80181E00; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80167714); - - -extern void (*D_80181EB8[])(void); - -void func_801678B4(void *a0) { - D_80181EB8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181EC4[])(void); - -void func_80167A9C(void *a0) { - D_80181EC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181FD0; - extern u8 D_80181FE4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181FD0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181FE4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80181E24[]; -extern u8 D_80181E38[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80181E24; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181E38; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181EDC[])(void); - -void func_80168744(void *a0) { - D_80181EDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181ECC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181ECC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181ECC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181EE4[])(void); - -void func_801689D8(void *a0) { - D_80181EE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181EEC[])(void); - -void func_80168AA8(void *a0) { - D_80181EEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181EF4[])(void); - -void func_80168D58(void *a0) { - D_80181EF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181EFC[])(void); - -void func_8016901C(void *a0) { - D_80181EFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015AE2C", func_80169228); - - -extern void (*D_80181F04[])(void); - -void func_801693CC(void *a0) { - D_80181F04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181F0C[])(void); - -void func_80169830(void *a0) { - D_80181F0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181FC0[])(void); - -void func_80169B80(void *a0) { - D_80181FC0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181F14[]; - extern u8 D_80181F84[]; - extern u8 D_80181FB4[]; - extern u8 D_80198C40[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181FB4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181F14[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80198C40; - RotMatrixYXZ(rot, D_80198C40); - func_80048D9C(D_80198C40, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181F84); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181FC8[])(void); - -void func_80169F00(void *a0) { - D_80181FC8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80181F78[]; -extern char D_80181F38[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80181F78, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181F38); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80182000[])(void); - -void func_8016A020(void *a0) { - D_80182000[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181FD0; - extern u8 D_80181FE4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181FD0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181FE4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018200C[])(void); - -void func_8016A700(void *a0) { - D_8018200C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80182054[])(void); - -void func_8016AB30(void *a0) { - D_80182054[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c b/src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c new file mode 100644 index 000000000..841799516 --- /dev/null +++ b/src/ov_SC03_023/ov_SC03_023_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80181420; +extern u8 D_80181390; +extern u8 D_8018136C; +extern u8 D_80181348; +extern u8 D_801813FC; +extern u8 D_801813D8; +extern u8 D_801813B4; +extern u8 D_80181324; +extern void func_80145934(void); +extern u8 D_801814B0; +extern u8 D_8018148C; +extern u8 D_80181468; +extern u8 D_80181444; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801808A8[]; +extern unsigned char D_801808D8[]; +extern unsigned char D_80180928[]; +extern unsigned char D_80180958[]; +extern unsigned char D_80180988[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801809D8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80180AA0[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180B28[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180B30; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80197A70; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_80197A74; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180B60; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180C08[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180C2C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180C1C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180C40[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180C4C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180C5C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80180C74[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180C64; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80180C88[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80180CA4[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80180C94; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80180CB8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80180CCC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80180CE0; +extern void (*D_80180D08[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80180CE8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80180D54[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80180D58[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801811BC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801811CC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80197AA8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801811F4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801811D4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801811E4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80181234[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018123C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80181208; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80181248[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80181218; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80197AB0; +extern s32 D_80197ABC; +extern s32 D_80197AC0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80181284[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80181258[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80197AB8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801814D4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801812F4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181578[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801816CC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801814E8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801816D4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801814F8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80181518; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801816DC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80181704[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181584[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181584[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181584[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181584[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181584[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181584[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181584[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181584[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181710[])(void); + +void func_8015C714(void *a0) { + D_80181710[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181584[])(void*); + extern int D_80181528; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181584)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181584)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181528); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181584[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181584[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181584[])(void*); + extern int D_80181528; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181584)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181528); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181584)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181720[])(void); + D_80181720[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181584[])(struct Ent_8015CD20 *); + extern u8 D_80181538; + extern u8 D_80181728; + extern u8 D_80181738; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181584[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181538); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181728); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181738); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181584[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181758[])(void); + D_80181758[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181748; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181748 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181584[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801817B4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801817B4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180898[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180898; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801817BC[])(void); + D_801817BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801817C8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801817C8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801817C8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801817C8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181584[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801817C8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80181548[]; + extern u8 D_80181558[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181548); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181558); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801817C8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801817C8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801817C8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801817FC[])(void); + D_801817FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181584[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181804[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018181C[])(void); + D_8018181C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181584[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181804[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181804[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018183C[])(void); + D_8018183C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181584[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181584)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018184C; +extern u16 D_8018184E; +extern u16 D_80181850; +extern s32 D_80181854; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018184C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018184E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181850 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181854, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018185C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018185C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181584[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181584)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181870[])(void); + D_80181870[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181584[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181584[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181878[])(void); + D_80181878[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80181568; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181568); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181584[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181880[])(void); + D_80181880[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181584[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181584[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181888[])(void); + D_80181888[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181584[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181890; + extern s32 D_801818A0; + extern s32 D_801818B0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181584[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181890); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801818A0); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181584[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801818B0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801818C0[])(void); + D_801818C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181584[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181584[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181584[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181584[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801818CC[])(void); + D_801818CC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181584[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181584[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181584[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181584[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801818E0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801818E0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181584[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181584)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181584[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181584[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018195C[])(void); + D_8018195C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181584[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181584)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018196C[])(void); + D_8018196C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181584[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181584[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181584[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181584[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181584[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181584[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181584[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181974[])(void); + D_80181974[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181584[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181584)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181584[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181584)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181980[])(void); + D_80181980[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181584 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181584[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181584[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181584[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181990[])(void); + +void func_80160EA4(void *a0) { + D_80181990[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181584[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181584[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801819C0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801819C0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181A24; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181A24); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80197AC8[]; + extern u8 D_801819F0[]; + extern u8 D_80181A10[]; + extern u8 D_80197AD4[]; + extern u8 D_80197AFC[]; + extern u8 D_80197B14[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80197AC8[0] = p; + func_80024054(&D_801819F0, &D_80197AD4); + func_8001CE28(p, &D_80197AD4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80197AC8[1] = p; + func_80024054(&D_80181A10, &D_80197AFC); + func_8001CE28(p, &D_80197AFC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80197AC8[2] = p; + func_800242D0((s16)func_801620C4(), &D_80197B14, 0x84); + func_8001CE68(p, &D_80197B14); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80197B14, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80197AC8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80197AC8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181A24; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181A24; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181A24; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181A24; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80197AC8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80197AC8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181A48[])(void); + +void func_80162330(void *a0) { + D_80181A48[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80197B20[i] via `extern int D_80197B20[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181A54[]; + extern s32 D_80181A6C; + extern u8 D_80197B2C[]; + extern u8 D_80197B54[]; + extern u8 D_80197B70[]; + extern int D_80197B20[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80197B20[0] = (s32)item; + func_80024054(D_80181A54, D_80197B2C); + func_8001CE28(item, D_80197B2C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80197B20[1] = (s32)item; + func_80024054(((u8 *)&D_80181A6C), D_80197B54); + func_8001CE28(item, D_80197B54); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80197B20[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80197B70, 0x84); + func_8001CE68(item, D_80197B70); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80197B70, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80197B20[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80197B20; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_801627E8); + + +extern void (*D_80181A90[])(void); + +void func_80162834(void *a0) { + D_80181A90[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181A80; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181A80, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80197394[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80197394, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80197394[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80197394, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181A98[])(void); + +void func_80163A58(void *a0) { + D_80181A98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019739C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019739C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80181AEC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80181AEC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181AB4; +extern s16 D_80181AE8; +extern s16 D_80181AE6; +extern s16 D_80181AE4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181AB4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181AE8 = 0x80; + D_80181AE6 = 0x80; + D_80181AE4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181AE8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181AE8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181AE8 - 8; + D_80181AE8 = nv; + D_80181AE6 = nv; + D_80181AE4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181AF8[])(void); + +void func_80164BA0(void *a0) { + D_80181AF8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80197B80; +extern u8 D_80197B81; +extern u8 D_80197B82; +extern u8 D_80197B83; +extern u8 D_80197B84; +extern u8 D_80197B85; +extern u8 D_80197B86; +extern u8 D_80197B87; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80197B80; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80197B81 = 0xf0; + *(u8 *)base = 0xf0; + D_80197B82 = 0xc0; + D_80197B86 = 0; + D_80197B85 = 0; + D_80197B84 = 0; + D_80197B87 = 0; + D_80197B83 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80197B80; +extern u8 D_80197B81; +extern u8 D_80197B82; + +s32 func_80164E40(void) { + u8 *p = &D_80197B80; + if (*p != 0) { + *p -= 0x10; + } + if (D_80197B81 != 0) { + D_80197B81 -= 0x10; + } + if (D_80197B82 != 0) { + D_80197B82 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181B08[])(void); + +void func_80164EA4(void *a0) { + D_80181B08[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80197BCC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80197BCC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80197BC0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80197BC0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80197BC0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80197BC0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80197BC0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181B1C[]; + extern u32 D_80181B3C, D_80181B40, D_80181B44, D_80181B48; + extern u32 D_80181B3C, D_80181B40, D_80181B44, D_80181B48; + extern u32 D_80181B3C, D_80181B40, D_80181B44, D_80181B48; + extern u32 D_80181B3C, D_80181B40, D_80181B44, D_80181B48; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181B1C[0x00], p); + ApplyMatrixSV(mat, &D_80181B1C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181B1C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181B1C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181B44; + *(u32 *)(prim + 0x24) = D_80181B3C; + *(u32 *)(prim + 0x28) = D_80181B48; + *(u32 *)(prim + 0x2c) = D_80181B40; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181B4C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181B4C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181B4C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181B4C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80181BC8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80181BC8[a1 & 0x7F]; +} + + + +extern s32 D_80181BE8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181BE8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181C64[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181C64[a1 & 0x7F]; +} + + + +extern u8 D_80181C84[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80181C84[a1 & 0x7F]; +} + + + +extern u8 D_80181CA4[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181CA4[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80181CC4[])(void); + D_80181CC4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80181D40[])(void); + +void func_80165AC8(void) { + D_80181D40[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181DBC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181DBC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801973A4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801973A4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80181DC8[])(void); + +void func_80166018(void *a0) { + D_80181DC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181DD0[])(void); + +void func_801663FC(void *a0) { + D_80181DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80181E98[])(void); + +void func_80166618(void *a0) { + D_80181E98[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181EA8[])(void); + +void func_80166654(void *a0) { + D_80181EA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80197C40[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80197C40[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80197C40). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80197C40[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80197C40)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80197C40[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80197C40[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80181DEC[]; + extern u8 D_80181DD8[]; + extern u8 D_80181E00[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80181DEC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80181DD8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80181E00; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80167714); + + +extern void (*D_80181EB8[])(void); + +void func_801678B4(void *a0) { + D_80181EB8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181EC4[])(void); + +void func_80167A9C(void *a0) { + D_80181EC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181FD0; + extern u8 D_80181FE4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181FD0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181FE4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80181E24[]; +extern u8 D_80181E38[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80181E24; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181E38; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181EDC[])(void); + +void func_80168744(void *a0) { + D_80181EDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181ECC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181ECC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181ECC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181EE4[])(void); + +void func_801689D8(void *a0) { + D_80181EE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181EEC[])(void); + +void func_80168AA8(void *a0) { + D_80181EEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181EF4[])(void); + +void func_80168D58(void *a0) { + D_80181EF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181EFC[])(void); + +void func_8016901C(void *a0) { + D_80181EFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_023/nonmatchings/ov_SC03_023_jr_8015C32C", func_80169228); + + +extern void (*D_80181F04[])(void); + +void func_801693CC(void *a0) { + D_80181F04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181F0C[])(void); + +void func_80169830(void *a0) { + D_80181F0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181FC0[])(void); + +void func_80169B80(void *a0) { + D_80181FC0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181F14[]; + extern u8 D_80181F84[]; + extern u8 D_80181FB4[]; + extern u8 D_80198C40[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181FB4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181F14[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80198C40; + RotMatrixYXZ(rot, D_80198C40); + func_80048D9C(D_80198C40, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181F84); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181FC8[])(void); + +void func_80169F00(void *a0) { + D_80181FC8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80181F78[]; +extern char D_80181F38[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80181F78, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181F38); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80182000[])(void); + +void func_8016A020(void *a0) { + D_80182000[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181FD0; + extern u8 D_80181FE4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181FD0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181FE4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018200C[])(void); + +void func_8016A700(void *a0) { + D_8018200C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80182054[])(void); + +void func_8016AB30(void *a0) { + D_80182054[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_024/ov_SC03_024_jr_8015AE2C.c b/src/ov_SC03_024/ov_SC03_024_jr_8015AE2C.c index 95133ff44..b1f5b927b 100644 --- a/src/ov_SC03_024/ov_SC03_024_jr_8015AE2C.c +++ b/src/ov_SC03_024/ov_SC03_024_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80189734[])(void); - -void func_8015C714(void *a0) { - D_80189734[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801895A8[])(void*); - extern int D_8018954C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801895A8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801895A8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018954C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801895A8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801895A8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801895A8[])(void*); - extern int D_8018954C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801895A8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018954C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801895A8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80189744[])(void); - D_80189744[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801895A8[])(struct Ent_8015CD20 *); - extern u8 D_8018955C; - extern u8 D_8018974C; - extern u8 D_8018975C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801895A8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018955C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018974C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018975C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801895A8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018977C[])(void); - D_8018977C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018976C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018976C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801895A8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801897D8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801897D8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801888BC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801888BC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801897E0[])(void); - D_801897E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801897EC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801897EC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801897EC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801897EC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801895A8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801897EC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018956C[]; - extern u8 D_8018957C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018956C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018957C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801897EC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801897EC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801897EC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80189820[])(void); - D_80189820[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801895A8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80189828[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80189840[])(void); - D_80189840[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801895A8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80189828[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80189860[])(void); - D_80189860[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801895A8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801895A8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80189870; -extern u16 D_80189872; -extern u16 D_80189874; -extern s32 D_80189878; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80189870 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80189872 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80189874 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80189878, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80189880; - -void func_8015E588(void) { - func_8013C9C4(&D_80189880); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801895A8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801895A8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80189894[])(void); - D_80189894[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801895A8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801895A8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018989C[])(void); - D_8018989C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018958C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018958C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801895A8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801898A4[])(void); - D_801898A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801895A8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801895A8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801898AC[])(void); - D_801898AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801895A8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801898B4; - extern s32 D_801898C4; - extern s32 D_801898D4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801895A8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801898B4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801898C4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801895A8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801898D4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801898E4[])(void); - D_801898E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801895A8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801895A8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801895A8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801895A8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801898F0[])(void); - D_801898F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801895A8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801895A8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801895A8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801895A8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80189904[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80189904[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801895A8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801895A8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801895A8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801895A8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80189980[])(void); - D_80189980[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801895A8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801895A8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80189990[])(void); - D_80189990[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801895A8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801895A8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801895A8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801895A8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801895A8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801895A8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801895A8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80189998[])(void); - D_80189998[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801895A8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801895A8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801895A8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801895A8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801899A4[])(void); - D_801899A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801895A8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801895A8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801895A8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801895A8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801899B4[])(void); - -void func_80160EA4(void *a0) { - D_801899B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801895A8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801895A8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801899E4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801899E4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80189A48; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80189A48); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C0060[]; - extern u8 D_80189A14[]; - extern u8 D_80189A34[]; - extern u8 D_801C006C[]; - extern u8 D_801C0094[]; - extern u8 D_801C00AC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C0060[0] = p; - func_80024054(&D_80189A14, &D_801C006C); - func_8001CE28(p, &D_801C006C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C0060[1] = p; - func_80024054(&D_80189A34, &D_801C0094); - func_8001CE28(p, &D_801C0094); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C0060[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C00AC, 0x84); - func_8001CE68(p, &D_801C00AC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C00AC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C0060[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C0060; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80189A48; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80189A48; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80189A48; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80189A48; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C0060[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C0060; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80189A6C[])(void); - -void func_80162330(void *a0) { - D_80189A6C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C00B8[i] via `extern int D_801C00B8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80189A78[]; - extern s32 D_80189A90; - extern u8 D_801C00C4[]; - extern u8 D_801C00EC[]; - extern u8 D_801C0108[]; - extern int D_801C00B8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C00B8[0] = (s32)item; - func_80024054(D_80189A78, D_801C00C4); - func_8001CE28(item, D_801C00C4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C00B8[1] = (s32)item; - func_80024054(((u8 *)&D_80189A90), D_801C00EC); - func_8001CE28(item, D_801C00EC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C00B8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C0108, 0x84); - func_8001CE68(item, D_801C0108); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C0108, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C00B8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C00B8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_801627E8); - - -extern void (*D_80189AB4[])(void); - -void func_80162834(void *a0) { - D_80189AB4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80189AA4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80189AA4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801BF81C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801BF81C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801BF81C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801BF81C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80189ABC[])(void); - -void func_80163A58(void *a0) { - D_80189ABC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801BF824; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801BF824; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80189B10[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80189B10[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80189AD8; -extern s16 D_80189B0C; -extern s16 D_80189B0A; -extern s16 D_80189B08; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80189AD8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80189B0C = 0x80; - D_80189B0A = 0x80; - D_80189B08 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80189B0C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80189B0C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80189B0C - 8; - D_80189B0C = nv; - D_80189B0A = nv; - D_80189B08 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80189B1C[])(void); - -void func_80164BA0(void *a0) { - D_80189B1C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C0118; -extern u8 D_801C0119; -extern u8 D_801C011A; -extern u8 D_801C011B; -extern u8 D_801C011C; -extern u8 D_801C011D; -extern u8 D_801C011E; -extern u8 D_801C011F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C0118; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C0119 = 0xf0; - *(u8 *)base = 0xf0; - D_801C011A = 0xc0; - D_801C011E = 0; - D_801C011D = 0; - D_801C011C = 0; - D_801C011F = 0; - D_801C011B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C0118; -extern u8 D_801C0119; -extern u8 D_801C011A; - -s32 func_80164E40(void) { - u8 *p = &D_801C0118; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C0119 != 0) { - D_801C0119 -= 0x10; - } - if (D_801C011A != 0) { - D_801C011A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80189B2C[])(void); - -void func_80164EA4(void *a0) { - D_80189B2C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C0164[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C0164[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C0158[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C0158[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C0158[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C0158; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C0158; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80189B40[]; - extern u32 D_80189B60, D_80189B64, D_80189B68, D_80189B6C; - extern u32 D_80189B60, D_80189B64, D_80189B68, D_80189B6C; - extern u32 D_80189B60, D_80189B64, D_80189B68, D_80189B6C; - extern u32 D_80189B60, D_80189B64, D_80189B68, D_80189B6C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80189B40[0x00], p); - ApplyMatrixSV(mat, &D_80189B40[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80189B40[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80189B40[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80189B68; - *(u32 *)(prim + 0x24) = D_80189B60; - *(u32 *)(prim + 0x28) = D_80189B6C; - *(u32 *)(prim + 0x2c) = D_80189B64; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80189B70[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80189B70[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80189B70[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80189B70[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80189BEC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80189BEC[a1 & 0x7F]; -} - - - -extern s32 D_80189C0C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80189C0C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80189C88[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80189C88[a1 & 0x7F]; -} - - - -extern u8 D_80189CA8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80189CA8[a1 & 0x7F]; -} - - - -extern u8 D_80189CC8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80189CC8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80189CE8[])(void); - D_80189CE8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80189D64[])(void); - -void func_80165AC8(void) { - D_80189D64[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80189DE0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80189DE0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801BF82C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801BF82C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80189DEC[])(void); - -void func_80166018(void *a0) { - D_80189DEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80189DF4[])(void); - -void func_801663FC(void *a0) { - D_80189DF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80189EBC[])(void); - -void func_80166618(void *a0) { - D_80189EBC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80189ECC[])(void); - -void func_80166654(void *a0) { - D_80189ECC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C01D8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C01D8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C01D8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C01D8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C01D8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C01D8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C01D8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80189E10[]; - extern u8 D_80189DFC[]; - extern u8 D_80189E24[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80189E10; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80189DFC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80189E24; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80167714); - - -extern void (*D_80189EDC[])(void); - -void func_801678B4(void *a0) { - D_80189EDC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80189EE8[])(void); - -void func_80167A9C(void *a0) { - D_80189EE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80189FF4; - extern u8 D_8018A008[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80189FF4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018A008; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80189E48[]; -extern u8 D_80189E5C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80189E48; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80189E5C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80189F00[])(void); - -void func_80168744(void *a0) { - D_80189F00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80189EF0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80189EF0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80189EF0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80189F08[])(void); - -void func_801689D8(void *a0) { - D_80189F08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80189F10[])(void); - -void func_80168AA8(void *a0) { - D_80189F10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80189F18[])(void); - -void func_80168D58(void *a0) { - D_80189F18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80189F20[])(void); - -void func_8016901C(void *a0) { - D_80189F20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015AE2C", func_80169228); - - -extern void (*D_80189F28[])(void); - -void func_801693CC(void *a0) { - D_80189F28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80189F30[])(void); - -void func_80169830(void *a0) { - D_80189F30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80189FE4[])(void); - -void func_80169B80(void *a0) { - D_80189FE4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80189F38[]; - extern u8 D_80189FA8[]; - extern u8 D_80189FD8[]; - extern u8 D_801C1708[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80189FD8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80189F38[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C1708; - RotMatrixYXZ(rot, D_801C1708); - func_80048D9C(D_801C1708, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80189FA8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80189FEC[])(void); - -void func_80169F00(void *a0) { - D_80189FEC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80189F9C[]; -extern char D_80189F5C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80189F9C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80189F5C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018A024[])(void); - -void func_8016A020(void *a0) { - D_8018A024[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80189FF4; - extern u8 D_8018A008[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80189FF4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018A008; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018A030[])(void); - -void func_8016A700(void *a0) { - D_8018A030[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018A078[])(void); - -void func_8016AB30(void *a0) { - D_8018A078[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c b/src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c new file mode 100644 index 000000000..42569429d --- /dev/null +++ b/src/ov_SC03_024/ov_SC03_024_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80189444; +extern u8 D_801893B4; +extern u8 D_80189390; +extern u8 D_8018936C; +extern u8 D_80189420; +extern u8 D_801893FC; +extern u8 D_801893D8; +extern u8 D_80189348; +extern void func_80145934(void); +extern u8 D_801894D4; +extern u8 D_801894B0; +extern u8 D_8018948C; +extern u8 D_80189468; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801888CC[]; +extern unsigned char D_801888FC[]; +extern unsigned char D_8018894C[]; +extern unsigned char D_8018897C[]; +extern unsigned char D_801889AC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801889FC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80188AC4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80188B4C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80188B54; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C0008; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C000C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80188B84; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80188C2C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80188C50[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80188C40; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80188C64[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80188C70[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80188C80[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80188C98[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80188C88; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80188CAC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80188CC8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80188CB8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80188CDC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80188CF0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80188D04; +extern void (*D_80188D2C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80188D0C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80188D78[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80188D7C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801891E0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801891F0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C0040; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80189218[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801891F8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80189208; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80189258[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80189260[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018922C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018926C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018923C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C0048; +extern s32 D_801C0054; +extern s32 D_801C0058; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801892A8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018927C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C0050; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801894F8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80189318[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018959C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801896F0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018950C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801896F8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018951C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018953C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80189700[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80189728[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801895A8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80189734[])(void); + +void func_8015C714(void *a0) { + D_80189734[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801895A8[])(void*); + extern int D_8018954C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801895A8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801895A8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018954C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801895A8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801895A8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801895A8[])(void*); + extern int D_8018954C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801895A8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018954C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801895A8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80189744[])(void); + D_80189744[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801895A8[])(struct Ent_8015CD20 *); + extern u8 D_8018955C; + extern u8 D_8018974C; + extern u8 D_8018975C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801895A8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018955C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018974C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018975C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801895A8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018977C[])(void); + D_8018977C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018976C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018976C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801895A8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801897D8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801897D8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801888BC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801888BC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801897E0[])(void); + D_801897E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801897EC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801897EC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801897EC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801897EC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801895A8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801897EC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018956C[]; + extern u8 D_8018957C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018956C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018957C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801897EC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801897EC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801897EC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80189820[])(void); + D_80189820[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801895A8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80189828[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80189840[])(void); + D_80189840[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801895A8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80189828[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80189828[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80189860[])(void); + D_80189860[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801895A8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801895A8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80189870; +extern u16 D_80189872; +extern u16 D_80189874; +extern s32 D_80189878; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80189870 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80189872 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80189874 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80189878, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80189880; + +void func_8015E588(void) { + func_8013C9C4(&D_80189880); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801895A8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801895A8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80189894[])(void); + D_80189894[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801895A8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801895A8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018989C[])(void); + D_8018989C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018958C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018958C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801895A8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801898A4[])(void); + D_801898A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801895A8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801895A8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801898AC[])(void); + D_801898AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801895A8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801898B4; + extern s32 D_801898C4; + extern s32 D_801898D4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801898B4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801898C4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801895A8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801898D4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801898E4[])(void); + D_801898E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801895A8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801895A8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801895A8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801895A8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801898F0[])(void); + D_801898F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801895A8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801895A8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801895A8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801895A8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80189904[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80189904[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801895A8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801895A8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801895A8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801895A8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80189980[])(void); + D_80189980[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801895A8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801895A8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80189990[])(void); + D_80189990[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801895A8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801895A8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801895A8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801895A8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801895A8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801895A8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801895A8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80189998[])(void); + D_80189998[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801895A8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801895A8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801895A8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801895A8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801899A4[])(void); + D_801899A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801895A8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801895A8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801895A8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801895A8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801899B4[])(void); + +void func_80160EA4(void *a0) { + D_801899B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801895A8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801895A8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801899E4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801899E4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80189A48; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80189A48); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C0060[]; + extern u8 D_80189A14[]; + extern u8 D_80189A34[]; + extern u8 D_801C006C[]; + extern u8 D_801C0094[]; + extern u8 D_801C00AC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C0060[0] = p; + func_80024054(&D_80189A14, &D_801C006C); + func_8001CE28(p, &D_801C006C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C0060[1] = p; + func_80024054(&D_80189A34, &D_801C0094); + func_8001CE28(p, &D_801C0094); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C0060[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C00AC, 0x84); + func_8001CE68(p, &D_801C00AC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C00AC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C0060[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C0060; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80189A48; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80189A48; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80189A48; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80189A48; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C0060[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C0060; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80189A6C[])(void); + +void func_80162330(void *a0) { + D_80189A6C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C00B8[i] via `extern int D_801C00B8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80189A78[]; + extern s32 D_80189A90; + extern u8 D_801C00C4[]; + extern u8 D_801C00EC[]; + extern u8 D_801C0108[]; + extern int D_801C00B8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C00B8[0] = (s32)item; + func_80024054(D_80189A78, D_801C00C4); + func_8001CE28(item, D_801C00C4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C00B8[1] = (s32)item; + func_80024054(((u8 *)&D_80189A90), D_801C00EC); + func_8001CE28(item, D_801C00EC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C00B8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C0108, 0x84); + func_8001CE68(item, D_801C0108); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C0108, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C00B8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C00B8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_801627E8); + + +extern void (*D_80189AB4[])(void); + +void func_80162834(void *a0) { + D_80189AB4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80189AA4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80189AA4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801BF81C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801BF81C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801BF81C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801BF81C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80189ABC[])(void); + +void func_80163A58(void *a0) { + D_80189ABC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801BF824; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801BF824; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80189B10[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80189B10[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80189AD8; +extern s16 D_80189B0C; +extern s16 D_80189B0A; +extern s16 D_80189B08; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80189AD8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80189B0C = 0x80; + D_80189B0A = 0x80; + D_80189B08 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80189B0C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80189B0C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80189B0C - 8; + D_80189B0C = nv; + D_80189B0A = nv; + D_80189B08 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80189B1C[])(void); + +void func_80164BA0(void *a0) { + D_80189B1C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C0118; +extern u8 D_801C0119; +extern u8 D_801C011A; +extern u8 D_801C011B; +extern u8 D_801C011C; +extern u8 D_801C011D; +extern u8 D_801C011E; +extern u8 D_801C011F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C0118; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C0119 = 0xf0; + *(u8 *)base = 0xf0; + D_801C011A = 0xc0; + D_801C011E = 0; + D_801C011D = 0; + D_801C011C = 0; + D_801C011F = 0; + D_801C011B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C0118; +extern u8 D_801C0119; +extern u8 D_801C011A; + +s32 func_80164E40(void) { + u8 *p = &D_801C0118; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C0119 != 0) { + D_801C0119 -= 0x10; + } + if (D_801C011A != 0) { + D_801C011A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80189B2C[])(void); + +void func_80164EA4(void *a0) { + D_80189B2C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C0164[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C0164[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C0158[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C0158[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C0158[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C0158; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C0158; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80189B40[]; + extern u32 D_80189B60, D_80189B64, D_80189B68, D_80189B6C; + extern u32 D_80189B60, D_80189B64, D_80189B68, D_80189B6C; + extern u32 D_80189B60, D_80189B64, D_80189B68, D_80189B6C; + extern u32 D_80189B60, D_80189B64, D_80189B68, D_80189B6C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80189B40[0x00], p); + ApplyMatrixSV(mat, &D_80189B40[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80189B40[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80189B40[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80189B68; + *(u32 *)(prim + 0x24) = D_80189B60; + *(u32 *)(prim + 0x28) = D_80189B6C; + *(u32 *)(prim + 0x2c) = D_80189B64; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80189B70[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80189B70[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80189B70[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80189B70[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80189BEC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80189BEC[a1 & 0x7F]; +} + + + +extern s32 D_80189C0C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80189C0C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80189C88[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80189C88[a1 & 0x7F]; +} + + + +extern u8 D_80189CA8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80189CA8[a1 & 0x7F]; +} + + + +extern u8 D_80189CC8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80189CC8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80189CE8[])(void); + D_80189CE8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80189D64[])(void); + +void func_80165AC8(void) { + D_80189D64[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80189DE0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80189DE0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801BF82C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801BF82C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80189DEC[])(void); + +void func_80166018(void *a0) { + D_80189DEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80189DF4[])(void); + +void func_801663FC(void *a0) { + D_80189DF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80189EBC[])(void); + +void func_80166618(void *a0) { + D_80189EBC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80189ECC[])(void); + +void func_80166654(void *a0) { + D_80189ECC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C01D8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C01D8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C01D8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C01D8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C01D8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C01D8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C01D8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80189E10[]; + extern u8 D_80189DFC[]; + extern u8 D_80189E24[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80189E10; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80189DFC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80189E24; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80167714); + + +extern void (*D_80189EDC[])(void); + +void func_801678B4(void *a0) { + D_80189EDC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80189EE8[])(void); + +void func_80167A9C(void *a0) { + D_80189EE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80189FF4; + extern u8 D_8018A008[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80189FF4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018A008; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80189E48[]; +extern u8 D_80189E5C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80189E48; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80189E5C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80189F00[])(void); + +void func_80168744(void *a0) { + D_80189F00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80189EF0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80189EF0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80189EF0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80189F08[])(void); + +void func_801689D8(void *a0) { + D_80189F08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80189F10[])(void); + +void func_80168AA8(void *a0) { + D_80189F10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80189F18[])(void); + +void func_80168D58(void *a0) { + D_80189F18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80189F20[])(void); + +void func_8016901C(void *a0) { + D_80189F20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_024/nonmatchings/ov_SC03_024_jr_8015C32C", func_80169228); + + +extern void (*D_80189F28[])(void); + +void func_801693CC(void *a0) { + D_80189F28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80189F30[])(void); + +void func_80169830(void *a0) { + D_80189F30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80189FE4[])(void); + +void func_80169B80(void *a0) { + D_80189FE4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80189F38[]; + extern u8 D_80189FA8[]; + extern u8 D_80189FD8[]; + extern u8 D_801C1708[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80189FD8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80189F38[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C1708; + RotMatrixYXZ(rot, D_801C1708); + func_80048D9C(D_801C1708, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80189FA8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80189FEC[])(void); + +void func_80169F00(void *a0) { + D_80189FEC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80189F9C[]; +extern char D_80189F5C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80189F9C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80189F5C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018A024[])(void); + +void func_8016A020(void *a0) { + D_8018A024[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80189FF4; + extern u8 D_8018A008[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80189FF4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018A008; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018A030[])(void); + +void func_8016A700(void *a0) { + D_8018A030[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018A078[])(void); + +void func_8016AB30(void *a0) { + D_8018A078[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_028/ov_SC03_028_jr_8015AE2C.c b/src/ov_SC03_028/ov_SC03_028_jr_8015AE2C.c index 7d0f08d35..9870e38c5 100644 --- a/src/ov_SC03_028/ov_SC03_028_jr_8015AE2C.c +++ b/src/ov_SC03_028/ov_SC03_028_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018E200[])(void); - -void func_8015C714(void *a0) { - D_8018E200[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018E074[])(void*); - extern int D_8018E018; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018E074)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018E074)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018E018); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018E074[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018E074[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018E074[])(void*); - extern int D_8018E018; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018E074)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018E018); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018E074)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018E210[])(void); - D_8018E210[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018E074[])(struct Ent_8015CD20 *); - extern u8 D_8018E028; - extern u8 D_8018E218; - extern u8 D_8018E228; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018E074[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E028); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E218); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E228); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018E074[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018E248[])(void); - D_8018E248[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018E238; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018E238 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018E074[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018E2A4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018E2A4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018D388[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018D388; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018E2AC[])(void); - D_8018E2AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018E2B8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018E2B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018E2B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018E2B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018E074[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018E2B8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018E038[]; - extern u8 D_8018E048[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018E038); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018E048); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018E2B8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018E2B8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018E2B8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018E2EC[])(void); - D_8018E2EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018E074[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018E2F4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018E30C[])(void); - D_8018E30C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018E074[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018E2F4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018E32C[])(void); - D_8018E32C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018E074[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018E074)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018E33C; -extern u16 D_8018E33E; -extern u16 D_8018E340; -extern s32 D_8018E344; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018E33C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018E33E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018E340 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018E344, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018E34C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018E34C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018E074[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018E074)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018E360[])(void); - D_8018E360[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018E074[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018E074[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018E368[])(void); - D_8018E368[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018E058; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018E058); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018E074[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018E370[])(void); - D_8018E370[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018E074[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018E074[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018E378[])(void); - D_8018E378[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018E074[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018E380; - extern s32 D_8018E390; - extern s32 D_8018E3A0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018E074[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E380); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E390); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018E074[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E3A0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018E3B0[])(void); - D_8018E3B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018E074[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018E074[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018E074[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018E074[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018E3BC[])(void); - D_8018E3BC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018E074[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018E074[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018E074[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018E074[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018E3D0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018E3D0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018E074[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018E074)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018E074[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018E074[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018E44C[])(void); - D_8018E44C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018E074[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018E074)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018E45C[])(void); - D_8018E45C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018E074[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018E074[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018E074[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018E074[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018E074[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018E074[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018E074[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018E464[])(void); - D_8018E464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018E074[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018E074)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018E074[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018E074)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018E470[])(void); - D_8018E470[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018E074 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018E074[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018E074[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018E074[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018E480[])(void); - -void func_80160EA4(void *a0) { - D_8018E480[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018E074[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018E074[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018E4B0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018E4B0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018E514; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018E514); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801EA398[]; - extern u8 D_8018E4E0[]; - extern u8 D_8018E500[]; - extern u8 D_801EA3A4[]; - extern u8 D_801EA3CC[]; - extern u8 D_801EA3E4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801EA398[0] = p; - func_80024054(&D_8018E4E0, &D_801EA3A4); - func_8001CE28(p, &D_801EA3A4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801EA398[1] = p; - func_80024054(&D_8018E500, &D_801EA3CC); - func_8001CE28(p, &D_801EA3CC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801EA398[2] = p; - func_800242D0((s16)func_801620C4(), &D_801EA3E4, 0x84); - func_8001CE68(p, &D_801EA3E4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801EA3E4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EA398[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801EA398; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018E514; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018E514; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018E514; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018E514; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801EA398[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801EA398; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018E538[])(void); - -void func_80162330(void *a0) { - D_8018E538[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801EA3F0[i] via `extern int D_801EA3F0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018E544[]; - extern s32 D_8018E55C; - extern u8 D_801EA3FC[]; - extern u8 D_801EA424[]; - extern u8 D_801EA440[]; - extern int D_801EA3F0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801EA3F0[0] = (s32)item; - func_80024054(D_8018E544, D_801EA3FC); - func_8001CE28(item, D_801EA3FC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801EA3F0[1] = (s32)item; - func_80024054(((u8 *)&D_8018E55C), D_801EA424); - func_8001CE28(item, D_801EA424); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801EA3F0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801EA440, 0x84); - func_8001CE68(item, D_801EA440); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801EA440, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EA3F0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801EA3F0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018E580[])(void); - -void func_80162834(void *a0) { - D_8018E580[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018E570; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018E570, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E99A4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E99A4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E99A4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E99A4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018E588[])(void); - -void func_80163A58(void *a0) { - D_8018E588[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E99AC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E99AC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018E5DC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018E5DC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018E5A4; -extern s16 D_8018E5D8; -extern s16 D_8018E5D6; -extern s16 D_8018E5D4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018E5A4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018E5D8 = 0x80; - D_8018E5D6 = 0x80; - D_8018E5D4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018E5D8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E5D8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018E5D8 - 8; - D_8018E5D8 = nv; - D_8018E5D6 = nv; - D_8018E5D4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018E5E8[])(void); - -void func_80164BA0(void *a0) { - D_8018E5E8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801EA450; -extern u8 D_801EA451; -extern u8 D_801EA452; -extern u8 D_801EA453; -extern u8 D_801EA454; -extern u8 D_801EA455; -extern u8 D_801EA456; -extern u8 D_801EA457; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801EA450; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801EA451 = 0xf0; - *(u8 *)base = 0xf0; - D_801EA452 = 0xc0; - D_801EA456 = 0; - D_801EA455 = 0; - D_801EA454 = 0; - D_801EA457 = 0; - D_801EA453 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801EA450; -extern u8 D_801EA451; -extern u8 D_801EA452; - -s32 func_80164E40(void) { - u8 *p = &D_801EA450; - if (*p != 0) { - *p -= 0x10; - } - if (D_801EA451 != 0) { - D_801EA451 -= 0x10; - } - if (D_801EA452 != 0) { - D_801EA452 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018E5F8[])(void); - -void func_80164EA4(void *a0) { - D_8018E5F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801EA49C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801EA49C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801EA490[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801EA490[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801EA490[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801EA490; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801EA490; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018E60C[]; - extern u32 D_8018E62C, D_8018E630, D_8018E634, D_8018E638; - extern u32 D_8018E62C, D_8018E630, D_8018E634, D_8018E638; - extern u32 D_8018E62C, D_8018E630, D_8018E634, D_8018E638; - extern u32 D_8018E62C, D_8018E630, D_8018E634, D_8018E638; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018E60C[0x00], p); - ApplyMatrixSV(mat, &D_8018E60C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018E60C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018E60C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018E634; - *(u32 *)(prim + 0x24) = D_8018E62C; - *(u32 *)(prim + 0x28) = D_8018E638; - *(u32 *)(prim + 0x2c) = D_8018E630; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018E63C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018E63C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018E63C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018E63C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018E6B8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018E6B8[a1 & 0x7F]; -} - - - -extern s32 D_8018E6D8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018E6D8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018E754[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018E754[a1 & 0x7F]; -} - - - -extern u8 D_8018E774[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018E774[a1 & 0x7F]; -} - - - -extern u8 D_8018E794[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018E794[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018E7B4[])(void); - D_8018E7B4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018E830[])(void); - -void func_80165AC8(void) { - D_8018E830[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018E8AC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018E8AC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E99B4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E99B4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018E8B8[])(void); - -void func_80166018(void *a0) { - D_8018E8B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018E8C0[])(void); - -void func_801663FC(void *a0) { - D_8018E8C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018E988[])(void); - -void func_80166618(void *a0) { - D_8018E988[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018E998[])(void); - -void func_80166654(void *a0) { - D_8018E998[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801EA510[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801EA510[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EA510). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801EA510[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801EA510)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801EA510[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801EA510[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018E8DC[]; - extern u8 D_8018E8C8[]; - extern u8 D_8018E8F0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018E8DC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018E8C8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018E8F0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80167714); - - -extern void (*D_8018E9A8[])(void); - -void func_801678B4(void *a0) { - D_8018E9A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018E9B4[])(void); - -void func_80167A9C(void *a0) { - D_8018E9B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018EAC0; - extern u8 D_8018EAD4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018EAC0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018EAD4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018E914[]; -extern u8 D_8018E928[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018E914; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018E928; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018E9CC[])(void); - -void func_80168744(void *a0) { - D_8018E9CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018E9BC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018E9BC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018E9BC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018E9D4[])(void); - -void func_801689D8(void *a0) { - D_8018E9D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018E9DC[])(void); - -void func_80168AA8(void *a0) { - D_8018E9DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018E9E4[])(void); - -void func_80168D58(void *a0) { - D_8018E9E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018E9EC[])(void); - -void func_8016901C(void *a0) { - D_8018E9EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015AE2C", func_80169228); - - -extern void (*D_8018E9F4[])(void); - -void func_801693CC(void *a0) { - D_8018E9F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018E9FC[])(void); - -void func_80169830(void *a0) { - D_8018E9FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018EAB0[])(void); - -void func_80169B80(void *a0) { - D_8018EAB0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018EA04[]; - extern u8 D_8018EA74[]; - extern u8 D_8018EAA4[]; - extern u8 D_801EC4C0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018EAA4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018EA04[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801EC4C0; - RotMatrixYXZ(rot, D_801EC4C0); - func_80048D9C(D_801EC4C0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018EA74); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018EAB8[])(void); - -void func_80169F00(void *a0) { - D_8018EAB8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018EA68[]; -extern char D_8018EA28[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018EA68, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018EA28); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018EAF0[])(void); - -void func_8016A020(void *a0) { - D_8018EAF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018EAC0; - extern u8 D_8018EAD4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018EAC0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018EAD4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018EAFC[])(void); - -void func_8016A700(void *a0) { - D_8018EAFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018EB44[])(void); - -void func_8016AB30(void *a0) { - D_8018EB44[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c b/src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c new file mode 100644 index 000000000..ddfa5a849 --- /dev/null +++ b/src/ov_SC03_028/ov_SC03_028_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018DF10; +extern u8 D_8018DE80; +extern u8 D_8018DE5C; +extern u8 D_8018DE38; +extern u8 D_8018DEEC; +extern u8 D_8018DEC8; +extern u8 D_8018DEA4; +extern u8 D_8018DE14; +extern void func_80145934(void); +extern u8 D_8018DFA0; +extern u8 D_8018DF7C; +extern u8 D_8018DF58; +extern u8 D_8018DF34; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018D398[]; +extern unsigned char D_8018D3C8[]; +extern unsigned char D_8018D418[]; +extern unsigned char D_8018D448[]; +extern unsigned char D_8018D478[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018D4C8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018D590[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018D618[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018D620; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801EA340; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801EA344; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018D650; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018D6F8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018D71C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018D70C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018D730[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018D73C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018D74C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018D764[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018D754; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018D778[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018D794[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018D784; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018D7A8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018D7BC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018D7D0; +extern void (*D_8018D7F8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018D7D8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018D844[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018D848[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018DCAC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018DCBC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801EA378; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018DCE4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018DCC4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018DCD4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018DD24[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018DD2C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018DCF8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018DD38[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018DD08; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801EA380; +extern s32 D_801EA38C; +extern s32 D_801EA390; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018DD74[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018DD48[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801EA388; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018DFC4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018DDE4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018E068[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018E1BC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018DFD8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018E1C4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018DFE8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018E008; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018E1CC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018E1F4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018E074[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018E200[])(void); + +void func_8015C714(void *a0) { + D_8018E200[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018E074[])(void*); + extern int D_8018E018; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018E074)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018E074)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018E018); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018E074[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018E074[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018E074[])(void*); + extern int D_8018E018; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018E074)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018E018); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018E074)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018E210[])(void); + D_8018E210[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018E074[])(struct Ent_8015CD20 *); + extern u8 D_8018E028; + extern u8 D_8018E218; + extern u8 D_8018E228; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018E074[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E028); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E218); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E228); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018E074[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018E248[])(void); + D_8018E248[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018E238; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018E238 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018E074[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018E2A4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018E2A4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018D388[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018D388; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018E2AC[])(void); + D_8018E2AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018E2B8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018E2B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018E2B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018E2B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018E074[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018E2B8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018E038[]; + extern u8 D_8018E048[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018E038); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018E048); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018E2B8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018E2B8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018E2B8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018E2EC[])(void); + D_8018E2EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018E074[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018E2F4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018E30C[])(void); + D_8018E30C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018E074[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018E2F4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018E2F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018E32C[])(void); + D_8018E32C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018E074[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018E074)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018E33C; +extern u16 D_8018E33E; +extern u16 D_8018E340; +extern s32 D_8018E344; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018E33C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018E33E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018E340 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018E344, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018E34C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018E34C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018E074[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018E074)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018E360[])(void); + D_8018E360[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018E074[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018E074[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018E368[])(void); + D_8018E368[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018E058; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018E058); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018E074[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018E370[])(void); + D_8018E370[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018E074[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018E074[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018E378[])(void); + D_8018E378[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018E074[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018E380; + extern s32 D_8018E390; + extern s32 D_8018E3A0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E380); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E390); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018E074[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E3A0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018E3B0[])(void); + D_8018E3B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018E074[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018E074[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018E074[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018E074[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018E3BC[])(void); + D_8018E3BC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018E074[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018E074[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018E074[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018E074[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018E3D0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018E3D0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018E074[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018E074)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018E074[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018E074[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018E44C[])(void); + D_8018E44C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018E074[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018E074)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018E45C[])(void); + D_8018E45C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018E074[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018E074[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018E074[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018E074[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018E074[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018E074[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018E074[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018E464[])(void); + D_8018E464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018E074[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018E074)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018E074[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018E074)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018E470[])(void); + D_8018E470[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018E074 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018E074[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018E074[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018E074[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018E480[])(void); + +void func_80160EA4(void *a0) { + D_8018E480[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018E074[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018E074[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018E4B0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018E4B0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018E514; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018E514); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801EA398[]; + extern u8 D_8018E4E0[]; + extern u8 D_8018E500[]; + extern u8 D_801EA3A4[]; + extern u8 D_801EA3CC[]; + extern u8 D_801EA3E4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801EA398[0] = p; + func_80024054(&D_8018E4E0, &D_801EA3A4); + func_8001CE28(p, &D_801EA3A4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801EA398[1] = p; + func_80024054(&D_8018E500, &D_801EA3CC); + func_8001CE28(p, &D_801EA3CC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801EA398[2] = p; + func_800242D0((s16)func_801620C4(), &D_801EA3E4, 0x84); + func_8001CE68(p, &D_801EA3E4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801EA3E4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EA398[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801EA398; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018E514; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018E514; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018E514; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018E514; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801EA398[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801EA398; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018E538[])(void); + +void func_80162330(void *a0) { + D_8018E538[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801EA3F0[i] via `extern int D_801EA3F0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018E544[]; + extern s32 D_8018E55C; + extern u8 D_801EA3FC[]; + extern u8 D_801EA424[]; + extern u8 D_801EA440[]; + extern int D_801EA3F0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801EA3F0[0] = (s32)item; + func_80024054(D_8018E544, D_801EA3FC); + func_8001CE28(item, D_801EA3FC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801EA3F0[1] = (s32)item; + func_80024054(((u8 *)&D_8018E55C), D_801EA424); + func_8001CE28(item, D_801EA424); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801EA3F0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801EA440, 0x84); + func_8001CE68(item, D_801EA440); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801EA440, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EA3F0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801EA3F0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_801627E8); + + +extern void (*D_8018E580[])(void); + +void func_80162834(void *a0) { + D_8018E580[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018E570; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018E570, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E99A4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E99A4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E99A4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E99A4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018E588[])(void); + +void func_80163A58(void *a0) { + D_8018E588[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E99AC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E99AC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018E5DC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018E5DC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018E5A4; +extern s16 D_8018E5D8; +extern s16 D_8018E5D6; +extern s16 D_8018E5D4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018E5A4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018E5D8 = 0x80; + D_8018E5D6 = 0x80; + D_8018E5D4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018E5D8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E5D8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018E5D8 - 8; + D_8018E5D8 = nv; + D_8018E5D6 = nv; + D_8018E5D4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018E5E8[])(void); + +void func_80164BA0(void *a0) { + D_8018E5E8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801EA450; +extern u8 D_801EA451; +extern u8 D_801EA452; +extern u8 D_801EA453; +extern u8 D_801EA454; +extern u8 D_801EA455; +extern u8 D_801EA456; +extern u8 D_801EA457; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801EA450; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801EA451 = 0xf0; + *(u8 *)base = 0xf0; + D_801EA452 = 0xc0; + D_801EA456 = 0; + D_801EA455 = 0; + D_801EA454 = 0; + D_801EA457 = 0; + D_801EA453 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801EA450; +extern u8 D_801EA451; +extern u8 D_801EA452; + +s32 func_80164E40(void) { + u8 *p = &D_801EA450; + if (*p != 0) { + *p -= 0x10; + } + if (D_801EA451 != 0) { + D_801EA451 -= 0x10; + } + if (D_801EA452 != 0) { + D_801EA452 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018E5F8[])(void); + +void func_80164EA4(void *a0) { + D_8018E5F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801EA49C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801EA49C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801EA490[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801EA490[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801EA490[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801EA490; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801EA490; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018E60C[]; + extern u32 D_8018E62C, D_8018E630, D_8018E634, D_8018E638; + extern u32 D_8018E62C, D_8018E630, D_8018E634, D_8018E638; + extern u32 D_8018E62C, D_8018E630, D_8018E634, D_8018E638; + extern u32 D_8018E62C, D_8018E630, D_8018E634, D_8018E638; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018E60C[0x00], p); + ApplyMatrixSV(mat, &D_8018E60C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018E60C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018E60C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018E634; + *(u32 *)(prim + 0x24) = D_8018E62C; + *(u32 *)(prim + 0x28) = D_8018E638; + *(u32 *)(prim + 0x2c) = D_8018E630; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018E63C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018E63C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018E63C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018E63C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018E6B8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018E6B8[a1 & 0x7F]; +} + + + +extern s32 D_8018E6D8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018E6D8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018E754[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018E754[a1 & 0x7F]; +} + + + +extern u8 D_8018E774[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018E774[a1 & 0x7F]; +} + + + +extern u8 D_8018E794[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018E794[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018E7B4[])(void); + D_8018E7B4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018E830[])(void); + +void func_80165AC8(void) { + D_8018E830[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018E8AC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018E8AC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E99B4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E99B4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018E8B8[])(void); + +void func_80166018(void *a0) { + D_8018E8B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018E8C0[])(void); + +void func_801663FC(void *a0) { + D_8018E8C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018E988[])(void); + +void func_80166618(void *a0) { + D_8018E988[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018E998[])(void); + +void func_80166654(void *a0) { + D_8018E998[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801EA510[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801EA510[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EA510). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801EA510[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801EA510)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801EA510[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801EA510[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018E8DC[]; + extern u8 D_8018E8C8[]; + extern u8 D_8018E8F0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018E8DC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018E8C8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018E8F0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80167714); + + +extern void (*D_8018E9A8[])(void); + +void func_801678B4(void *a0) { + D_8018E9A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018E9B4[])(void); + +void func_80167A9C(void *a0) { + D_8018E9B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018EAC0; + extern u8 D_8018EAD4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018EAC0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018EAD4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018E914[]; +extern u8 D_8018E928[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018E914; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018E928; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018E9CC[])(void); + +void func_80168744(void *a0) { + D_8018E9CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018E9BC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018E9BC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018E9BC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018E9D4[])(void); + +void func_801689D8(void *a0) { + D_8018E9D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018E9DC[])(void); + +void func_80168AA8(void *a0) { + D_8018E9DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018E9E4[])(void); + +void func_80168D58(void *a0) { + D_8018E9E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018E9EC[])(void); + +void func_8016901C(void *a0) { + D_8018E9EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_028/nonmatchings/ov_SC03_028_jr_8015C32C", func_80169228); + + +extern void (*D_8018E9F4[])(void); + +void func_801693CC(void *a0) { + D_8018E9F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018E9FC[])(void); + +void func_80169830(void *a0) { + D_8018E9FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018EAB0[])(void); + +void func_80169B80(void *a0) { + D_8018EAB0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018EA04[]; + extern u8 D_8018EA74[]; + extern u8 D_8018EAA4[]; + extern u8 D_801EC4C0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018EAA4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018EA04[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801EC4C0; + RotMatrixYXZ(rot, D_801EC4C0); + func_80048D9C(D_801EC4C0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018EA74); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018EAB8[])(void); + +void func_80169F00(void *a0) { + D_8018EAB8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018EA68[]; +extern char D_8018EA28[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018EA68, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018EA28); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018EAF0[])(void); + +void func_8016A020(void *a0) { + D_8018EAF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018EAC0; + extern u8 D_8018EAD4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018EAC0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018EAD4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018EAFC[])(void); + +void func_8016A700(void *a0) { + D_8018EAFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018EB44[])(void); + +void func_8016AB30(void *a0) { + D_8018EB44[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_029/ov_SC03_029_jr_8015AE2C.c b/src/ov_SC03_029/ov_SC03_029_jr_8015AE2C.c index 879e76c97..07e917aba 100644 --- a/src/ov_SC03_029/ov_SC03_029_jr_8015AE2C.c +++ b/src/ov_SC03_029/ov_SC03_029_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018A038[])(void); - -void func_8015C714(void *a0) { - D_8018A038[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80189EAC[])(void*); - extern int D_80189E50; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80189EAC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80189EAC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189E50); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80189EAC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80189EAC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80189EAC[])(void*); - extern int D_80189E50; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80189EAC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189E50); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80189EAC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018A048[])(void); - D_8018A048[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80189EAC[])(struct Ent_8015CD20 *); - extern u8 D_80189E60; - extern u8 D_8018A050; - extern u8 D_8018A060; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80189EAC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189E60); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A050); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A060); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80189EAC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018A080[])(void); - D_8018A080[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018A070; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018A070 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80189EAC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018A0DC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018A0DC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801891C0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801891C0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018A0E4[])(void); - D_8018A0E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018A0F0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018A0F0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018A0F0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018A0F0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80189EAC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018A0F0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80189E70[]; - extern u8 D_80189E80[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189E70); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189E80); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018A0F0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018A0F0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018A0F0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018A124[])(void); - D_8018A124[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80189EAC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018A12C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018A144[])(void); - D_8018A144[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80189EAC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018A12C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018A164[])(void); - D_8018A164[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80189EAC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80189EAC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018A174; -extern u16 D_8018A176; -extern u16 D_8018A178; -extern s32 D_8018A17C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018A174 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018A176 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018A178 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018A17C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018A184; - -void func_8015E588(void) { - func_8013C9C4(&D_8018A184); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80189EAC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80189EAC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018A198[])(void); - D_8018A198[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80189EAC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80189EAC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018A1A0[])(void); - D_8018A1A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80189E90; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80189E90); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80189EAC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018A1A8[])(void); - D_8018A1A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80189EAC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80189EAC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018A1B0[])(void); - D_8018A1B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80189EAC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018A1B8; - extern s32 D_8018A1C8; - extern s32 D_8018A1D8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80189EAC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A1B8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A1C8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80189EAC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A1D8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018A1E8[])(void); - D_8018A1E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80189EAC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80189EAC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80189EAC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80189EAC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018A1F4[])(void); - D_8018A1F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80189EAC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80189EAC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80189EAC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80189EAC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018A208[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018A208[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80189EAC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80189EAC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80189EAC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80189EAC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018A284[])(void); - D_8018A284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80189EAC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80189EAC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018A294[])(void); - D_8018A294[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80189EAC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80189EAC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80189EAC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80189EAC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80189EAC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80189EAC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80189EAC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018A29C[])(void); - D_8018A29C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80189EAC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80189EAC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80189EAC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80189EAC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018A2A8[])(void); - D_8018A2A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80189EAC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80189EAC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80189EAC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80189EAC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018A2B8[])(void); - -void func_80160EA4(void *a0) { - D_8018A2B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80189EAC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80189EAC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018A2E8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018A2E8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018A34C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018A34C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801D8370[]; - extern u8 D_8018A318[]; - extern u8 D_8018A338[]; - extern u8 D_801D837C[]; - extern u8 D_801D83A4[]; - extern u8 D_801D83BC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801D8370[0] = p; - func_80024054(&D_8018A318, &D_801D837C); - func_8001CE28(p, &D_801D837C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801D8370[1] = p; - func_80024054(&D_8018A338, &D_801D83A4); - func_8001CE28(p, &D_801D83A4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801D8370[2] = p; - func_800242D0((s16)func_801620C4(), &D_801D83BC, 0x84); - func_8001CE68(p, &D_801D83BC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801D83BC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D8370[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801D8370; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018A34C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018A34C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018A34C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018A34C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801D8370[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801D8370; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018A370[])(void); - -void func_80162330(void *a0) { - D_8018A370[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801D83C8[i] via `extern int D_801D83C8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018A37C[]; - extern s32 D_8018A394; - extern u8 D_801D83D4[]; - extern u8 D_801D83FC[]; - extern u8 D_801D8418[]; - extern int D_801D83C8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801D83C8[0] = (s32)item; - func_80024054(D_8018A37C, D_801D83D4); - func_8001CE28(item, D_801D83D4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801D83C8[1] = (s32)item; - func_80024054(((u8 *)&D_8018A394), D_801D83FC); - func_8001CE28(item, D_801D83FC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801D83C8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801D8418, 0x84); - func_8001CE68(item, D_801D8418); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801D8418, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D83C8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801D83C8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018A3B8[])(void); - -void func_80162834(void *a0) { - D_8018A3B8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018A3A8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018A3A8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801D7AD8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801D7AD8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801D7AD8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801D7AD8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018A3C0[])(void); - -void func_80163A58(void *a0) { - D_8018A3C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801D7AE0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801D7AE0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018A414[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018A414[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018A3DC; -extern s16 D_8018A410; -extern s16 D_8018A40E; -extern s16 D_8018A40C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018A3DC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018A410 = 0x80; - D_8018A40E = 0x80; - D_8018A40C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018A410 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018A410` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018A410 - 8; - D_8018A410 = nv; - D_8018A40E = nv; - D_8018A40C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018A420[])(void); - -void func_80164BA0(void *a0) { - D_8018A420[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801D8428; -extern u8 D_801D8429; -extern u8 D_801D842A; -extern u8 D_801D842B; -extern u8 D_801D842C; -extern u8 D_801D842D; -extern u8 D_801D842E; -extern u8 D_801D842F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801D8428; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801D8429 = 0xf0; - *(u8 *)base = 0xf0; - D_801D842A = 0xc0; - D_801D842E = 0; - D_801D842D = 0; - D_801D842C = 0; - D_801D842F = 0; - D_801D842B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801D8428; -extern u8 D_801D8429; -extern u8 D_801D842A; - -s32 func_80164E40(void) { - u8 *p = &D_801D8428; - if (*p != 0) { - *p -= 0x10; - } - if (D_801D8429 != 0) { - D_801D8429 -= 0x10; - } - if (D_801D842A != 0) { - D_801D842A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018A430[])(void); - -void func_80164EA4(void *a0) { - D_8018A430[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801D8474[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801D8474[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801D8468[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801D8468[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801D8468[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801D8468; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801D8468; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018A444[]; - extern u32 D_8018A464, D_8018A468, D_8018A46C, D_8018A470; - extern u32 D_8018A464, D_8018A468, D_8018A46C, D_8018A470; - extern u32 D_8018A464, D_8018A468, D_8018A46C, D_8018A470; - extern u32 D_8018A464, D_8018A468, D_8018A46C, D_8018A470; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018A444[0x00], p); - ApplyMatrixSV(mat, &D_8018A444[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018A444[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018A444[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018A46C; - *(u32 *)(prim + 0x24) = D_8018A464; - *(u32 *)(prim + 0x28) = D_8018A470; - *(u32 *)(prim + 0x2c) = D_8018A468; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018A474[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018A474[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018A474[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018A474[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018A4F0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018A4F0[a1 & 0x7F]; -} - - - -extern s32 D_8018A510[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018A510[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018A58C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018A58C[a1 & 0x7F]; -} - - - -extern u8 D_8018A5AC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018A5AC[a1 & 0x7F]; -} - - - -extern u8 D_8018A5CC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018A5CC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018A5EC[])(void); - D_8018A5EC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018A668[])(void); - -void func_80165AC8(void) { - D_8018A668[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018A6E4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018A6E4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801D7AE8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801D7AE8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018A6F0[])(void); - -void func_80166018(void *a0) { - D_8018A6F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018A6F8[])(void); - -void func_801663FC(void *a0) { - D_8018A6F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018A7C0[])(void); - -void func_80166618(void *a0) { - D_8018A7C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018A7D0[])(void); - -void func_80166654(void *a0) { - D_8018A7D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801D84E8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801D84E8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D84E8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801D84E8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801D84E8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801D84E8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801D84E8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018A714[]; - extern u8 D_8018A700[]; - extern u8 D_8018A728[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018A714; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018A700; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018A728; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80167714); - - -extern void (*D_8018A7E0[])(void); - -void func_801678B4(void *a0) { - D_8018A7E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018A7EC[])(void); - -void func_80167A9C(void *a0) { - D_8018A7EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018A8F8; - extern u8 D_8018A90C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018A8F8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018A90C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018A74C[]; -extern u8 D_8018A760[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018A74C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018A760; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018A804[])(void); - -void func_80168744(void *a0) { - D_8018A804[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018A7F4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018A7F4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018A7F4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018A80C[])(void); - -void func_801689D8(void *a0) { - D_8018A80C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018A814[])(void); - -void func_80168AA8(void *a0) { - D_8018A814[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018A81C[])(void); - -void func_80168D58(void *a0) { - D_8018A81C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018A824[])(void); - -void func_8016901C(void *a0) { - D_8018A824[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015AE2C", func_80169228); - - -extern void (*D_8018A82C[])(void); - -void func_801693CC(void *a0) { - D_8018A82C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018A834[])(void); - -void func_80169830(void *a0) { - D_8018A834[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018A8E8[])(void); - -void func_80169B80(void *a0) { - D_8018A8E8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018A83C[]; - extern u8 D_8018A8AC[]; - extern u8 D_8018A8DC[]; - extern u8 D_801D9900[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018A8DC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018A83C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801D9900; - RotMatrixYXZ(rot, D_801D9900); - func_80048D9C(D_801D9900, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018A8AC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018A8F0[])(void); - -void func_80169F00(void *a0) { - D_8018A8F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018A8A0[]; -extern char D_8018A860[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018A8A0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018A860); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018A928[])(void); - -void func_8016A020(void *a0) { - D_8018A928[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018A8F8; - extern u8 D_8018A90C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018A8F8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018A90C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018A934[])(void); - -void func_8016A700(void *a0) { - D_8018A934[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018A97C[])(void); - -void func_8016AB30(void *a0) { - D_8018A97C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c b/src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c new file mode 100644 index 000000000..d32964034 --- /dev/null +++ b/src/ov_SC03_029/ov_SC03_029_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80189D48; +extern u8 D_80189CB8; +extern u8 D_80189C94; +extern u8 D_80189C70; +extern u8 D_80189D24; +extern u8 D_80189D00; +extern u8 D_80189CDC; +extern u8 D_80189C4C; +extern void func_80145934(void); +extern u8 D_80189DD8; +extern u8 D_80189DB4; +extern u8 D_80189D90; +extern u8 D_80189D6C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801891D0[]; +extern unsigned char D_80189200[]; +extern unsigned char D_80189250[]; +extern unsigned char D_80189280[]; +extern unsigned char D_801892B0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80189300[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801893C8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80189450[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80189458; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801D8318; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801D831C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80189488; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80189530[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80189554[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80189544; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80189568[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80189574[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80189584[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018959C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018958C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801895B0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801895CC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801895BC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801895E0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801895F4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80189608; +extern void (*D_80189630[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80189610; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018967C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80189680[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80189AE4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80189AF4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801D8350; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80189B1C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80189AFC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80189B0C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80189B5C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80189B64[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80189B30; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80189B70[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80189B40; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801D8358; +extern s32 D_801D8364; +extern s32 D_801D8368; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80189BAC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80189B80[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801D8360; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80189DFC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80189C1C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80189EA0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80189FF4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80189E10; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80189FFC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80189E20; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80189E40; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018A004[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018A02C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80189EAC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018A038[])(void); + +void func_8015C714(void *a0) { + D_8018A038[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80189EAC[])(void*); + extern int D_80189E50; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80189EAC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80189EAC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189E50); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80189EAC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80189EAC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80189EAC[])(void*); + extern int D_80189E50; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80189EAC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189E50); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80189EAC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018A048[])(void); + D_8018A048[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80189EAC[])(struct Ent_8015CD20 *); + extern u8 D_80189E60; + extern u8 D_8018A050; + extern u8 D_8018A060; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80189EAC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189E60); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A050); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A060); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80189EAC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018A080[])(void); + D_8018A080[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018A070; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018A070 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80189EAC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018A0DC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018A0DC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801891C0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801891C0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018A0E4[])(void); + D_8018A0E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018A0F0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018A0F0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018A0F0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018A0F0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80189EAC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018A0F0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80189E70[]; + extern u8 D_80189E80[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189E70); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189E80); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018A0F0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018A0F0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018A0F0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018A124[])(void); + D_8018A124[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80189EAC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018A12C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018A144[])(void); + D_8018A144[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80189EAC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018A12C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018A12C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018A164[])(void); + D_8018A164[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80189EAC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80189EAC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018A174; +extern u16 D_8018A176; +extern u16 D_8018A178; +extern s32 D_8018A17C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018A174 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018A176 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018A178 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018A17C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018A184; + +void func_8015E588(void) { + func_8013C9C4(&D_8018A184); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80189EAC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80189EAC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018A198[])(void); + D_8018A198[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80189EAC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80189EAC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018A1A0[])(void); + D_8018A1A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80189E90; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80189E90); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80189EAC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018A1A8[])(void); + D_8018A1A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80189EAC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80189EAC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018A1B0[])(void); + D_8018A1B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80189EAC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018A1B8; + extern s32 D_8018A1C8; + extern s32 D_8018A1D8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A1B8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A1C8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80189EAC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A1D8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018A1E8[])(void); + D_8018A1E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80189EAC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80189EAC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80189EAC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80189EAC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018A1F4[])(void); + D_8018A1F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80189EAC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80189EAC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80189EAC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80189EAC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018A208[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018A208[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80189EAC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80189EAC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80189EAC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80189EAC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018A284[])(void); + D_8018A284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80189EAC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80189EAC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018A294[])(void); + D_8018A294[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80189EAC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80189EAC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80189EAC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80189EAC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80189EAC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80189EAC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80189EAC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018A29C[])(void); + D_8018A29C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80189EAC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80189EAC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80189EAC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80189EAC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018A2A8[])(void); + D_8018A2A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80189EAC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80189EAC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80189EAC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80189EAC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018A2B8[])(void); + +void func_80160EA4(void *a0) { + D_8018A2B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80189EAC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80189EAC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018A2E8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018A2E8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018A34C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018A34C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801D8370[]; + extern u8 D_8018A318[]; + extern u8 D_8018A338[]; + extern u8 D_801D837C[]; + extern u8 D_801D83A4[]; + extern u8 D_801D83BC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801D8370[0] = p; + func_80024054(&D_8018A318, &D_801D837C); + func_8001CE28(p, &D_801D837C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801D8370[1] = p; + func_80024054(&D_8018A338, &D_801D83A4); + func_8001CE28(p, &D_801D83A4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801D8370[2] = p; + func_800242D0((s16)func_801620C4(), &D_801D83BC, 0x84); + func_8001CE68(p, &D_801D83BC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801D83BC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D8370[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801D8370; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018A34C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018A34C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018A34C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018A34C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801D8370[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801D8370; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018A370[])(void); + +void func_80162330(void *a0) { + D_8018A370[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801D83C8[i] via `extern int D_801D83C8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018A37C[]; + extern s32 D_8018A394; + extern u8 D_801D83D4[]; + extern u8 D_801D83FC[]; + extern u8 D_801D8418[]; + extern int D_801D83C8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801D83C8[0] = (s32)item; + func_80024054(D_8018A37C, D_801D83D4); + func_8001CE28(item, D_801D83D4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801D83C8[1] = (s32)item; + func_80024054(((u8 *)&D_8018A394), D_801D83FC); + func_8001CE28(item, D_801D83FC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801D83C8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801D8418, 0x84); + func_8001CE68(item, D_801D8418); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801D8418, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D83C8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801D83C8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_801627E8); + + +extern void (*D_8018A3B8[])(void); + +void func_80162834(void *a0) { + D_8018A3B8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018A3A8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018A3A8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801D7AD8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801D7AD8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801D7AD8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801D7AD8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018A3C0[])(void); + +void func_80163A58(void *a0) { + D_8018A3C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801D7AE0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801D7AE0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018A414[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018A414[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018A3DC; +extern s16 D_8018A410; +extern s16 D_8018A40E; +extern s16 D_8018A40C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018A3DC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018A410 = 0x80; + D_8018A40E = 0x80; + D_8018A40C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018A410 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018A410` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018A410 - 8; + D_8018A410 = nv; + D_8018A40E = nv; + D_8018A40C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018A420[])(void); + +void func_80164BA0(void *a0) { + D_8018A420[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801D8428; +extern u8 D_801D8429; +extern u8 D_801D842A; +extern u8 D_801D842B; +extern u8 D_801D842C; +extern u8 D_801D842D; +extern u8 D_801D842E; +extern u8 D_801D842F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801D8428; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801D8429 = 0xf0; + *(u8 *)base = 0xf0; + D_801D842A = 0xc0; + D_801D842E = 0; + D_801D842D = 0; + D_801D842C = 0; + D_801D842F = 0; + D_801D842B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801D8428; +extern u8 D_801D8429; +extern u8 D_801D842A; + +s32 func_80164E40(void) { + u8 *p = &D_801D8428; + if (*p != 0) { + *p -= 0x10; + } + if (D_801D8429 != 0) { + D_801D8429 -= 0x10; + } + if (D_801D842A != 0) { + D_801D842A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018A430[])(void); + +void func_80164EA4(void *a0) { + D_8018A430[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801D8474[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801D8474[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801D8468[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801D8468[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801D8468[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801D8468; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801D8468; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018A444[]; + extern u32 D_8018A464, D_8018A468, D_8018A46C, D_8018A470; + extern u32 D_8018A464, D_8018A468, D_8018A46C, D_8018A470; + extern u32 D_8018A464, D_8018A468, D_8018A46C, D_8018A470; + extern u32 D_8018A464, D_8018A468, D_8018A46C, D_8018A470; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018A444[0x00], p); + ApplyMatrixSV(mat, &D_8018A444[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018A444[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018A444[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018A46C; + *(u32 *)(prim + 0x24) = D_8018A464; + *(u32 *)(prim + 0x28) = D_8018A470; + *(u32 *)(prim + 0x2c) = D_8018A468; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018A474[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018A474[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018A474[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018A474[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018A4F0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018A4F0[a1 & 0x7F]; +} + + + +extern s32 D_8018A510[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018A510[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018A58C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018A58C[a1 & 0x7F]; +} + + + +extern u8 D_8018A5AC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018A5AC[a1 & 0x7F]; +} + + + +extern u8 D_8018A5CC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018A5CC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018A5EC[])(void); + D_8018A5EC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018A668[])(void); + +void func_80165AC8(void) { + D_8018A668[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018A6E4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018A6E4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801D7AE8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801D7AE8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018A6F0[])(void); + +void func_80166018(void *a0) { + D_8018A6F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018A6F8[])(void); + +void func_801663FC(void *a0) { + D_8018A6F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018A7C0[])(void); + +void func_80166618(void *a0) { + D_8018A7C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018A7D0[])(void); + +void func_80166654(void *a0) { + D_8018A7D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801D84E8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801D84E8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D84E8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801D84E8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801D84E8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801D84E8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801D84E8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018A714[]; + extern u8 D_8018A700[]; + extern u8 D_8018A728[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018A714; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018A700; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018A728; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80167714); + + +extern void (*D_8018A7E0[])(void); + +void func_801678B4(void *a0) { + D_8018A7E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018A7EC[])(void); + +void func_80167A9C(void *a0) { + D_8018A7EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018A8F8; + extern u8 D_8018A90C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018A8F8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018A90C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018A74C[]; +extern u8 D_8018A760[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018A74C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018A760; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018A804[])(void); + +void func_80168744(void *a0) { + D_8018A804[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018A7F4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018A7F4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018A7F4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018A80C[])(void); + +void func_801689D8(void *a0) { + D_8018A80C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018A814[])(void); + +void func_80168AA8(void *a0) { + D_8018A814[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018A81C[])(void); + +void func_80168D58(void *a0) { + D_8018A81C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018A824[])(void); + +void func_8016901C(void *a0) { + D_8018A824[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_029/nonmatchings/ov_SC03_029_jr_8015C32C", func_80169228); + + +extern void (*D_8018A82C[])(void); + +void func_801693CC(void *a0) { + D_8018A82C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018A834[])(void); + +void func_80169830(void *a0) { + D_8018A834[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018A8E8[])(void); + +void func_80169B80(void *a0) { + D_8018A8E8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018A83C[]; + extern u8 D_8018A8AC[]; + extern u8 D_8018A8DC[]; + extern u8 D_801D9900[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018A8DC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018A83C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801D9900; + RotMatrixYXZ(rot, D_801D9900); + func_80048D9C(D_801D9900, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018A8AC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018A8F0[])(void); + +void func_80169F00(void *a0) { + D_8018A8F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018A8A0[]; +extern char D_8018A860[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018A8A0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018A860); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018A928[])(void); + +void func_8016A020(void *a0) { + D_8018A928[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018A8F8; + extern u8 D_8018A90C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018A8F8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018A90C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018A934[])(void); + +void func_8016A700(void *a0) { + D_8018A934[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018A97C[])(void); + +void func_8016AB30(void *a0) { + D_8018A97C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_030/ov_SC03_030_jr_8015AE2C.c b/src/ov_SC03_030/ov_SC03_030_jr_8015AE2C.c index f14ccd6d3..f6ea55804 100644 --- a/src/ov_SC03_030/ov_SC03_030_jr_8015AE2C.c +++ b/src/ov_SC03_030/ov_SC03_030_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80184674[])(void); - -void func_8015C714(void *a0) { - D_80184674[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801844E8[])(void*); - extern int D_8018448C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801844E8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801844E8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018448C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801844E8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801844E8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801844E8[])(void*); - extern int D_8018448C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801844E8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018448C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801844E8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80184684[])(void); - D_80184684[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801844E8[])(struct Ent_8015CD20 *); - extern u8 D_8018449C; - extern u8 D_8018468C; - extern u8 D_8018469C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801844E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018449C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018468C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018469C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801844E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801846BC[])(void); - D_801846BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801846AC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801846AC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801844E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80184718; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80184718, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801837FC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801837FC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80184720[])(void); - D_80184720[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018472C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018472C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018472C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018472C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801844E8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018472C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801844AC[]; - extern u8 D_801844BC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801844AC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801844BC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018472C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018472C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018472C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80184760[])(void); - D_80184760[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801844E8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184768[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80184780[])(void); - D_80184780[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801844E8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184768[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801847A0[])(void); - D_801847A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801844E8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801844E8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801847B0; -extern u16 D_801847B2; -extern u16 D_801847B4; -extern s32 D_801847B8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801847B0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801847B2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801847B4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801847B8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801847C0; - -void func_8015E588(void) { - func_8013C9C4(&D_801847C0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801844E8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801844E8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801847D4[])(void); - D_801847D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801844E8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801844E8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801847DC[])(void); - D_801847DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801844CC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801844CC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801844E8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801847E4[])(void); - D_801847E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801844E8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801844E8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801847EC[])(void); - D_801847EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801844E8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801847F4; - extern s32 D_80184804; - extern s32 D_80184814; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801844E8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801847F4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184804); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801844E8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184814); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184824[])(void); - D_80184824[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801844E8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801844E8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801844E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801844E8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184830[])(void); - D_80184830[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801844E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801844E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801844E8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801844E8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80184844[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80184844[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801844E8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801844E8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801844E8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801844E8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801848C0[])(void); - D_801848C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801844E8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801844E8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801848D0[])(void); - D_801848D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801844E8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801844E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801844E8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801844E8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801844E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801844E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801844E8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801848D8[])(void); - D_801848D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801844E8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801844E8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801844E8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801844E8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801848E4[])(void); - D_801848E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801844E8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801844E8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801844E8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801844E8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801848F4[])(void); - -void func_80160EA4(void *a0) { - D_801848F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801844E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801844E8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80184924[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80184924[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80184988; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80184988); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E0968[]; - extern u8 D_80184954[]; - extern u8 D_80184974[]; - extern u8 D_801E0974[]; - extern u8 D_801E099C[]; - extern u8 D_801E09B4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E0968[0] = p; - func_80024054(&D_80184954, &D_801E0974); - func_8001CE28(p, &D_801E0974); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E0968[1] = p; - func_80024054(&D_80184974, &D_801E099C); - func_8001CE28(p, &D_801E099C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E0968[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E09B4, 0x84); - func_8001CE68(p, &D_801E09B4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E09B4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E0968[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E0968; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80184988; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80184988; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80184988; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80184988; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E0968[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E0968; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801849AC[])(void); - -void func_80162330(void *a0) { - D_801849AC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E09C0[i] via `extern int D_801E09C0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801849B8[]; - extern s32 D_801849D0; - extern u8 D_801E09CC[]; - extern u8 D_801E09F4[]; - extern u8 D_801E0A10[]; - extern int D_801E09C0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E09C0[0] = (s32)item; - func_80024054(D_801849B8, D_801E09CC); - func_8001CE28(item, D_801E09CC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E09C0[1] = (s32)item; - func_80024054(((u8 *)&D_801849D0), D_801E09F4); - func_8001CE28(item, D_801E09F4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E09C0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E0A10, 0x84); - func_8001CE68(item, D_801E0A10); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E0A10, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E09C0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E09C0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_801627E8); - - -extern void (*D_801849F4[])(void); - -void func_80162834(void *a0) { - D_801849F4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801849E4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801849E4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E017C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E017C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E017C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E017C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801849FC[])(void); - -void func_80163A58(void *a0) { - D_801849FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E0184; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E0184; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80184A50[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80184A50[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80184A18; -extern s16 D_80184A4C; -extern s16 D_80184A4A; -extern s16 D_80184A48; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80184A18; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80184A4C = 0x80; - D_80184A4A = 0x80; - D_80184A48 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80184A4C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80184A4C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80184A4C - 8; - D_80184A4C = nv; - D_80184A4A = nv; - D_80184A48 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80184A5C[])(void); - -void func_80164BA0(void *a0) { - D_80184A5C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E0A20; -extern u8 D_801E0A21; -extern u8 D_801E0A22; -extern u8 D_801E0A23; -extern u8 D_801E0A24; -extern u8 D_801E0A25; -extern u8 D_801E0A26; -extern u8 D_801E0A27; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E0A20; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E0A21 = 0xf0; - *(u8 *)base = 0xf0; - D_801E0A22 = 0xc0; - D_801E0A26 = 0; - D_801E0A25 = 0; - D_801E0A24 = 0; - D_801E0A27 = 0; - D_801E0A23 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E0A20; -extern u8 D_801E0A21; -extern u8 D_801E0A22; - -s32 func_80164E40(void) { - u8 *p = &D_801E0A20; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E0A21 != 0) { - D_801E0A21 -= 0x10; - } - if (D_801E0A22 != 0) { - D_801E0A22 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80184A6C[])(void); - -void func_80164EA4(void *a0) { - D_80184A6C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E0A6C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E0A6C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E0A60[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E0A60[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E0A60[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E0A60; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E0A60; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80184A80[]; - extern u32 D_80184AA0, D_80184AA4, D_80184AA8, D_80184AAC; - extern u32 D_80184AA0, D_80184AA4, D_80184AA8, D_80184AAC; - extern u32 D_80184AA0, D_80184AA4, D_80184AA8, D_80184AAC; - extern u32 D_80184AA0, D_80184AA4, D_80184AA8, D_80184AAC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80184A80[0x00], p); - ApplyMatrixSV(mat, &D_80184A80[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80184A80[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80184A80[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80184AA8; - *(u32 *)(prim + 0x24) = D_80184AA0; - *(u32 *)(prim + 0x28) = D_80184AAC; - *(u32 *)(prim + 0x2c) = D_80184AA4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80184AB0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80184AB0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80184AB0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80184AB0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80184B2C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80184B2C[a1 & 0x7F]; -} - - - -extern s32 D_80184B4C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80184B4C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80184BC8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80184BC8[a1 & 0x7F]; -} - - - -extern u8 D_80184BE8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80184BE8[a1 & 0x7F]; -} - - - -extern u8 D_80184C08[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80184C08[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80184C28[])(void); - D_80184C28[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80184CA4[])(void); - -void func_80165AC8(void) { - D_80184CA4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80184D20[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80184D20[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E018C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E018C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80184D2C[])(void); - -void func_80166018(void *a0) { - D_80184D2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80184D34[])(void); - -void func_801663FC(void *a0) { - D_80184D34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80184DFC[])(void); - -void func_80166618(void *a0) { - D_80184DFC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80184E0C[])(void); - -void func_80166654(void *a0) { - D_80184E0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E0AE0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E0AE0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E0AE0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E0AE0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E0AE0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E0AE0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E0AE0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80184D50[]; - extern u8 D_80184D3C[]; - extern u8 D_80184D64[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80184D50; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80184D3C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80184D64; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80167714); - - -extern void (*D_80184E1C[])(void); - -void func_801678B4(void *a0) { - D_80184E1C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80184E28[])(void); - -void func_80167A9C(void *a0) { - D_80184E28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80184F34; - extern u8 D_80184F48[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80184F34); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184F48; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80184D88[]; -extern u8 D_80184D9C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80184D88; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80184D9C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80184E40[])(void); - -void func_80168744(void *a0) { - D_80184E40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80184E30 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80184E30[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80184E30; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80184E48[])(void); - -void func_801689D8(void *a0) { - D_80184E48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80184E50[])(void); - -void func_80168AA8(void *a0) { - D_80184E50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80184E58[])(void); - -void func_80168D58(void *a0) { - D_80184E58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80184E60[])(void); - -void func_8016901C(void *a0) { - D_80184E60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015AE2C", func_80169228); - - -extern void (*D_80184E68[])(void); - -void func_801693CC(void *a0) { - D_80184E68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80184E70[])(void); - -void func_80169830(void *a0) { - D_80184E70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80184F24[])(void); - -void func_80169B80(void *a0) { - D_80184F24[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80184E78[]; - extern u8 D_80184EE8[]; - extern u8 D_80184F18[]; - extern u8 D_801E1AF8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80184F18, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80184E78[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801E1AF8; - RotMatrixYXZ(rot, D_801E1AF8); - func_80048D9C(D_801E1AF8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80184EE8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80184F2C[])(void); - -void func_80169F00(void *a0) { - D_80184F2C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80184EDC[]; -extern char D_80184E9C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80184EDC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80184E9C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80184F64[])(void); - -void func_8016A020(void *a0) { - D_80184F64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80184F34; - extern u8 D_80184F48[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80184F34); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184F48; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80184F70[])(void); - -void func_8016A700(void *a0) { - D_80184F70[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80184FB8[])(void); - -void func_8016AB30(void *a0) { - D_80184FB8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c b/src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c new file mode 100644 index 000000000..0bd43423e --- /dev/null +++ b/src/ov_SC03_030/ov_SC03_030_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80184384; +extern u8 D_801842F4; +extern u8 D_801842D0; +extern u8 D_801842AC; +extern u8 D_80184360; +extern u8 D_8018433C; +extern u8 D_80184318; +extern u8 D_80184288; +extern void func_80145934(void); +extern u8 D_80184414; +extern u8 D_801843F0; +extern u8 D_801843CC; +extern u8 D_801843A8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018380C[]; +extern unsigned char D_8018383C[]; +extern unsigned char D_8018388C[]; +extern unsigned char D_801838BC[]; +extern unsigned char D_801838EC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018393C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80183A04[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80183A8C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80183A94; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E0910; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E0914; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80183AC4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80183B6C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80183B90[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80183B80; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80183BA4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80183BB0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80183BC0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80183BD8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80183BC8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80183BEC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80183C08[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80183BF8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80183C1C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80183C30[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80183C44; +extern void (*D_80183C6C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80183C4C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80183CB8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80183CBC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184120[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184130[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E0948; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80184158[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80184138; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80184148; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80184198[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801841A0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018416C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801841AC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018417C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E0950; +extern s32 D_801E095C; +extern s32 D_801E0960; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801841E8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801841BC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E0958; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184438[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80184258[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801844DC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80184630[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018444C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80184638[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018445C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018447C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80184640[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80184668[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801844E8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80184674[])(void); + +void func_8015C714(void *a0) { + D_80184674[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801844E8[])(void*); + extern int D_8018448C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801844E8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801844E8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018448C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801844E8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801844E8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801844E8[])(void*); + extern int D_8018448C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801844E8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018448C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801844E8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80184684[])(void); + D_80184684[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801844E8[])(struct Ent_8015CD20 *); + extern u8 D_8018449C; + extern u8 D_8018468C; + extern u8 D_8018469C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801844E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018449C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018468C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018469C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801844E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801846BC[])(void); + D_801846BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801846AC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801846AC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801844E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80184718; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80184718, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801837FC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801837FC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80184720[])(void); + D_80184720[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018472C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018472C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018472C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018472C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801844E8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018472C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801844AC[]; + extern u8 D_801844BC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801844AC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801844BC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018472C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018472C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018472C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80184760[])(void); + D_80184760[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801844E8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184768[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80184780[])(void); + D_80184780[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801844E8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184768[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184768[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801847A0[])(void); + D_801847A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801844E8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801844E8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801847B0; +extern u16 D_801847B2; +extern u16 D_801847B4; +extern s32 D_801847B8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801847B0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801847B2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801847B4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801847B8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801847C0; + +void func_8015E588(void) { + func_8013C9C4(&D_801847C0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801844E8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801844E8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801847D4[])(void); + D_801847D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801844E8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801844E8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801847DC[])(void); + D_801847DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801844CC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801844CC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801844E8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801847E4[])(void); + D_801847E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801844E8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801844E8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801847EC[])(void); + D_801847EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801844E8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801847F4; + extern s32 D_80184804; + extern s32 D_80184814; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801847F4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184804); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801844E8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184814); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184824[])(void); + D_80184824[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801844E8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801844E8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801844E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801844E8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184830[])(void); + D_80184830[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801844E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801844E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801844E8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801844E8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80184844[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80184844[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801844E8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801844E8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801844E8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801844E8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801848C0[])(void); + D_801848C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801844E8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801844E8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801848D0[])(void); + D_801848D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801844E8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801844E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801844E8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801844E8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801844E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801844E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801844E8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801848D8[])(void); + D_801848D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801844E8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801844E8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801844E8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801844E8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801848E4[])(void); + D_801848E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801844E8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801844E8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801844E8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801844E8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801848F4[])(void); + +void func_80160EA4(void *a0) { + D_801848F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801844E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801844E8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80184924[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80184924[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80184988; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80184988); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E0968[]; + extern u8 D_80184954[]; + extern u8 D_80184974[]; + extern u8 D_801E0974[]; + extern u8 D_801E099C[]; + extern u8 D_801E09B4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E0968[0] = p; + func_80024054(&D_80184954, &D_801E0974); + func_8001CE28(p, &D_801E0974); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E0968[1] = p; + func_80024054(&D_80184974, &D_801E099C); + func_8001CE28(p, &D_801E099C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E0968[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E09B4, 0x84); + func_8001CE68(p, &D_801E09B4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E09B4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E0968[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E0968; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80184988; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80184988; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80184988; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80184988; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E0968[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E0968; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801849AC[])(void); + +void func_80162330(void *a0) { + D_801849AC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E09C0[i] via `extern int D_801E09C0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801849B8[]; + extern s32 D_801849D0; + extern u8 D_801E09CC[]; + extern u8 D_801E09F4[]; + extern u8 D_801E0A10[]; + extern int D_801E09C0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E09C0[0] = (s32)item; + func_80024054(D_801849B8, D_801E09CC); + func_8001CE28(item, D_801E09CC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E09C0[1] = (s32)item; + func_80024054(((u8 *)&D_801849D0), D_801E09F4); + func_8001CE28(item, D_801E09F4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E09C0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E0A10, 0x84); + func_8001CE68(item, D_801E0A10); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E0A10, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E09C0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E09C0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_801627E8); + + +extern void (*D_801849F4[])(void); + +void func_80162834(void *a0) { + D_801849F4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801849E4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801849E4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E017C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E017C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E017C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E017C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801849FC[])(void); + +void func_80163A58(void *a0) { + D_801849FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E0184; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E0184; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80184A50[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80184A50[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80184A18; +extern s16 D_80184A4C; +extern s16 D_80184A4A; +extern s16 D_80184A48; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80184A18; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80184A4C = 0x80; + D_80184A4A = 0x80; + D_80184A48 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80184A4C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80184A4C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80184A4C - 8; + D_80184A4C = nv; + D_80184A4A = nv; + D_80184A48 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80184A5C[])(void); + +void func_80164BA0(void *a0) { + D_80184A5C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E0A20; +extern u8 D_801E0A21; +extern u8 D_801E0A22; +extern u8 D_801E0A23; +extern u8 D_801E0A24; +extern u8 D_801E0A25; +extern u8 D_801E0A26; +extern u8 D_801E0A27; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E0A20; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E0A21 = 0xf0; + *(u8 *)base = 0xf0; + D_801E0A22 = 0xc0; + D_801E0A26 = 0; + D_801E0A25 = 0; + D_801E0A24 = 0; + D_801E0A27 = 0; + D_801E0A23 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E0A20; +extern u8 D_801E0A21; +extern u8 D_801E0A22; + +s32 func_80164E40(void) { + u8 *p = &D_801E0A20; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E0A21 != 0) { + D_801E0A21 -= 0x10; + } + if (D_801E0A22 != 0) { + D_801E0A22 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80184A6C[])(void); + +void func_80164EA4(void *a0) { + D_80184A6C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E0A6C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E0A6C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E0A60[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E0A60[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E0A60[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E0A60; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E0A60; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80184A80[]; + extern u32 D_80184AA0, D_80184AA4, D_80184AA8, D_80184AAC; + extern u32 D_80184AA0, D_80184AA4, D_80184AA8, D_80184AAC; + extern u32 D_80184AA0, D_80184AA4, D_80184AA8, D_80184AAC; + extern u32 D_80184AA0, D_80184AA4, D_80184AA8, D_80184AAC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80184A80[0x00], p); + ApplyMatrixSV(mat, &D_80184A80[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80184A80[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80184A80[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80184AA8; + *(u32 *)(prim + 0x24) = D_80184AA0; + *(u32 *)(prim + 0x28) = D_80184AAC; + *(u32 *)(prim + 0x2c) = D_80184AA4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80184AB0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80184AB0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80184AB0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80184AB0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80184B2C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80184B2C[a1 & 0x7F]; +} + + + +extern s32 D_80184B4C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80184B4C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80184BC8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80184BC8[a1 & 0x7F]; +} + + + +extern u8 D_80184BE8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80184BE8[a1 & 0x7F]; +} + + + +extern u8 D_80184C08[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80184C08[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80184C28[])(void); + D_80184C28[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80184CA4[])(void); + +void func_80165AC8(void) { + D_80184CA4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80184D20[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80184D20[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E018C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E018C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80184D2C[])(void); + +void func_80166018(void *a0) { + D_80184D2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80184D34[])(void); + +void func_801663FC(void *a0) { + D_80184D34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80184DFC[])(void); + +void func_80166618(void *a0) { + D_80184DFC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80184E0C[])(void); + +void func_80166654(void *a0) { + D_80184E0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E0AE0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E0AE0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E0AE0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E0AE0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E0AE0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E0AE0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E0AE0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80184D50[]; + extern u8 D_80184D3C[]; + extern u8 D_80184D64[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80184D50; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80184D3C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80184D64; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80167714); + + +extern void (*D_80184E1C[])(void); + +void func_801678B4(void *a0) { + D_80184E1C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80184E28[])(void); + +void func_80167A9C(void *a0) { + D_80184E28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80184F34; + extern u8 D_80184F48[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80184F34); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184F48; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80184D88[]; +extern u8 D_80184D9C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80184D88; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80184D9C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80184E40[])(void); + +void func_80168744(void *a0) { + D_80184E40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80184E30 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80184E30[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80184E30; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80184E48[])(void); + +void func_801689D8(void *a0) { + D_80184E48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80184E50[])(void); + +void func_80168AA8(void *a0) { + D_80184E50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80184E58[])(void); + +void func_80168D58(void *a0) { + D_80184E58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80184E60[])(void); + +void func_8016901C(void *a0) { + D_80184E60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_030/nonmatchings/ov_SC03_030_jr_8015C32C", func_80169228); + + +extern void (*D_80184E68[])(void); + +void func_801693CC(void *a0) { + D_80184E68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80184E70[])(void); + +void func_80169830(void *a0) { + D_80184E70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80184F24[])(void); + +void func_80169B80(void *a0) { + D_80184F24[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80184E78[]; + extern u8 D_80184EE8[]; + extern u8 D_80184F18[]; + extern u8 D_801E1AF8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80184F18, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80184E78[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801E1AF8; + RotMatrixYXZ(rot, D_801E1AF8); + func_80048D9C(D_801E1AF8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80184EE8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80184F2C[])(void); + +void func_80169F00(void *a0) { + D_80184F2C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80184EDC[]; +extern char D_80184E9C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80184EDC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80184E9C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80184F64[])(void); + +void func_8016A020(void *a0) { + D_80184F64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80184F34; + extern u8 D_80184F48[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80184F34); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184F48; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80184F70[])(void); + +void func_8016A700(void *a0) { + D_80184F70[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80184FB8[])(void); + +void func_8016AB30(void *a0) { + D_80184FB8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_031/ov_SC03_031_jr_8015AE2C.c b/src/ov_SC03_031/ov_SC03_031_jr_8015AE2C.c index a222c8be3..fb8e29c7e 100644 --- a/src/ov_SC03_031/ov_SC03_031_jr_8015AE2C.c +++ b/src/ov_SC03_031/ov_SC03_031_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80184B90[])(void); - -void func_8015C714(void *a0) { - D_80184B90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80184A04[])(void*); - extern int D_801849A8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80184A04)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80184A04)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801849A8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80184A04[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80184A04[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80184A04[])(void*); - extern int D_801849A8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80184A04)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801849A8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80184A04)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80184BA0[])(void); - D_80184BA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80184A04[])(struct Ent_8015CD20 *); - extern u8 D_801849B8; - extern u8 D_80184BA8; - extern u8 D_80184BB8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80184A04[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849B8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184BA8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184BB8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80184A04[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80184BD8[])(void); - D_80184BD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80184BC8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80184BC8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80184A04[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80184C34; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80184C34, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80183D18[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80183D18; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80184C3C[])(void); - D_80184C3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80184C48[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80184C48[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80184C48[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80184C48[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80184A04[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80184C48[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801849C8[]; - extern u8 D_801849D8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801849C8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801849D8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80184C48[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184C48[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184C48[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80184C7C[])(void); - D_80184C7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184A04[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184C84[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80184C9C[])(void); - D_80184C9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184A04[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184C84[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80184CBC[])(void); - D_80184CBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80184A04[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184A04)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80184CCC; -extern u16 D_80184CCE; -extern u16 D_80184CD0; -extern s32 D_80184CD4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80184CCC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80184CCE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80184CD0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184CD4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80184CDC; - -void func_8015E588(void) { - func_8013C9C4(&D_80184CDC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80184A04[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184A04)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80184CF0[])(void); - D_80184CF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80184A04[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80184A04[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80184CF8[])(void); - D_80184CF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801849E8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801849E8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80184A04[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80184D00[])(void); - D_80184D00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80184A04[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80184A04[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80184D08[])(void); - D_80184D08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80184A04[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80184D10; - extern s32 D_80184D20; - extern s32 D_80184D30; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80184A04[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184D10); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184D20); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80184A04[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184D30); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184D40[])(void); - D_80184D40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80184A04[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80184A04[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80184A04[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184A04[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184D4C[])(void); - D_80184D4C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80184A04[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184A04[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80184A04[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184A04[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80184D60[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80184D60[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80184A04[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80184A04)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80184A04[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184A04[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80184DDC[])(void); - D_80184DDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80184A04[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80184A04)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80184DEC[])(void); - D_80184DEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80184A04[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80184A04[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80184A04[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80184A04[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80184A04[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80184A04[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80184A04[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80184DF4[])(void); - D_80184DF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80184A04[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80184A04)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80184A04[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80184A04)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80184E00[])(void); - D_80184E00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184A04 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80184A04[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80184A04[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80184A04[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80184E10[])(void); - -void func_80160EA4(void *a0) { - D_80184E10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80184A04[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80184A04[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80184E40[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80184E40[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80184EA4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80184EA4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C4D68[]; - extern u8 D_80184E70[]; - extern u8 D_80184E90[]; - extern u8 D_801C4D74[]; - extern u8 D_801C4D9C[]; - extern u8 D_801C4DB4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C4D68[0] = p; - func_80024054(&D_80184E70, &D_801C4D74); - func_8001CE28(p, &D_801C4D74); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C4D68[1] = p; - func_80024054(&D_80184E90, &D_801C4D9C); - func_8001CE28(p, &D_801C4D9C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C4D68[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C4DB4, 0x84); - func_8001CE68(p, &D_801C4DB4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C4DB4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C4D68[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C4D68; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80184EA4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80184EA4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80184EA4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80184EA4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C4D68[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C4D68; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80184EC8[])(void); - -void func_80162330(void *a0) { - D_80184EC8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C4DC0[i] via `extern int D_801C4DC0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80184ED4[]; - extern s32 D_80184EEC; - extern u8 D_801C4DCC[]; - extern u8 D_801C4DF4[]; - extern u8 D_801C4E10[]; - extern int D_801C4DC0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C4DC0[0] = (s32)item; - func_80024054(D_80184ED4, D_801C4DCC); - func_8001CE28(item, D_801C4DCC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C4DC0[1] = (s32)item; - func_80024054(((u8 *)&D_80184EEC), D_801C4DF4); - func_8001CE28(item, D_801C4DF4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C4DC0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C4E10, 0x84); - func_8001CE68(item, D_801C4E10); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C4E10, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C4DC0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C4DC0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_801627E8); - - -extern void (*D_80184F10[])(void); - -void func_80162834(void *a0) { - D_80184F10[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80184F00; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80184F00, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C4620[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C4620, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C4620[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C4620, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80184F18[])(void); - -void func_80163A58(void *a0) { - D_80184F18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C4628; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C4628; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80184F6C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80184F6C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80184F34; -extern s16 D_80184F68; -extern s16 D_80184F66; -extern s16 D_80184F64; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80184F34; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80184F68 = 0x80; - D_80184F66 = 0x80; - D_80184F64 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80184F68 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80184F68` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80184F68 - 8; - D_80184F68 = nv; - D_80184F66 = nv; - D_80184F64 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80184F78[])(void); - -void func_80164BA0(void *a0) { - D_80184F78[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C4E20; -extern u8 D_801C4E21; -extern u8 D_801C4E22; -extern u8 D_801C4E23; -extern u8 D_801C4E24; -extern u8 D_801C4E25; -extern u8 D_801C4E26; -extern u8 D_801C4E27; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C4E20; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C4E21 = 0xf0; - *(u8 *)base = 0xf0; - D_801C4E22 = 0xc0; - D_801C4E26 = 0; - D_801C4E25 = 0; - D_801C4E24 = 0; - D_801C4E27 = 0; - D_801C4E23 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C4E20; -extern u8 D_801C4E21; -extern u8 D_801C4E22; - -s32 func_80164E40(void) { - u8 *p = &D_801C4E20; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C4E21 != 0) { - D_801C4E21 -= 0x10; - } - if (D_801C4E22 != 0) { - D_801C4E22 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80184F88[])(void); - -void func_80164EA4(void *a0) { - D_80184F88[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C4E6C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C4E6C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C4E60[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C4E60[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C4E60[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C4E60; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C4E60; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80184F9C[]; - extern u32 D_80184FBC, D_80184FC0, D_80184FC4, D_80184FC8; - extern u32 D_80184FBC, D_80184FC0, D_80184FC4, D_80184FC8; - extern u32 D_80184FBC, D_80184FC0, D_80184FC4, D_80184FC8; - extern u32 D_80184FBC, D_80184FC0, D_80184FC4, D_80184FC8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80184F9C[0x00], p); - ApplyMatrixSV(mat, &D_80184F9C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80184F9C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80184F9C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80184FC4; - *(u32 *)(prim + 0x24) = D_80184FBC; - *(u32 *)(prim + 0x28) = D_80184FC8; - *(u32 *)(prim + 0x2c) = D_80184FC0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80184FCC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80184FCC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80184FCC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80184FCC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80185048[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80185048[a1 & 0x7F]; -} - - - -extern s32 D_80185068[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80185068[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801850E4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801850E4[a1 & 0x7F]; -} - - - -extern u8 D_80185104[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80185104[a1 & 0x7F]; -} - - - -extern u8 D_80185124[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80185124[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80185144[])(void); - D_80185144[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801851C0[])(void); - -void func_80165AC8(void) { - D_801851C0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018523C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018523C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C4630; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C4630, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80185248[])(void); - -void func_80166018(void *a0) { - D_80185248[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80185250[])(void); - -void func_801663FC(void *a0) { - D_80185250[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80185318[])(void); - -void func_80166618(void *a0) { - D_80185318[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80185328[])(void); - -void func_80166654(void *a0) { - D_80185328[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C4EE0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C4EE0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C4EE0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C4EE0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C4EE0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C4EE0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C4EE0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018526C[]; - extern u8 D_80185258[]; - extern u8 D_80185280[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018526C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80185258; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80185280; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80167714); - - -extern void (*D_80185338[])(void); - -void func_801678B4(void *a0) { - D_80185338[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80185344[])(void); - -void func_80167A9C(void *a0) { - D_80185344[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80185450; - extern u8 D_80185464[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80185450); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185464; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801852A4[]; -extern u8 D_801852B8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801852A4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801852B8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018535C[])(void); - -void func_80168744(void *a0) { - D_8018535C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018534C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018534C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018534C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80185364[])(void); - -void func_801689D8(void *a0) { - D_80185364[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018536C[])(void); - -void func_80168AA8(void *a0) { - D_8018536C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80185374[])(void); - -void func_80168D58(void *a0) { - D_80185374[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018537C[])(void); - -void func_8016901C(void *a0) { - D_8018537C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015AE2C", func_80169228); - - -extern void (*D_80185384[])(void); - -void func_801693CC(void *a0) { - D_80185384[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018538C[])(void); - -void func_80169830(void *a0) { - D_8018538C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80185440[])(void); - -void func_80169B80(void *a0) { - D_80185440[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80185394[]; - extern u8 D_80185404[]; - extern u8 D_80185434[]; - extern u8 D_801C6160[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80185434, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80185394[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C6160; - RotMatrixYXZ(rot, D_801C6160); - func_80048D9C(D_801C6160, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80185404); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80185448[])(void); - -void func_80169F00(void *a0) { - D_80185448[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801853F8[]; -extern char D_801853B8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801853F8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801853B8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80185480[])(void); - -void func_8016A020(void *a0) { - D_80185480[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80185450; - extern u8 D_80185464[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80185450); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185464; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018548C[])(void); - -void func_8016A700(void *a0) { - D_8018548C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801854D4[])(void); - -void func_8016AB30(void *a0) { - D_801854D4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c b/src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c new file mode 100644 index 000000000..cbd535a3a --- /dev/null +++ b/src/ov_SC03_031/ov_SC03_031_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801848A0; +extern u8 D_80184810; +extern u8 D_801847EC; +extern u8 D_801847C8; +extern u8 D_8018487C; +extern u8 D_80184858; +extern u8 D_80184834; +extern u8 D_801847A4; +extern void func_80145934(void); +extern u8 D_80184930; +extern u8 D_8018490C; +extern u8 D_801848E8; +extern u8 D_801848C4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80183D28[]; +extern unsigned char D_80183D58[]; +extern unsigned char D_80183DA8[]; +extern unsigned char D_80183DD8[]; +extern unsigned char D_80183E08[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80183E58[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80183F20[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80183FA8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80183FB0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C4D10; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C4D14; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80183FE0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80184088[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801840AC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018409C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801840C0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801840CC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801840DC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801840F4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801840E4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80184108[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80184124[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80184114; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80184138[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018414C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80184160; +extern void (*D_80184188[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80184168; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801841D4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801841D8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018463C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018464C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C4D48; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80184674[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80184654; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80184664; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801846B4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801846BC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80184688; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801846C8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80184698; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C4D50; +extern s32 D_801C4D5C; +extern s32 D_801C4D60; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80184704[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801846D8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C4D58; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184954[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80184774[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801849F8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80184B4C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80184968; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80184B54[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80184978; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80184998; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80184B5C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80184B84[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80184A04[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80184B90[])(void); + +void func_8015C714(void *a0) { + D_80184B90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80184A04[])(void*); + extern int D_801849A8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80184A04)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80184A04)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801849A8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80184A04[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80184A04[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80184A04[])(void*); + extern int D_801849A8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80184A04)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801849A8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80184A04)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80184BA0[])(void); + D_80184BA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80184A04[])(struct Ent_8015CD20 *); + extern u8 D_801849B8; + extern u8 D_80184BA8; + extern u8 D_80184BB8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80184A04[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849B8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184BA8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184BB8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80184A04[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80184BD8[])(void); + D_80184BD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80184BC8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80184BC8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80184A04[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80184C34; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80184C34, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80183D18[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80183D18; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80184C3C[])(void); + D_80184C3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80184C48[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80184C48[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80184C48[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80184C48[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80184A04[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80184C48[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801849C8[]; + extern u8 D_801849D8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801849C8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801849D8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80184C48[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184C48[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184C48[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80184C7C[])(void); + D_80184C7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184A04[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184C84[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80184C9C[])(void); + D_80184C9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184A04[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184C84[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184C84[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80184CBC[])(void); + D_80184CBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80184A04[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184A04)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80184CCC; +extern u16 D_80184CCE; +extern u16 D_80184CD0; +extern s32 D_80184CD4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80184CCC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80184CCE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80184CD0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184CD4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80184CDC; + +void func_8015E588(void) { + func_8013C9C4(&D_80184CDC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80184A04[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184A04)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80184CF0[])(void); + D_80184CF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80184A04[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80184A04[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80184CF8[])(void); + D_80184CF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801849E8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801849E8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80184A04[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80184D00[])(void); + D_80184D00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80184A04[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80184A04[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80184D08[])(void); + D_80184D08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80184A04[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80184D10; + extern s32 D_80184D20; + extern s32 D_80184D30; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184D10); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184D20); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80184A04[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184D30); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184D40[])(void); + D_80184D40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80184A04[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80184A04[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80184A04[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184A04[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184D4C[])(void); + D_80184D4C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80184A04[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184A04[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80184A04[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184A04[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80184D60[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80184D60[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80184A04[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80184A04)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80184A04[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184A04[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80184DDC[])(void); + D_80184DDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80184A04[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80184A04)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80184DEC[])(void); + D_80184DEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80184A04[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80184A04[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80184A04[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80184A04[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80184A04[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80184A04[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80184A04[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80184DF4[])(void); + D_80184DF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80184A04[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80184A04)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80184A04[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80184A04)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80184E00[])(void); + D_80184E00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184A04 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80184A04[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80184A04[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80184A04[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80184E10[])(void); + +void func_80160EA4(void *a0) { + D_80184E10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80184A04[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80184A04[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80184E40[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80184E40[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80184EA4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80184EA4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C4D68[]; + extern u8 D_80184E70[]; + extern u8 D_80184E90[]; + extern u8 D_801C4D74[]; + extern u8 D_801C4D9C[]; + extern u8 D_801C4DB4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C4D68[0] = p; + func_80024054(&D_80184E70, &D_801C4D74); + func_8001CE28(p, &D_801C4D74); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C4D68[1] = p; + func_80024054(&D_80184E90, &D_801C4D9C); + func_8001CE28(p, &D_801C4D9C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C4D68[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C4DB4, 0x84); + func_8001CE68(p, &D_801C4DB4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C4DB4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C4D68[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C4D68; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80184EA4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80184EA4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80184EA4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80184EA4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C4D68[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C4D68; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80184EC8[])(void); + +void func_80162330(void *a0) { + D_80184EC8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C4DC0[i] via `extern int D_801C4DC0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80184ED4[]; + extern s32 D_80184EEC; + extern u8 D_801C4DCC[]; + extern u8 D_801C4DF4[]; + extern u8 D_801C4E10[]; + extern int D_801C4DC0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C4DC0[0] = (s32)item; + func_80024054(D_80184ED4, D_801C4DCC); + func_8001CE28(item, D_801C4DCC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C4DC0[1] = (s32)item; + func_80024054(((u8 *)&D_80184EEC), D_801C4DF4); + func_8001CE28(item, D_801C4DF4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C4DC0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C4E10, 0x84); + func_8001CE68(item, D_801C4E10); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C4E10, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C4DC0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C4DC0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_801627E8); + + +extern void (*D_80184F10[])(void); + +void func_80162834(void *a0) { + D_80184F10[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80184F00; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80184F00, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C4620[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C4620, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C4620[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C4620, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80184F18[])(void); + +void func_80163A58(void *a0) { + D_80184F18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C4628; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C4628; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80184F6C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80184F6C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80184F34; +extern s16 D_80184F68; +extern s16 D_80184F66; +extern s16 D_80184F64; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80184F34; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80184F68 = 0x80; + D_80184F66 = 0x80; + D_80184F64 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80184F68 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80184F68` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80184F68 - 8; + D_80184F68 = nv; + D_80184F66 = nv; + D_80184F64 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80184F78[])(void); + +void func_80164BA0(void *a0) { + D_80184F78[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C4E20; +extern u8 D_801C4E21; +extern u8 D_801C4E22; +extern u8 D_801C4E23; +extern u8 D_801C4E24; +extern u8 D_801C4E25; +extern u8 D_801C4E26; +extern u8 D_801C4E27; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C4E20; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C4E21 = 0xf0; + *(u8 *)base = 0xf0; + D_801C4E22 = 0xc0; + D_801C4E26 = 0; + D_801C4E25 = 0; + D_801C4E24 = 0; + D_801C4E27 = 0; + D_801C4E23 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C4E20; +extern u8 D_801C4E21; +extern u8 D_801C4E22; + +s32 func_80164E40(void) { + u8 *p = &D_801C4E20; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C4E21 != 0) { + D_801C4E21 -= 0x10; + } + if (D_801C4E22 != 0) { + D_801C4E22 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80184F88[])(void); + +void func_80164EA4(void *a0) { + D_80184F88[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C4E6C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C4E6C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C4E60[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C4E60[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C4E60[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C4E60; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C4E60; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80184F9C[]; + extern u32 D_80184FBC, D_80184FC0, D_80184FC4, D_80184FC8; + extern u32 D_80184FBC, D_80184FC0, D_80184FC4, D_80184FC8; + extern u32 D_80184FBC, D_80184FC0, D_80184FC4, D_80184FC8; + extern u32 D_80184FBC, D_80184FC0, D_80184FC4, D_80184FC8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80184F9C[0x00], p); + ApplyMatrixSV(mat, &D_80184F9C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80184F9C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80184F9C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80184FC4; + *(u32 *)(prim + 0x24) = D_80184FBC; + *(u32 *)(prim + 0x28) = D_80184FC8; + *(u32 *)(prim + 0x2c) = D_80184FC0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80184FCC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80184FCC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80184FCC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80184FCC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80185048[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80185048[a1 & 0x7F]; +} + + + +extern s32 D_80185068[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80185068[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801850E4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801850E4[a1 & 0x7F]; +} + + + +extern u8 D_80185104[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80185104[a1 & 0x7F]; +} + + + +extern u8 D_80185124[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80185124[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80185144[])(void); + D_80185144[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801851C0[])(void); + +void func_80165AC8(void) { + D_801851C0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018523C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018523C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C4630; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C4630, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80185248[])(void); + +void func_80166018(void *a0) { + D_80185248[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80185250[])(void); + +void func_801663FC(void *a0) { + D_80185250[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80185318[])(void); + +void func_80166618(void *a0) { + D_80185318[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80185328[])(void); + +void func_80166654(void *a0) { + D_80185328[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C4EE0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C4EE0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C4EE0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C4EE0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C4EE0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C4EE0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C4EE0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018526C[]; + extern u8 D_80185258[]; + extern u8 D_80185280[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018526C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80185258; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80185280; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80167714); + + +extern void (*D_80185338[])(void); + +void func_801678B4(void *a0) { + D_80185338[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80185344[])(void); + +void func_80167A9C(void *a0) { + D_80185344[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80185450; + extern u8 D_80185464[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80185450); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185464; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801852A4[]; +extern u8 D_801852B8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801852A4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801852B8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018535C[])(void); + +void func_80168744(void *a0) { + D_8018535C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018534C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018534C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018534C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80185364[])(void); + +void func_801689D8(void *a0) { + D_80185364[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018536C[])(void); + +void func_80168AA8(void *a0) { + D_8018536C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80185374[])(void); + +void func_80168D58(void *a0) { + D_80185374[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018537C[])(void); + +void func_8016901C(void *a0) { + D_8018537C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_031/nonmatchings/ov_SC03_031_jr_8015C32C", func_80169228); + + +extern void (*D_80185384[])(void); + +void func_801693CC(void *a0) { + D_80185384[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018538C[])(void); + +void func_80169830(void *a0) { + D_8018538C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80185440[])(void); + +void func_80169B80(void *a0) { + D_80185440[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80185394[]; + extern u8 D_80185404[]; + extern u8 D_80185434[]; + extern u8 D_801C6160[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80185434, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80185394[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C6160; + RotMatrixYXZ(rot, D_801C6160); + func_80048D9C(D_801C6160, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80185404); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80185448[])(void); + +void func_80169F00(void *a0) { + D_80185448[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801853F8[]; +extern char D_801853B8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801853F8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801853B8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80185480[])(void); + +void func_8016A020(void *a0) { + D_80185480[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80185450; + extern u8 D_80185464[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80185450); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185464; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018548C[])(void); + +void func_8016A700(void *a0) { + D_8018548C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801854D4[])(void); + +void func_8016AB30(void *a0) { + D_801854D4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_089/ov_SC03_089_jr_8015AE2C.c b/src/ov_SC03_089/ov_SC03_089_jr_8015AE2C.c index 991280e94..d7bcf17ca 100644 --- a/src/ov_SC03_089/ov_SC03_089_jr_8015AE2C.c +++ b/src/ov_SC03_089/ov_SC03_089_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018BE8C[])(void); - -void func_8015C714(void *a0) { - D_8018BE8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018BD00[])(void*); - extern int D_8018BCA4; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018BD00)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018BD00)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BCA4); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018BD00[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018BD00[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018BD00[])(void*); - extern int D_8018BCA4; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018BD00)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BCA4); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018BD00)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018BE9C[])(void); - D_8018BE9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018BD00[])(struct Ent_8015CD20 *); - extern u8 D_8018BCB4; - extern u8 D_8018BEA4; - extern u8 D_8018BEB4; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018BD00[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BCB4); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BEA4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BEB4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018BD00[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018BED4[])(void); - D_8018BED4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018BEC4; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018BEC4 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018BD00[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018BF30; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018BF30, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018B014[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018B014; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018BF38[])(void); - D_8018BF38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018BF44[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018BF44[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018BF44[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018BF44[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018BD00[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018BF44[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018BCC4[]; - extern u8 D_8018BCD4[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BCC4); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BCD4); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018BF44[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018BF44[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018BF44[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018BF78[])(void); - D_8018BF78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018BD00[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018BF80[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018BF98[])(void); - D_8018BF98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018BD00[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018BF80[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018BFB8[])(void); - D_8018BFB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018BD00[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018BD00)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018BFC8; -extern u16 D_8018BFCA; -extern u16 D_8018BFCC; -extern s32 D_8018BFD0; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018BFC8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018BFCA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018BFCC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018BFD0, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018BFD8; - -void func_8015E588(void) { - func_8013C9C4(&D_8018BFD8); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018BD00[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018BD00)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018BFEC[])(void); - D_8018BFEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018BD00[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018BD00[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018BFF4[])(void); - D_8018BFF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018BCE4; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018BCE4); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018BD00[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018BFFC[])(void); - D_8018BFFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018BD00[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018BD00[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018C004[])(void); - D_8018C004[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018BD00[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018C00C; - extern s32 D_8018C01C; - extern s32 D_8018C02C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018BD00[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C00C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C01C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018BD00[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C02C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018C03C[])(void); - D_8018C03C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018BD00[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018BD00[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018BD00[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018BD00[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018C048[])(void); - D_8018C048[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018BD00[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018BD00[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018BD00[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018BD00[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018C05C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018C05C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018BD00[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018BD00)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018BD00[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018BD00[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018C0D8[])(void); - D_8018C0D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018BD00[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018BD00)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018C0E8[])(void); - D_8018C0E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018BD00[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018BD00[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018BD00[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018BD00[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018BD00[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018BD00[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018BD00[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018C0F0[])(void); - D_8018C0F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018BD00[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018BD00)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018BD00[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018BD00)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018C0FC[])(void); - D_8018C0FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018BD00 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018BD00[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018BD00[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018BD00[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018C10C[])(void); - -void func_80160EA4(void *a0) { - D_8018C10C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018BD00[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018BD00[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018C13C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018C13C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018C1A0; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018C1A0); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C5620[]; - extern u8 D_8018C16C[]; - extern u8 D_8018C18C[]; - extern u8 D_801C562C[]; - extern u8 D_801C5654[]; - extern u8 D_801C566C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C5620[0] = p; - func_80024054(&D_8018C16C, &D_801C562C); - func_8001CE28(p, &D_801C562C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C5620[1] = p; - func_80024054(&D_8018C18C, &D_801C5654); - func_8001CE28(p, &D_801C5654); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C5620[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C566C, 0x84); - func_8001CE68(p, &D_801C566C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C566C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C5620[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C5620; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018C1A0; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018C1A0; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018C1A0; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018C1A0; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C5620[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C5620; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018C1C4[])(void); - -void func_80162330(void *a0) { - D_8018C1C4[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C5678[i] via `extern int D_801C5678[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018C1D0[]; - extern s32 D_8018C1E8; - extern u8 D_801C5684[]; - extern u8 D_801C56AC[]; - extern u8 D_801C56C8[]; - extern int D_801C5678[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C5678[0] = (s32)item; - func_80024054(D_8018C1D0, D_801C5684); - func_8001CE28(item, D_801C5684); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C5678[1] = (s32)item; - func_80024054(((u8 *)&D_8018C1E8), D_801C56AC); - func_8001CE28(item, D_801C56AC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C5678[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C56C8, 0x84); - func_8001CE68(item, D_801C56C8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C56C8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C5678[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C5678; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018C20C[])(void); - -void func_80162834(void *a0) { - D_8018C20C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018C1FC; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018C1FC, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C4E8C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C4E8C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C4E8C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C4E8C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018C214[])(void); - -void func_80163A58(void *a0) { - D_8018C214[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C4E94; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C4E94; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018C268[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018C268[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018C230; -extern s16 D_8018C264; -extern s16 D_8018C262; -extern s16 D_8018C260; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018C230; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018C264 = 0x80; - D_8018C262 = 0x80; - D_8018C260 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018C264 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018C264` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018C264 - 8; - D_8018C264 = nv; - D_8018C262 = nv; - D_8018C260 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018C274[])(void); - -void func_80164BA0(void *a0) { - D_8018C274[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C56D8; -extern u8 D_801C56D9; -extern u8 D_801C56DA; -extern u8 D_801C56DB; -extern u8 D_801C56DC; -extern u8 D_801C56DD; -extern u8 D_801C56DE; -extern u8 D_801C56DF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C56D8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C56D9 = 0xf0; - *(u8 *)base = 0xf0; - D_801C56DA = 0xc0; - D_801C56DE = 0; - D_801C56DD = 0; - D_801C56DC = 0; - D_801C56DF = 0; - D_801C56DB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C56D8; -extern u8 D_801C56D9; -extern u8 D_801C56DA; - -s32 func_80164E40(void) { - u8 *p = &D_801C56D8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C56D9 != 0) { - D_801C56D9 -= 0x10; - } - if (D_801C56DA != 0) { - D_801C56DA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018C284[])(void); - -void func_80164EA4(void *a0) { - D_8018C284[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C5724[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C5724[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C5718[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C5718[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C5718[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C5718; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C5718; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018C298[]; - extern u32 D_8018C2B8, D_8018C2BC, D_8018C2C0, D_8018C2C4; - extern u32 D_8018C2B8, D_8018C2BC, D_8018C2C0, D_8018C2C4; - extern u32 D_8018C2B8, D_8018C2BC, D_8018C2C0, D_8018C2C4; - extern u32 D_8018C2B8, D_8018C2BC, D_8018C2C0, D_8018C2C4; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018C298[0x00], p); - ApplyMatrixSV(mat, &D_8018C298[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018C298[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018C298[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018C2C0; - *(u32 *)(prim + 0x24) = D_8018C2B8; - *(u32 *)(prim + 0x28) = D_8018C2C4; - *(u32 *)(prim + 0x2c) = D_8018C2BC; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018C2C8[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018C2C8[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018C2C8[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018C2C8[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018C344[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018C344[a1 & 0x7F]; -} - - - -extern s32 D_8018C364[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018C364[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018C3E0[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018C3E0[a1 & 0x7F]; -} - - - -extern u8 D_8018C400[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018C400[a1 & 0x7F]; -} - - - -extern u8 D_8018C420[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018C420[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018C440[])(void); - D_8018C440[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018C4BC[])(void); - -void func_80165AC8(void) { - D_8018C4BC[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018C538[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018C538[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C4E9C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C4E9C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018C544[])(void); - -void func_80166018(void *a0) { - D_8018C544[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018C54C[])(void); - -void func_801663FC(void *a0) { - D_8018C54C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018C614[])(void); - -void func_80166618(void *a0) { - D_8018C614[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018C624[])(void); - -void func_80166654(void *a0) { - D_8018C624[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C5798[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C5798[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C5798). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C5798[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C5798)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C5798[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C5798[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018C568[]; - extern u8 D_8018C554[]; - extern u8 D_8018C57C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018C568; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018C554; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018C57C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80167714); - - -extern void (*D_8018C634[])(void); - -void func_801678B4(void *a0) { - D_8018C634[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018C640[])(void); - -void func_80167A9C(void *a0) { - D_8018C640[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018C74C; - extern u8 D_8018C760[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018C74C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018C760; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018C5A0[]; -extern u8 D_8018C5B4[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018C5A0; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018C5B4; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018C658[])(void); - -void func_80168744(void *a0) { - D_8018C658[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018C648 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018C648[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018C648; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018C660[])(void); - -void func_801689D8(void *a0) { - D_8018C660[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018C668[])(void); - -void func_80168AA8(void *a0) { - D_8018C668[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018C670[])(void); - -void func_80168D58(void *a0) { - D_8018C670[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018C678[])(void); - -void func_8016901C(void *a0) { - D_8018C678[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015AE2C", func_80169228); - - -extern void (*D_8018C680[])(void); - -void func_801693CC(void *a0) { - D_8018C680[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018C688[])(void); - -void func_80169830(void *a0) { - D_8018C688[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018C73C[])(void); - -void func_80169B80(void *a0) { - D_8018C73C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018C690[]; - extern u8 D_8018C700[]; - extern u8 D_8018C730[]; - extern u8 D_801C67D8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018C730, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018C690[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C67D8; - RotMatrixYXZ(rot, D_801C67D8); - func_80048D9C(D_801C67D8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018C700); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018C744[])(void); - -void func_80169F00(void *a0) { - D_8018C744[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018C6F4[]; -extern char D_8018C6B4[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018C6F4, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018C6B4); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018C77C[])(void); - -void func_8016A020(void *a0) { - D_8018C77C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018C74C; - extern u8 D_8018C760[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018C74C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018C760; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018C788[])(void); - -void func_8016A700(void *a0) { - D_8018C788[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018C7D0[])(void); - -void func_8016AB30(void *a0) { - D_8018C7D0[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c b/src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c new file mode 100644 index 000000000..1fe001452 --- /dev/null +++ b/src/ov_SC03_089/ov_SC03_089_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018BB9C; +extern u8 D_8018BB0C; +extern u8 D_8018BAE8; +extern u8 D_8018BAC4; +extern u8 D_8018BB78; +extern u8 D_8018BB54; +extern u8 D_8018BB30; +extern u8 D_8018BAA0; +extern void func_80145934(void); +extern u8 D_8018BC2C; +extern u8 D_8018BC08; +extern u8 D_8018BBE4; +extern u8 D_8018BBC0; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018B024[]; +extern unsigned char D_8018B054[]; +extern unsigned char D_8018B0A4[]; +extern unsigned char D_8018B0D4[]; +extern unsigned char D_8018B104[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018B154[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018B21C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018B2A4[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018B2AC; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C55C8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C55CC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018B2DC; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018B384[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018B3A8[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018B398; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018B3BC[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018B3C8[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018B3D8[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018B3F0[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018B3E0; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018B404[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018B420[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018B410; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018B434[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018B448[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018B45C; +extern void (*D_8018B484[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018B464; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018B4D0[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018B4D4[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018B938[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018B948[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C5600; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018B970[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018B950; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018B960; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018B9B0[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018B9B8[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018B984; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018B9C4[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018B994; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C5608; +extern s32 D_801C5614; +extern s32 D_801C5618; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018BA00[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018B9D4[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C5610; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018BC50[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018BA70[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018BCF4[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018BE48[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018BC64; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018BE50[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018BC74; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018BC94; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018BE58[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018BE80[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018BD00[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018BE8C[])(void); + +void func_8015C714(void *a0) { + D_8018BE8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018BD00[])(void*); + extern int D_8018BCA4; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018BD00)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018BD00)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BCA4); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018BD00[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018BD00[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018BD00[])(void*); + extern int D_8018BCA4; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018BD00)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BCA4); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018BD00)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018BE9C[])(void); + D_8018BE9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018BD00[])(struct Ent_8015CD20 *); + extern u8 D_8018BCB4; + extern u8 D_8018BEA4; + extern u8 D_8018BEB4; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018BD00[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BCB4); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BEA4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BEB4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018BD00[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018BED4[])(void); + D_8018BED4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018BEC4; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018BEC4 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018BD00[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018BF30; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018BF30, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018B014[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018B014; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018BF38[])(void); + D_8018BF38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018BF44[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018BF44[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018BF44[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018BF44[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018BD00[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018BF44[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018BCC4[]; + extern u8 D_8018BCD4[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BCC4); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BCD4); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018BF44[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018BF44[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018BF44[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018BF78[])(void); + D_8018BF78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018BD00[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018BF80[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018BF98[])(void); + D_8018BF98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018BD00[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018BF80[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018BF80[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018BFB8[])(void); + D_8018BFB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018BD00[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018BD00)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018BFC8; +extern u16 D_8018BFCA; +extern u16 D_8018BFCC; +extern s32 D_8018BFD0; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018BFC8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018BFCA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018BFCC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018BFD0, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018BFD8; + +void func_8015E588(void) { + func_8013C9C4(&D_8018BFD8); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018BD00[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018BD00)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018BFEC[])(void); + D_8018BFEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018BD00[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018BD00[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018BFF4[])(void); + D_8018BFF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018BCE4; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018BCE4); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018BD00[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018BFFC[])(void); + D_8018BFFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018BD00[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018BD00[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018C004[])(void); + D_8018C004[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018BD00[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018C00C; + extern s32 D_8018C01C; + extern s32 D_8018C02C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C00C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C01C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018BD00[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C02C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018C03C[])(void); + D_8018C03C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018BD00[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018BD00[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018BD00[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018BD00[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018C048[])(void); + D_8018C048[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018BD00[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018BD00[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018BD00[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018BD00[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018C05C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018C05C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018BD00[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018BD00)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018BD00[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018BD00[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018C0D8[])(void); + D_8018C0D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018BD00[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018BD00)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018C0E8[])(void); + D_8018C0E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018BD00[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018BD00[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018BD00[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018BD00[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018BD00[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018BD00[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018BD00[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018C0F0[])(void); + D_8018C0F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018BD00[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018BD00)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018BD00[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018BD00)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018C0FC[])(void); + D_8018C0FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018BD00 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018BD00[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018BD00[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018BD00[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018C10C[])(void); + +void func_80160EA4(void *a0) { + D_8018C10C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018BD00[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018BD00[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018C13C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018C13C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018C1A0; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018C1A0); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C5620[]; + extern u8 D_8018C16C[]; + extern u8 D_8018C18C[]; + extern u8 D_801C562C[]; + extern u8 D_801C5654[]; + extern u8 D_801C566C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C5620[0] = p; + func_80024054(&D_8018C16C, &D_801C562C); + func_8001CE28(p, &D_801C562C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C5620[1] = p; + func_80024054(&D_8018C18C, &D_801C5654); + func_8001CE28(p, &D_801C5654); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C5620[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C566C, 0x84); + func_8001CE68(p, &D_801C566C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C566C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C5620[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C5620; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018C1A0; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018C1A0; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018C1A0; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018C1A0; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C5620[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C5620; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018C1C4[])(void); + +void func_80162330(void *a0) { + D_8018C1C4[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C5678[i] via `extern int D_801C5678[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018C1D0[]; + extern s32 D_8018C1E8; + extern u8 D_801C5684[]; + extern u8 D_801C56AC[]; + extern u8 D_801C56C8[]; + extern int D_801C5678[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C5678[0] = (s32)item; + func_80024054(D_8018C1D0, D_801C5684); + func_8001CE28(item, D_801C5684); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C5678[1] = (s32)item; + func_80024054(((u8 *)&D_8018C1E8), D_801C56AC); + func_8001CE28(item, D_801C56AC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C5678[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C56C8, 0x84); + func_8001CE68(item, D_801C56C8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C56C8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C5678[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C5678; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_801627E8); + + +extern void (*D_8018C20C[])(void); + +void func_80162834(void *a0) { + D_8018C20C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018C1FC; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018C1FC, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C4E8C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C4E8C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C4E8C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C4E8C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018C214[])(void); + +void func_80163A58(void *a0) { + D_8018C214[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C4E94; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C4E94; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018C268[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018C268[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018C230; +extern s16 D_8018C264; +extern s16 D_8018C262; +extern s16 D_8018C260; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018C230; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018C264 = 0x80; + D_8018C262 = 0x80; + D_8018C260 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018C264 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018C264` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018C264 - 8; + D_8018C264 = nv; + D_8018C262 = nv; + D_8018C260 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018C274[])(void); + +void func_80164BA0(void *a0) { + D_8018C274[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C56D8; +extern u8 D_801C56D9; +extern u8 D_801C56DA; +extern u8 D_801C56DB; +extern u8 D_801C56DC; +extern u8 D_801C56DD; +extern u8 D_801C56DE; +extern u8 D_801C56DF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C56D8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C56D9 = 0xf0; + *(u8 *)base = 0xf0; + D_801C56DA = 0xc0; + D_801C56DE = 0; + D_801C56DD = 0; + D_801C56DC = 0; + D_801C56DF = 0; + D_801C56DB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C56D8; +extern u8 D_801C56D9; +extern u8 D_801C56DA; + +s32 func_80164E40(void) { + u8 *p = &D_801C56D8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C56D9 != 0) { + D_801C56D9 -= 0x10; + } + if (D_801C56DA != 0) { + D_801C56DA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018C284[])(void); + +void func_80164EA4(void *a0) { + D_8018C284[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C5724[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C5724[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C5718[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C5718[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C5718[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C5718; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C5718; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018C298[]; + extern u32 D_8018C2B8, D_8018C2BC, D_8018C2C0, D_8018C2C4; + extern u32 D_8018C2B8, D_8018C2BC, D_8018C2C0, D_8018C2C4; + extern u32 D_8018C2B8, D_8018C2BC, D_8018C2C0, D_8018C2C4; + extern u32 D_8018C2B8, D_8018C2BC, D_8018C2C0, D_8018C2C4; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018C298[0x00], p); + ApplyMatrixSV(mat, &D_8018C298[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018C298[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018C298[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018C2C0; + *(u32 *)(prim + 0x24) = D_8018C2B8; + *(u32 *)(prim + 0x28) = D_8018C2C4; + *(u32 *)(prim + 0x2c) = D_8018C2BC; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018C2C8[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018C2C8[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018C2C8[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018C2C8[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018C344[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018C344[a1 & 0x7F]; +} + + + +extern s32 D_8018C364[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018C364[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018C3E0[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018C3E0[a1 & 0x7F]; +} + + + +extern u8 D_8018C400[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018C400[a1 & 0x7F]; +} + + + +extern u8 D_8018C420[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018C420[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018C440[])(void); + D_8018C440[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018C4BC[])(void); + +void func_80165AC8(void) { + D_8018C4BC[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018C538[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018C538[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C4E9C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C4E9C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018C544[])(void); + +void func_80166018(void *a0) { + D_8018C544[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018C54C[])(void); + +void func_801663FC(void *a0) { + D_8018C54C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018C614[])(void); + +void func_80166618(void *a0) { + D_8018C614[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018C624[])(void); + +void func_80166654(void *a0) { + D_8018C624[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C5798[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C5798[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C5798). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C5798[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C5798)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C5798[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C5798[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018C568[]; + extern u8 D_8018C554[]; + extern u8 D_8018C57C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018C568; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018C554; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018C57C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80167714); + + +extern void (*D_8018C634[])(void); + +void func_801678B4(void *a0) { + D_8018C634[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018C640[])(void); + +void func_80167A9C(void *a0) { + D_8018C640[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018C74C; + extern u8 D_8018C760[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018C74C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018C760; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018C5A0[]; +extern u8 D_8018C5B4[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018C5A0; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018C5B4; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018C658[])(void); + +void func_80168744(void *a0) { + D_8018C658[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018C648 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018C648[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018C648; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018C660[])(void); + +void func_801689D8(void *a0) { + D_8018C660[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018C668[])(void); + +void func_80168AA8(void *a0) { + D_8018C668[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018C670[])(void); + +void func_80168D58(void *a0) { + D_8018C670[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018C678[])(void); + +void func_8016901C(void *a0) { + D_8018C678[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_089/nonmatchings/ov_SC03_089_jr_8015C32C", func_80169228); + + +extern void (*D_8018C680[])(void); + +void func_801693CC(void *a0) { + D_8018C680[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018C688[])(void); + +void func_80169830(void *a0) { + D_8018C688[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018C73C[])(void); + +void func_80169B80(void *a0) { + D_8018C73C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018C690[]; + extern u8 D_8018C700[]; + extern u8 D_8018C730[]; + extern u8 D_801C67D8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018C730, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018C690[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C67D8; + RotMatrixYXZ(rot, D_801C67D8); + func_80048D9C(D_801C67D8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018C700); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018C744[])(void); + +void func_80169F00(void *a0) { + D_8018C744[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018C6F4[]; +extern char D_8018C6B4[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018C6F4, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018C6B4); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018C77C[])(void); + +void func_8016A020(void *a0) { + D_8018C77C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018C74C; + extern u8 D_8018C760[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018C74C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018C760; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018C788[])(void); + +void func_8016A700(void *a0) { + D_8018C788[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018C7D0[])(void); + +void func_8016AB30(void *a0) { + D_8018C7D0[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_090/ov_SC03_090_jr_8015AE2C.c b/src/ov_SC03_090/ov_SC03_090_jr_8015AE2C.c index da00871b8..2e90a18ba 100644 --- a/src/ov_SC03_090/ov_SC03_090_jr_8015AE2C.c +++ b/src/ov_SC03_090/ov_SC03_090_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018E2B0[])(void); - -void func_8015C714(void *a0) { - D_8018E2B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018E124[])(void*); - extern int D_8018E0C8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018E124)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018E124)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018E0C8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018E124[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018E124[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018E124[])(void*); - extern int D_8018E0C8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018E124)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018E0C8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018E124)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018E2C0[])(void); - D_8018E2C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018E124[])(struct Ent_8015CD20 *); - extern u8 D_8018E0D8; - extern u8 D_8018E2C8; - extern u8 D_8018E2D8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018E124[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E0D8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E2C8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E2D8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018E124[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018E2F8[])(void); - D_8018E2F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018E2E8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018E2E8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018E124[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018E354; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018E354, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018D438[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018D438; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018E35C[])(void); - D_8018E35C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018E368[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018E368[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018E368[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018E368[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018E124[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018E368[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018E0E8[]; - extern u8 D_8018E0F8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018E0E8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018E0F8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018E368[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018E368[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018E368[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018E39C[])(void); - D_8018E39C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018E124[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018E3A4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018E3BC[])(void); - D_8018E3BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018E124[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018E3A4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018E3DC[])(void); - D_8018E3DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018E124[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018E124)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018E3EC; -extern u16 D_8018E3EE; -extern u16 D_8018E3F0; -extern s32 D_8018E3F4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018E3EC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018E3EE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018E3F0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018E3F4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018E3FC; - -void func_8015E588(void) { - func_8013C9C4(&D_8018E3FC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018E124[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018E124)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018E410[])(void); - D_8018E410[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018E124[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018E124[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018E418[])(void); - D_8018E418[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018E108; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018E108); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018E124[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018E420[])(void); - D_8018E420[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018E124[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018E124[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018E428[])(void); - D_8018E428[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018E124[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018E430; - extern s32 D_8018E440; - extern s32 D_8018E450; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018E124[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E430); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E440); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018E124[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E450); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018E460[])(void); - D_8018E460[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018E124[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018E124[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018E124[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018E124[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018E46C[])(void); - D_8018E46C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018E124[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018E124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018E124[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018E124[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018E480[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018E480[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018E124[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018E124)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018E124[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018E124[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018E4FC[])(void); - D_8018E4FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018E124[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018E124)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018E50C[])(void); - D_8018E50C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018E124[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018E124[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018E124[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018E124[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018E124[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018E124[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018E124[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018E514[])(void); - D_8018E514[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018E124[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018E124)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018E124[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018E124)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018E520[])(void); - D_8018E520[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018E124 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018E124[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018E124[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018E124[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018E530[])(void); - -void func_80160EA4(void *a0) { - D_8018E530[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018E124[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018E124[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018E560[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018E560[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018E5C4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018E5C4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801CAA88[]; - extern u8 D_8018E590[]; - extern u8 D_8018E5B0[]; - extern u8 D_801CAA94[]; - extern u8 D_801CAABC[]; - extern u8 D_801CAAD4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801CAA88[0] = p; - func_80024054(&D_8018E590, &D_801CAA94); - func_8001CE28(p, &D_801CAA94); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801CAA88[1] = p; - func_80024054(&D_8018E5B0, &D_801CAABC); - func_8001CE28(p, &D_801CAABC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801CAA88[2] = p; - func_800242D0((s16)func_801620C4(), &D_801CAAD4, 0x84); - func_8001CE68(p, &D_801CAAD4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801CAAD4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CAA88[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801CAA88; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018E5C4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018E5C4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018E5C4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018E5C4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801CAA88[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801CAA88; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018E5E8[])(void); - -void func_80162330(void *a0) { - D_8018E5E8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801CAAE0[i] via `extern int D_801CAAE0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018E5F4[]; - extern s32 D_8018E60C; - extern u8 D_801CAAEC[]; - extern u8 D_801CAB14[]; - extern u8 D_801CAB30[]; - extern int D_801CAAE0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801CAAE0[0] = (s32)item; - func_80024054(D_8018E5F4, D_801CAAEC); - func_8001CE28(item, D_801CAAEC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801CAAE0[1] = (s32)item; - func_80024054(((u8 *)&D_8018E60C), D_801CAB14); - func_8001CE28(item, D_801CAB14); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801CAAE0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801CAB30, 0x84); - func_8001CE68(item, D_801CAB30); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801CAB30, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CAAE0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801CAAE0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018E630[])(void); - -void func_80162834(void *a0) { - D_8018E630[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018E620; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018E620, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801CA2F8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801CA2F8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801CA2F8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801CA2F8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018E638[])(void); - -void func_80163A58(void *a0) { - D_8018E638[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801CA300; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801CA300; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018E68C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018E68C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018E654; -extern s16 D_8018E688; -extern s16 D_8018E686; -extern s16 D_8018E684; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018E654; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018E688 = 0x80; - D_8018E686 = 0x80; - D_8018E684 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018E688 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E688` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018E688 - 8; - D_8018E688 = nv; - D_8018E686 = nv; - D_8018E684 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018E698[])(void); - -void func_80164BA0(void *a0) { - D_8018E698[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801CAB40; -extern u8 D_801CAB41; -extern u8 D_801CAB42; -extern u8 D_801CAB43; -extern u8 D_801CAB44; -extern u8 D_801CAB45; -extern u8 D_801CAB46; -extern u8 D_801CAB47; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801CAB40; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801CAB41 = 0xf0; - *(u8 *)base = 0xf0; - D_801CAB42 = 0xc0; - D_801CAB46 = 0; - D_801CAB45 = 0; - D_801CAB44 = 0; - D_801CAB47 = 0; - D_801CAB43 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801CAB40; -extern u8 D_801CAB41; -extern u8 D_801CAB42; - -s32 func_80164E40(void) { - u8 *p = &D_801CAB40; - if (*p != 0) { - *p -= 0x10; - } - if (D_801CAB41 != 0) { - D_801CAB41 -= 0x10; - } - if (D_801CAB42 != 0) { - D_801CAB42 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018E6A8[])(void); - -void func_80164EA4(void *a0) { - D_8018E6A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801CAB8C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801CAB8C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801CAB80[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801CAB80[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801CAB80[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801CAB80; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801CAB80; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018E6BC[]; - extern u32 D_8018E6DC, D_8018E6E0, D_8018E6E4, D_8018E6E8; - extern u32 D_8018E6DC, D_8018E6E0, D_8018E6E4, D_8018E6E8; - extern u32 D_8018E6DC, D_8018E6E0, D_8018E6E4, D_8018E6E8; - extern u32 D_8018E6DC, D_8018E6E0, D_8018E6E4, D_8018E6E8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018E6BC[0x00], p); - ApplyMatrixSV(mat, &D_8018E6BC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018E6BC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018E6BC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018E6E4; - *(u32 *)(prim + 0x24) = D_8018E6DC; - *(u32 *)(prim + 0x28) = D_8018E6E8; - *(u32 *)(prim + 0x2c) = D_8018E6E0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018E6EC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018E6EC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018E6EC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018E6EC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018E768[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018E768[a1 & 0x7F]; -} - - - -extern s32 D_8018E788[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018E788[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018E804[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018E804[a1 & 0x7F]; -} - - - -extern u8 D_8018E824[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018E824[a1 & 0x7F]; -} - - - -extern u8 D_8018E844[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018E844[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018E864[])(void); - D_8018E864[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018E8E0[])(void); - -void func_80165AC8(void) { - D_8018E8E0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018E95C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018E95C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801CA308; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801CA308, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018E968[])(void); - -void func_80166018(void *a0) { - D_8018E968[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018E970[])(void); - -void func_801663FC(void *a0) { - D_8018E970[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018EA38[])(void); - -void func_80166618(void *a0) { - D_8018EA38[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018EA48[])(void); - -void func_80166654(void *a0) { - D_8018EA48[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801CAC00[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801CAC00[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CAC00). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801CAC00[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801CAC00)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801CAC00[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801CAC00[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018E98C[]; - extern u8 D_8018E978[]; - extern u8 D_8018E9A0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018E98C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018E978; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018E9A0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80167714); - - -extern void (*D_8018EA58[])(void); - -void func_801678B4(void *a0) { - D_8018EA58[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018EA64[])(void); - -void func_80167A9C(void *a0) { - D_8018EA64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018EB70; - extern u8 D_8018EB84[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018EB70); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018EB84; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018E9C4[]; -extern u8 D_8018E9D8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018E9C4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018E9D8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018EA7C[])(void); - -void func_80168744(void *a0) { - D_8018EA7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018EA6C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018EA6C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018EA6C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018EA84[])(void); - -void func_801689D8(void *a0) { - D_8018EA84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018EA8C[])(void); - -void func_80168AA8(void *a0) { - D_8018EA8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018EA94[])(void); - -void func_80168D58(void *a0) { - D_8018EA94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018EA9C[])(void); - -void func_8016901C(void *a0) { - D_8018EA9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015AE2C", func_80169228); - - -extern void (*D_8018EAA4[])(void); - -void func_801693CC(void *a0) { - D_8018EAA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018EAAC[])(void); - -void func_80169830(void *a0) { - D_8018EAAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018EB60[])(void); - -void func_80169B80(void *a0) { - D_8018EB60[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018EAB4[]; - extern u8 D_8018EB24[]; - extern u8 D_8018EB54[]; - extern u8 D_801CBC48[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018EB54, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018EAB4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801CBC48; - RotMatrixYXZ(rot, D_801CBC48); - func_80048D9C(D_801CBC48, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018EB24); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018EB68[])(void); - -void func_80169F00(void *a0) { - D_8018EB68[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018EB18[]; -extern char D_8018EAD8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018EB18, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018EAD8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018EBA0[])(void); - -void func_8016A020(void *a0) { - D_8018EBA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018EB70; - extern u8 D_8018EB84[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018EB70); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018EB84; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018EBAC[])(void); - -void func_8016A700(void *a0) { - D_8018EBAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018EBF4[])(void); - -void func_8016AB30(void *a0) { - D_8018EBF4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c b/src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c new file mode 100644 index 000000000..02c61fc90 --- /dev/null +++ b/src/ov_SC03_090/ov_SC03_090_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018DFC0; +extern u8 D_8018DF30; +extern u8 D_8018DF0C; +extern u8 D_8018DEE8; +extern u8 D_8018DF9C; +extern u8 D_8018DF78; +extern u8 D_8018DF54; +extern u8 D_8018DEC4; +extern void func_80145934(void); +extern u8 D_8018E050; +extern u8 D_8018E02C; +extern u8 D_8018E008; +extern u8 D_8018DFE4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018D448[]; +extern unsigned char D_8018D478[]; +extern unsigned char D_8018D4C8[]; +extern unsigned char D_8018D4F8[]; +extern unsigned char D_8018D528[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018D578[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018D640[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018D6C8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018D6D0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801CAA30; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801CAA34; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018D700; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018D7A8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018D7CC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018D7BC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018D7E0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018D7EC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018D7FC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018D814[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018D804; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018D828[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018D844[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018D834; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018D858[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018D86C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018D880; +extern void (*D_8018D8A8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018D888; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018D8F4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018D8F8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018DD5C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018DD6C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801CAA68; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018DD94[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018DD74; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018DD84; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018DDD4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018DDDC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018DDA8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018DDE8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018DDB8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801CAA70; +extern s32 D_801CAA7C; +extern s32 D_801CAA80; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018DE24[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018DDF8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801CAA78; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018E074[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018DE94[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018E118[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018E26C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018E088; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018E274[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018E098; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018E0B8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018E27C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018E2A4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018E124[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018E2B0[])(void); + +void func_8015C714(void *a0) { + D_8018E2B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018E124[])(void*); + extern int D_8018E0C8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018E124)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018E124)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018E0C8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018E124[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018E124[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018E124[])(void*); + extern int D_8018E0C8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018E124)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018E0C8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018E124)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018E2C0[])(void); + D_8018E2C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018E124[])(struct Ent_8015CD20 *); + extern u8 D_8018E0D8; + extern u8 D_8018E2C8; + extern u8 D_8018E2D8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018E124[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E0D8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E2C8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018E2D8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018E124[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018E2F8[])(void); + D_8018E2F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018E2E8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018E2E8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018E124[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018E354; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018E354, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018D438[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018D438; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018E35C[])(void); + D_8018E35C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018E368[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018E368[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018E368[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018E368[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018E124[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018E368[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018E0E8[]; + extern u8 D_8018E0F8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018E0E8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018E0F8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018E368[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018E368[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018E368[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018E39C[])(void); + D_8018E39C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018E124[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018E3A4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018E3BC[])(void); + D_8018E3BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018E124[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018E3A4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018E3A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018E3DC[])(void); + D_8018E3DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018E124[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018E124)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018E3EC; +extern u16 D_8018E3EE; +extern u16 D_8018E3F0; +extern s32 D_8018E3F4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018E3EC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018E3EE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018E3F0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018E3F4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018E3FC; + +void func_8015E588(void) { + func_8013C9C4(&D_8018E3FC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018E124[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018E124)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018E410[])(void); + D_8018E410[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018E124[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018E124[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018E418[])(void); + D_8018E418[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018E108; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018E108); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018E124[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018E420[])(void); + D_8018E420[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018E124[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018E124[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018E428[])(void); + D_8018E428[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018E124[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018E430; + extern s32 D_8018E440; + extern s32 D_8018E450; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E430); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E440); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018E124[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018E450); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018E460[])(void); + D_8018E460[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018E124[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018E124[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018E124[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018E124[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018E46C[])(void); + D_8018E46C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018E124[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018E124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018E124[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018E124[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018E480[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018E480[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018E124[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018E124)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018E124[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018E124[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018E4FC[])(void); + D_8018E4FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018E124[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018E124)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018E50C[])(void); + D_8018E50C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018E124[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018E124[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018E124[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018E124[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018E124[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018E124[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018E124[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018E514[])(void); + D_8018E514[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018E124[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018E124)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018E124[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018E124)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018E520[])(void); + D_8018E520[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018E124 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018E124[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018E124[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018E124[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018E530[])(void); + +void func_80160EA4(void *a0) { + D_8018E530[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018E124[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018E124[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018E560[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018E560[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018E5C4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018E5C4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801CAA88[]; + extern u8 D_8018E590[]; + extern u8 D_8018E5B0[]; + extern u8 D_801CAA94[]; + extern u8 D_801CAABC[]; + extern u8 D_801CAAD4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801CAA88[0] = p; + func_80024054(&D_8018E590, &D_801CAA94); + func_8001CE28(p, &D_801CAA94); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801CAA88[1] = p; + func_80024054(&D_8018E5B0, &D_801CAABC); + func_8001CE28(p, &D_801CAABC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801CAA88[2] = p; + func_800242D0((s16)func_801620C4(), &D_801CAAD4, 0x84); + func_8001CE68(p, &D_801CAAD4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801CAAD4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CAA88[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801CAA88; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018E5C4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018E5C4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018E5C4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018E5C4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801CAA88[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801CAA88; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018E5E8[])(void); + +void func_80162330(void *a0) { + D_8018E5E8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801CAAE0[i] via `extern int D_801CAAE0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018E5F4[]; + extern s32 D_8018E60C; + extern u8 D_801CAAEC[]; + extern u8 D_801CAB14[]; + extern u8 D_801CAB30[]; + extern int D_801CAAE0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801CAAE0[0] = (s32)item; + func_80024054(D_8018E5F4, D_801CAAEC); + func_8001CE28(item, D_801CAAEC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801CAAE0[1] = (s32)item; + func_80024054(((u8 *)&D_8018E60C), D_801CAB14); + func_8001CE28(item, D_801CAB14); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801CAAE0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801CAB30, 0x84); + func_8001CE68(item, D_801CAB30); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801CAB30, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CAAE0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801CAAE0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_801627E8); + + +extern void (*D_8018E630[])(void); + +void func_80162834(void *a0) { + D_8018E630[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018E620; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018E620, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801CA2F8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801CA2F8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801CA2F8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801CA2F8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018E638[])(void); + +void func_80163A58(void *a0) { + D_8018E638[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801CA300; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801CA300; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018E68C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018E68C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018E654; +extern s16 D_8018E688; +extern s16 D_8018E686; +extern s16 D_8018E684; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018E654; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018E688 = 0x80; + D_8018E686 = 0x80; + D_8018E684 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018E688 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018E688` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018E688 - 8; + D_8018E688 = nv; + D_8018E686 = nv; + D_8018E684 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018E698[])(void); + +void func_80164BA0(void *a0) { + D_8018E698[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801CAB40; +extern u8 D_801CAB41; +extern u8 D_801CAB42; +extern u8 D_801CAB43; +extern u8 D_801CAB44; +extern u8 D_801CAB45; +extern u8 D_801CAB46; +extern u8 D_801CAB47; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801CAB40; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801CAB41 = 0xf0; + *(u8 *)base = 0xf0; + D_801CAB42 = 0xc0; + D_801CAB46 = 0; + D_801CAB45 = 0; + D_801CAB44 = 0; + D_801CAB47 = 0; + D_801CAB43 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801CAB40; +extern u8 D_801CAB41; +extern u8 D_801CAB42; + +s32 func_80164E40(void) { + u8 *p = &D_801CAB40; + if (*p != 0) { + *p -= 0x10; + } + if (D_801CAB41 != 0) { + D_801CAB41 -= 0x10; + } + if (D_801CAB42 != 0) { + D_801CAB42 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018E6A8[])(void); + +void func_80164EA4(void *a0) { + D_8018E6A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801CAB8C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801CAB8C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801CAB80[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801CAB80[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801CAB80[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801CAB80; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801CAB80; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018E6BC[]; + extern u32 D_8018E6DC, D_8018E6E0, D_8018E6E4, D_8018E6E8; + extern u32 D_8018E6DC, D_8018E6E0, D_8018E6E4, D_8018E6E8; + extern u32 D_8018E6DC, D_8018E6E0, D_8018E6E4, D_8018E6E8; + extern u32 D_8018E6DC, D_8018E6E0, D_8018E6E4, D_8018E6E8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018E6BC[0x00], p); + ApplyMatrixSV(mat, &D_8018E6BC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018E6BC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018E6BC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018E6E4; + *(u32 *)(prim + 0x24) = D_8018E6DC; + *(u32 *)(prim + 0x28) = D_8018E6E8; + *(u32 *)(prim + 0x2c) = D_8018E6E0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018E6EC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018E6EC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018E6EC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018E6EC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018E768[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018E768[a1 & 0x7F]; +} + + + +extern s32 D_8018E788[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018E788[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018E804[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018E804[a1 & 0x7F]; +} + + + +extern u8 D_8018E824[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018E824[a1 & 0x7F]; +} + + + +extern u8 D_8018E844[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018E844[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018E864[])(void); + D_8018E864[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018E8E0[])(void); + +void func_80165AC8(void) { + D_8018E8E0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018E95C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018E95C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801CA308; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801CA308, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018E968[])(void); + +void func_80166018(void *a0) { + D_8018E968[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018E970[])(void); + +void func_801663FC(void *a0) { + D_8018E970[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018EA38[])(void); + +void func_80166618(void *a0) { + D_8018EA38[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018EA48[])(void); + +void func_80166654(void *a0) { + D_8018EA48[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801CAC00[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801CAC00[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CAC00). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801CAC00[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801CAC00)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801CAC00[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801CAC00[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018E98C[]; + extern u8 D_8018E978[]; + extern u8 D_8018E9A0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018E98C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018E978; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018E9A0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80167714); + + +extern void (*D_8018EA58[])(void); + +void func_801678B4(void *a0) { + D_8018EA58[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018EA64[])(void); + +void func_80167A9C(void *a0) { + D_8018EA64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018EB70; + extern u8 D_8018EB84[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018EB70); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018EB84; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018E9C4[]; +extern u8 D_8018E9D8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018E9C4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018E9D8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018EA7C[])(void); + +void func_80168744(void *a0) { + D_8018EA7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018EA6C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018EA6C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018EA6C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018EA84[])(void); + +void func_801689D8(void *a0) { + D_8018EA84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018EA8C[])(void); + +void func_80168AA8(void *a0) { + D_8018EA8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018EA94[])(void); + +void func_80168D58(void *a0) { + D_8018EA94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018EA9C[])(void); + +void func_8016901C(void *a0) { + D_8018EA9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_090/nonmatchings/ov_SC03_090_jr_8015C32C", func_80169228); + + +extern void (*D_8018EAA4[])(void); + +void func_801693CC(void *a0) { + D_8018EAA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018EAAC[])(void); + +void func_80169830(void *a0) { + D_8018EAAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018EB60[])(void); + +void func_80169B80(void *a0) { + D_8018EB60[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018EAB4[]; + extern u8 D_8018EB24[]; + extern u8 D_8018EB54[]; + extern u8 D_801CBC48[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018EB54, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018EAB4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801CBC48; + RotMatrixYXZ(rot, D_801CBC48); + func_80048D9C(D_801CBC48, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018EB24); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018EB68[])(void); + +void func_80169F00(void *a0) { + D_8018EB68[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018EB18[]; +extern char D_8018EAD8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018EB18, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018EAD8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018EBA0[])(void); + +void func_8016A020(void *a0) { + D_8018EBA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018EB70; + extern u8 D_8018EB84[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018EB70); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018EB84; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018EBAC[])(void); + +void func_8016A700(void *a0) { + D_8018EBAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018EBF4[])(void); + +void func_8016AB30(void *a0) { + D_8018EBF4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_091/ov_SC03_091_jr_8015AE2C.c b/src/ov_SC03_091/ov_SC03_091_jr_8015AE2C.c index 2e35e253d..619e27fd8 100644 --- a/src/ov_SC03_091/ov_SC03_091_jr_8015AE2C.c +++ b/src/ov_SC03_091/ov_SC03_091_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018F158[])(void); - -void func_8015C714(void *a0) { - D_8018F158[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018EFCC[])(void*); - extern int D_8018EF70; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018EF70); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018EFCC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018EFCC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018EFCC[])(void*); - extern int D_8018EF70; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018EF70); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018F168[])(void); - D_8018F168[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018EFCC[])(struct Ent_8015CD20 *); - extern u8 D_8018EF80; - extern u8 D_8018F170; - extern u8 D_8018F180; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018EFCC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018EF80); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F170); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F180); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018EFCC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018F1A0[])(void); - D_8018F1A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018F190; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018F190 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018EFCC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018F1FC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018F1FC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018E2E0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018E2E0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018F204[])(void); - D_8018F204[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018F210[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018F210[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018F210[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018F210[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018EFCC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018F210[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018EF90[]; - extern u8 D_8018EFA0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018EF90); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018EFA0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018F210[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018F210[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018F210[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018F244[])(void); - D_8018F244[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018EFCC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018F24C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018F264[])(void); - D_8018F264[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018EFCC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018F24C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018F284[])(void); - D_8018F284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018EFCC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018EFCC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018F294; -extern u16 D_8018F296; -extern u16 D_8018F298; -extern s32 D_8018F29C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018F294 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018F296 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018F298 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018F29C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018F2A4; - -void func_8015E588(void) { - func_8013C9C4(&D_8018F2A4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018EFCC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018EFCC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018F2B8[])(void); - D_8018F2B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018EFCC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018EFCC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018F2C0[])(void); - D_8018F2C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018EFB0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018EFB0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018EFCC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018F2C8[])(void); - D_8018F2C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018EFCC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018EFCC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018F2D0[])(void); - D_8018F2D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018EFCC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018F2D8; - extern s32 D_8018F2E8; - extern s32 D_8018F2F8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018EFCC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018F2D8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018F2E8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018EFCC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018F2F8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018F308[])(void); - D_8018F308[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018EFCC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018EFCC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018EFCC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018EFCC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018F314[])(void); - D_8018F314[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018EFCC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018EFCC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018EFCC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018EFCC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018F328[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018F328[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018EFCC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018EFCC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018EFCC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018EFCC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018F3A4[])(void); - D_8018F3A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018EFCC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018EFCC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018F3B4[])(void); - D_8018F3B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018EFCC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018EFCC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018EFCC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018EFCC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018EFCC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018EFCC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018EFCC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018F3BC[])(void); - D_8018F3BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018EFCC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018EFCC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018EFCC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018F3C8[])(void); - D_8018F3C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018EFCC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018EFCC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018EFCC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018EFCC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018F3D8[])(void); - -void func_80160EA4(void *a0) { - D_8018F3D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018EFCC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018EFCC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018F408[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018F408[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018F46C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018F46C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801D1158[]; - extern u8 D_8018F438[]; - extern u8 D_8018F458[]; - extern u8 D_801D1164[]; - extern u8 D_801D118C[]; - extern u8 D_801D11A4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801D1158[0] = p; - func_80024054(&D_8018F438, &D_801D1164); - func_8001CE28(p, &D_801D1164); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801D1158[1] = p; - func_80024054(&D_8018F458, &D_801D118C); - func_8001CE28(p, &D_801D118C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801D1158[2] = p; - func_800242D0((s16)func_801620C4(), &D_801D11A4, 0x84); - func_8001CE68(p, &D_801D11A4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801D11A4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D1158[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801D1158; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018F46C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018F46C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018F46C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018F46C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801D1158[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801D1158; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018F490[])(void); - -void func_80162330(void *a0) { - D_8018F490[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801D11B0[i] via `extern int D_801D11B0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018F49C[]; - extern s32 D_8018F4B4; - extern u8 D_801D11BC[]; - extern u8 D_801D11E4[]; - extern u8 D_801D1200[]; - extern int D_801D11B0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801D11B0[0] = (s32)item; - func_80024054(D_8018F49C, D_801D11BC); - func_8001CE28(item, D_801D11BC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801D11B0[1] = (s32)item; - func_80024054(((u8 *)&D_8018F4B4), D_801D11E4); - func_8001CE28(item, D_801D11E4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801D11B0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801D1200, 0x84); - func_8001CE68(item, D_801D1200); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801D1200, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D11B0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801D11B0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018F4D8[])(void); - -void func_80162834(void *a0) { - D_8018F4D8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018F4C8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018F4C8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801D09C4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801D09C4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801D09C4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801D09C4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018F4E0[])(void); - -void func_80163A58(void *a0) { - D_8018F4E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801D09CC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801D09CC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018F534[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018F534[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018F4FC; -extern s16 D_8018F530; -extern s16 D_8018F52E; -extern s16 D_8018F52C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018F4FC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018F530 = 0x80; - D_8018F52E = 0x80; - D_8018F52C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018F530 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018F530` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018F530 - 8; - D_8018F530 = nv; - D_8018F52E = nv; - D_8018F52C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018F540[])(void); - -void func_80164BA0(void *a0) { - D_8018F540[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801D1210; -extern u8 D_801D1211; -extern u8 D_801D1212; -extern u8 D_801D1213; -extern u8 D_801D1214; -extern u8 D_801D1215; -extern u8 D_801D1216; -extern u8 D_801D1217; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801D1210; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801D1211 = 0xf0; - *(u8 *)base = 0xf0; - D_801D1212 = 0xc0; - D_801D1216 = 0; - D_801D1215 = 0; - D_801D1214 = 0; - D_801D1217 = 0; - D_801D1213 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801D1210; -extern u8 D_801D1211; -extern u8 D_801D1212; - -s32 func_80164E40(void) { - u8 *p = &D_801D1210; - if (*p != 0) { - *p -= 0x10; - } - if (D_801D1211 != 0) { - D_801D1211 -= 0x10; - } - if (D_801D1212 != 0) { - D_801D1212 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018F550[])(void); - -void func_80164EA4(void *a0) { - D_8018F550[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801D125C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801D125C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801D1250[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801D1250[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801D1250[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801D1250; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801D1250; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018F564[]; - extern u32 D_8018F584, D_8018F588, D_8018F58C, D_8018F590; - extern u32 D_8018F584, D_8018F588, D_8018F58C, D_8018F590; - extern u32 D_8018F584, D_8018F588, D_8018F58C, D_8018F590; - extern u32 D_8018F584, D_8018F588, D_8018F58C, D_8018F590; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018F564[0x00], p); - ApplyMatrixSV(mat, &D_8018F564[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018F564[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018F564[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018F58C; - *(u32 *)(prim + 0x24) = D_8018F584; - *(u32 *)(prim + 0x28) = D_8018F590; - *(u32 *)(prim + 0x2c) = D_8018F588; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018F594[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018F594[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018F594[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018F594[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018F610[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018F610[a1 & 0x7F]; -} - - - -extern s32 D_8018F630[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018F630[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018F6AC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018F6AC[a1 & 0x7F]; -} - - - -extern u8 D_8018F6CC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018F6CC[a1 & 0x7F]; -} - - - -extern u8 D_8018F6EC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018F6EC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018F70C[])(void); - D_8018F70C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018F788[])(void); - -void func_80165AC8(void) { - D_8018F788[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018F804[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018F804[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801D09D4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801D09D4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018F810[])(void); - -void func_80166018(void *a0) { - D_8018F810[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018F818[])(void); - -void func_801663FC(void *a0) { - D_8018F818[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018F8E0[])(void); - -void func_80166618(void *a0) { - D_8018F8E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018F8F0[])(void); - -void func_80166654(void *a0) { - D_8018F8F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801D12D0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801D12D0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D12D0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801D12D0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801D12D0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801D12D0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801D12D0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018F834[]; - extern u8 D_8018F820[]; - extern u8 D_8018F848[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018F834; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018F820; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018F848; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80167714); - - -extern void (*D_8018F900[])(void); - -void func_801678B4(void *a0) { - D_8018F900[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018F90C[])(void); - -void func_80167A9C(void *a0) { - D_8018F90C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018FA18; - extern u8 D_8018FA2C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018FA18); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018FA2C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018F86C[]; -extern u8 D_8018F880[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018F86C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018F880; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018F924[])(void); - -void func_80168744(void *a0) { - D_8018F924[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018F914 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018F914[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018F914; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018F92C[])(void); - -void func_801689D8(void *a0) { - D_8018F92C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018F934[])(void); - -void func_80168AA8(void *a0) { - D_8018F934[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018F93C[])(void); - -void func_80168D58(void *a0) { - D_8018F93C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018F944[])(void); - -void func_8016901C(void *a0) { - D_8018F944[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015AE2C", func_80169228); - - -extern void (*D_8018F94C[])(void); - -void func_801693CC(void *a0) { - D_8018F94C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018F954[])(void); - -void func_80169830(void *a0) { - D_8018F954[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018FA08[])(void); - -void func_80169B80(void *a0) { - D_8018FA08[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018F95C[]; - extern u8 D_8018F9CC[]; - extern u8 D_8018F9FC[]; - extern u8 D_801D2598[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018F9FC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018F95C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801D2598; - RotMatrixYXZ(rot, D_801D2598); - func_80048D9C(D_801D2598, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018F9CC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018FA10[])(void); - -void func_80169F00(void *a0) { - D_8018FA10[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018F9C0[]; -extern char D_8018F980[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018F9C0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018F980); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018FA48[])(void); - -void func_8016A020(void *a0) { - D_8018FA48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018FA18; - extern u8 D_8018FA2C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018FA18); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018FA2C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018FA54[])(void); - -void func_8016A700(void *a0) { - D_8018FA54[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018FA9C[])(void); - -void func_8016AB30(void *a0) { - D_8018FA9C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c b/src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c new file mode 100644 index 000000000..42def88fa --- /dev/null +++ b/src/ov_SC03_091/ov_SC03_091_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018EE68; +extern u8 D_8018EDD8; +extern u8 D_8018EDB4; +extern u8 D_8018ED90; +extern u8 D_8018EE44; +extern u8 D_8018EE20; +extern u8 D_8018EDFC; +extern u8 D_8018ED6C; +extern void func_80145934(void); +extern u8 D_8018EEF8; +extern u8 D_8018EED4; +extern u8 D_8018EEB0; +extern u8 D_8018EE8C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018E2F0[]; +extern unsigned char D_8018E320[]; +extern unsigned char D_8018E370[]; +extern unsigned char D_8018E3A0[]; +extern unsigned char D_8018E3D0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018E420[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018E4E8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018E570[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018E578; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801D1100; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801D1104; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018E5A8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018E650[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018E674[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018E664; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018E688[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018E694[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018E6A4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018E6BC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018E6AC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018E6D0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018E6EC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018E6DC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018E700[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018E714[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018E728; +extern void (*D_8018E750[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018E730; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018E79C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018E7A0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018EC04[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018EC14[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801D1138; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018EC3C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018EC1C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018EC2C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018EC7C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018EC84[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018EC50; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018EC90[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018EC60; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801D1140; +extern s32 D_801D114C; +extern s32 D_801D1150; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018ECCC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018ECA0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801D1148; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018EF1C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018ED3C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018EFC0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018F114[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018EF30; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018F11C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018EF40; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018EF60; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018F124[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018F14C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018EFCC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018F158[])(void); + +void func_8015C714(void *a0) { + D_8018F158[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018EFCC[])(void*); + extern int D_8018EF70; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018EF70); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018EFCC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018EFCC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018EFCC[])(void*); + extern int D_8018EF70; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018EF70); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018F168[])(void); + D_8018F168[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018EFCC[])(struct Ent_8015CD20 *); + extern u8 D_8018EF80; + extern u8 D_8018F170; + extern u8 D_8018F180; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018EFCC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018EF80); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F170); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F180); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018EFCC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018F1A0[])(void); + D_8018F1A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018F190; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018F190 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018EFCC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018F1FC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018F1FC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018E2E0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018E2E0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018F204[])(void); + D_8018F204[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018F210[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018F210[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018F210[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018F210[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018EFCC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018F210[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018EF90[]; + extern u8 D_8018EFA0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018EF90); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018EFA0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018F210[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018F210[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018F210[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018F244[])(void); + D_8018F244[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018EFCC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018F24C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018F264[])(void); + D_8018F264[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018EFCC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018F24C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018F24C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018F284[])(void); + D_8018F284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018EFCC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018EFCC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018F294; +extern u16 D_8018F296; +extern u16 D_8018F298; +extern s32 D_8018F29C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018F294 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018F296 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018F298 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018F29C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018F2A4; + +void func_8015E588(void) { + func_8013C9C4(&D_8018F2A4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018EFCC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018EFCC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018F2B8[])(void); + D_8018F2B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018EFCC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018EFCC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018F2C0[])(void); + D_8018F2C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018EFB0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018EFB0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018EFCC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018F2C8[])(void); + D_8018F2C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018EFCC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018EFCC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018F2D0[])(void); + D_8018F2D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018EFCC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018F2D8; + extern s32 D_8018F2E8; + extern s32 D_8018F2F8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018F2D8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018F2E8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018EFCC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018F2F8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018F308[])(void); + D_8018F308[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018EFCC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018EFCC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018EFCC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018EFCC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018F314[])(void); + D_8018F314[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018EFCC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018EFCC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018EFCC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018EFCC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018F328[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018F328[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018EFCC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018EFCC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018EFCC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018EFCC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018F3A4[])(void); + D_8018F3A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018EFCC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018EFCC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018F3B4[])(void); + D_8018F3B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018EFCC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018EFCC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018EFCC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018EFCC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018EFCC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018EFCC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018EFCC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018F3BC[])(void); + D_8018F3BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018EFCC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018EFCC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018EFCC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018EFCC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018F3C8[])(void); + D_8018F3C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018EFCC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018EFCC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018EFCC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018EFCC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018F3D8[])(void); + +void func_80160EA4(void *a0) { + D_8018F3D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018EFCC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018EFCC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018F408[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018F408[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018F46C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018F46C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801D1158[]; + extern u8 D_8018F438[]; + extern u8 D_8018F458[]; + extern u8 D_801D1164[]; + extern u8 D_801D118C[]; + extern u8 D_801D11A4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801D1158[0] = p; + func_80024054(&D_8018F438, &D_801D1164); + func_8001CE28(p, &D_801D1164); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801D1158[1] = p; + func_80024054(&D_8018F458, &D_801D118C); + func_8001CE28(p, &D_801D118C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801D1158[2] = p; + func_800242D0((s16)func_801620C4(), &D_801D11A4, 0x84); + func_8001CE68(p, &D_801D11A4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801D11A4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D1158[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801D1158; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018F46C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018F46C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018F46C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018F46C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801D1158[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801D1158; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018F490[])(void); + +void func_80162330(void *a0) { + D_8018F490[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801D11B0[i] via `extern int D_801D11B0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018F49C[]; + extern s32 D_8018F4B4; + extern u8 D_801D11BC[]; + extern u8 D_801D11E4[]; + extern u8 D_801D1200[]; + extern int D_801D11B0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801D11B0[0] = (s32)item; + func_80024054(D_8018F49C, D_801D11BC); + func_8001CE28(item, D_801D11BC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801D11B0[1] = (s32)item; + func_80024054(((u8 *)&D_8018F4B4), D_801D11E4); + func_8001CE28(item, D_801D11E4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801D11B0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801D1200, 0x84); + func_8001CE68(item, D_801D1200); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801D1200, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D11B0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801D11B0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_801627E8); + + +extern void (*D_8018F4D8[])(void); + +void func_80162834(void *a0) { + D_8018F4D8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018F4C8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018F4C8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801D09C4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801D09C4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801D09C4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801D09C4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018F4E0[])(void); + +void func_80163A58(void *a0) { + D_8018F4E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801D09CC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801D09CC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018F534[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018F534[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018F4FC; +extern s16 D_8018F530; +extern s16 D_8018F52E; +extern s16 D_8018F52C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018F4FC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018F530 = 0x80; + D_8018F52E = 0x80; + D_8018F52C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018F530 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018F530` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018F530 - 8; + D_8018F530 = nv; + D_8018F52E = nv; + D_8018F52C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018F540[])(void); + +void func_80164BA0(void *a0) { + D_8018F540[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801D1210; +extern u8 D_801D1211; +extern u8 D_801D1212; +extern u8 D_801D1213; +extern u8 D_801D1214; +extern u8 D_801D1215; +extern u8 D_801D1216; +extern u8 D_801D1217; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801D1210; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801D1211 = 0xf0; + *(u8 *)base = 0xf0; + D_801D1212 = 0xc0; + D_801D1216 = 0; + D_801D1215 = 0; + D_801D1214 = 0; + D_801D1217 = 0; + D_801D1213 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801D1210; +extern u8 D_801D1211; +extern u8 D_801D1212; + +s32 func_80164E40(void) { + u8 *p = &D_801D1210; + if (*p != 0) { + *p -= 0x10; + } + if (D_801D1211 != 0) { + D_801D1211 -= 0x10; + } + if (D_801D1212 != 0) { + D_801D1212 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018F550[])(void); + +void func_80164EA4(void *a0) { + D_8018F550[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801D125C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801D125C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801D1250[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801D1250[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801D1250[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801D1250; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801D1250; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018F564[]; + extern u32 D_8018F584, D_8018F588, D_8018F58C, D_8018F590; + extern u32 D_8018F584, D_8018F588, D_8018F58C, D_8018F590; + extern u32 D_8018F584, D_8018F588, D_8018F58C, D_8018F590; + extern u32 D_8018F584, D_8018F588, D_8018F58C, D_8018F590; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018F564[0x00], p); + ApplyMatrixSV(mat, &D_8018F564[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018F564[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018F564[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018F58C; + *(u32 *)(prim + 0x24) = D_8018F584; + *(u32 *)(prim + 0x28) = D_8018F590; + *(u32 *)(prim + 0x2c) = D_8018F588; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018F594[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018F594[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018F594[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018F594[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018F610[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018F610[a1 & 0x7F]; +} + + + +extern s32 D_8018F630[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018F630[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018F6AC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018F6AC[a1 & 0x7F]; +} + + + +extern u8 D_8018F6CC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018F6CC[a1 & 0x7F]; +} + + + +extern u8 D_8018F6EC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018F6EC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018F70C[])(void); + D_8018F70C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018F788[])(void); + +void func_80165AC8(void) { + D_8018F788[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018F804[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018F804[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801D09D4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801D09D4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018F810[])(void); + +void func_80166018(void *a0) { + D_8018F810[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018F818[])(void); + +void func_801663FC(void *a0) { + D_8018F818[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018F8E0[])(void); + +void func_80166618(void *a0) { + D_8018F8E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018F8F0[])(void); + +void func_80166654(void *a0) { + D_8018F8F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801D12D0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801D12D0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D12D0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801D12D0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801D12D0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801D12D0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801D12D0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018F834[]; + extern u8 D_8018F820[]; + extern u8 D_8018F848[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018F834; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018F820; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018F848; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80167714); + + +extern void (*D_8018F900[])(void); + +void func_801678B4(void *a0) { + D_8018F900[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018F90C[])(void); + +void func_80167A9C(void *a0) { + D_8018F90C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018FA18; + extern u8 D_8018FA2C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018FA18); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018FA2C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018F86C[]; +extern u8 D_8018F880[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018F86C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018F880; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018F924[])(void); + +void func_80168744(void *a0) { + D_8018F924[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018F914 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018F914[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018F914; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018F92C[])(void); + +void func_801689D8(void *a0) { + D_8018F92C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018F934[])(void); + +void func_80168AA8(void *a0) { + D_8018F934[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018F93C[])(void); + +void func_80168D58(void *a0) { + D_8018F93C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018F944[])(void); + +void func_8016901C(void *a0) { + D_8018F944[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_091/nonmatchings/ov_SC03_091_jr_8015C32C", func_80169228); + + +extern void (*D_8018F94C[])(void); + +void func_801693CC(void *a0) { + D_8018F94C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018F954[])(void); + +void func_80169830(void *a0) { + D_8018F954[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018FA08[])(void); + +void func_80169B80(void *a0) { + D_8018FA08[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018F95C[]; + extern u8 D_8018F9CC[]; + extern u8 D_8018F9FC[]; + extern u8 D_801D2598[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018F9FC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018F95C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801D2598; + RotMatrixYXZ(rot, D_801D2598); + func_80048D9C(D_801D2598, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018F9CC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018FA10[])(void); + +void func_80169F00(void *a0) { + D_8018FA10[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018F9C0[]; +extern char D_8018F980[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018F9C0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018F980); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018FA48[])(void); + +void func_8016A020(void *a0) { + D_8018FA48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018FA18; + extern u8 D_8018FA2C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018FA18); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018FA2C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018FA54[])(void); + +void func_8016A700(void *a0) { + D_8018FA54[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018FA9C[])(void); + +void func_8016AB30(void *a0) { + D_8018FA9C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_092/ov_SC03_092_jr_8015AE2C.c b/src/ov_SC03_092/ov_SC03_092_jr_8015AE2C.c index e3be6fd46..a818aa606 100644 --- a/src/ov_SC03_092/ov_SC03_092_jr_8015AE2C.c +++ b/src/ov_SC03_092/ov_SC03_092_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80187528[])(void); - -void func_8015C714(void *a0) { - D_80187528[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018739C[])(void*); - extern int D_80187340; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018739C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018739C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187340); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018739C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018739C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018739C[])(void*); - extern int D_80187340; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018739C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187340); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018739C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80187538[])(void); - D_80187538[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018739C[])(struct Ent_8015CD20 *); - extern u8 D_80187350; - extern u8 D_80187540; - extern u8 D_80187550; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018739C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187350); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187540); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187550); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018739C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80187570[])(void); - D_80187570[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80187560; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80187560 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018739C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801875CC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801875CC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801866B0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801866B0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801875D4[])(void); - D_801875D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801875E0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801875E0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801875E0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801875E0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018739C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801875E0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80187360[]; - extern u8 D_80187370[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187360); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187370); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801875E0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801875E0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801875E0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80187614[])(void); - D_80187614[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018739C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018761C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80187634[])(void); - D_80187634[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018739C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018761C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80187654[])(void); - D_80187654[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018739C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018739C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80187664; -extern u16 D_80187666; -extern u16 D_80187668; -extern s32 D_8018766C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80187664 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80187666 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187668 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018766C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80187674; - -void func_8015E588(void) { - func_8013C9C4(&D_80187674); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018739C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018739C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80187688[])(void); - D_80187688[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018739C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018739C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80187690[])(void); - D_80187690[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80187380; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187380); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018739C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187698[])(void); - D_80187698[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018739C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018739C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801876A0[])(void); - D_801876A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018739C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801876A8; - extern s32 D_801876B8; - extern s32 D_801876C8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018739C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801876A8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801876B8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018739C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801876C8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801876D8[])(void); - D_801876D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018739C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018739C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018739C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018739C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801876E4[])(void); - D_801876E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018739C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018739C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018739C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018739C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801876F8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801876F8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018739C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018739C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018739C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018739C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80187774[])(void); - D_80187774[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018739C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018739C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80187784[])(void); - D_80187784[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018739C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018739C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018739C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018739C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018739C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018739C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018739C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018778C[])(void); - D_8018778C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018739C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018739C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018739C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018739C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187798[])(void); - D_80187798[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018739C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018739C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018739C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018739C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801877A8[])(void); - -void func_80160EA4(void *a0) { - D_801877A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018739C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018739C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801877D8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801877D8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018783C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018783C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B1D20[]; - extern u8 D_80187808[]; - extern u8 D_80187828[]; - extern u8 D_801B1D2C[]; - extern u8 D_801B1D54[]; - extern u8 D_801B1D6C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B1D20[0] = p; - func_80024054(&D_80187808, &D_801B1D2C); - func_8001CE28(p, &D_801B1D2C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B1D20[1] = p; - func_80024054(&D_80187828, &D_801B1D54); - func_8001CE28(p, &D_801B1D54); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B1D20[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B1D6C, 0x84); - func_8001CE68(p, &D_801B1D6C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B1D6C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B1D20[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B1D20; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018783C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018783C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018783C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018783C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B1D20[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B1D20; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80187860[])(void); - -void func_80162330(void *a0) { - D_80187860[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B1D78[i] via `extern int D_801B1D78[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018786C[]; - extern s32 D_80187884; - extern u8 D_801B1D84[]; - extern u8 D_801B1DAC[]; - extern u8 D_801B1DC8[]; - extern int D_801B1D78[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B1D78[0] = (s32)item; - func_80024054(D_8018786C, D_801B1D84); - func_8001CE28(item, D_801B1D84); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B1D78[1] = (s32)item; - func_80024054(((u8 *)&D_80187884), D_801B1DAC); - func_8001CE28(item, D_801B1DAC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B1D78[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B1DC8, 0x84); - func_8001CE68(item, D_801B1DC8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B1DC8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B1D78[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B1D78; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_801627E8); - - -extern void (*D_801878A8[])(void); - -void func_80162834(void *a0) { - D_801878A8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187898; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187898, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B159C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B159C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B159C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B159C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801878B0[])(void); - -void func_80163A58(void *a0) { - D_801878B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B15A4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B15A4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80187904[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80187904[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801878CC; -extern s16 D_80187900; -extern s16 D_801878FE; -extern s16 D_801878FC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801878CC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80187900 = 0x80; - D_801878FE = 0x80; - D_801878FC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80187900 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187900` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80187900 - 8; - D_80187900 = nv; - D_801878FE = nv; - D_801878FC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80187910[])(void); - -void func_80164BA0(void *a0) { - D_80187910[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B1DD8; -extern u8 D_801B1DD9; -extern u8 D_801B1DDA; -extern u8 D_801B1DDB; -extern u8 D_801B1DDC; -extern u8 D_801B1DDD; -extern u8 D_801B1DDE; -extern u8 D_801B1DDF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B1DD8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B1DD9 = 0xf0; - *(u8 *)base = 0xf0; - D_801B1DDA = 0xc0; - D_801B1DDE = 0; - D_801B1DDD = 0; - D_801B1DDC = 0; - D_801B1DDF = 0; - D_801B1DDB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B1DD8; -extern u8 D_801B1DD9; -extern u8 D_801B1DDA; - -s32 func_80164E40(void) { - u8 *p = &D_801B1DD8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B1DD9 != 0) { - D_801B1DD9 -= 0x10; - } - if (D_801B1DDA != 0) { - D_801B1DDA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80187920[])(void); - -void func_80164EA4(void *a0) { - D_80187920[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B1E24[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B1E24[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B1E18[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B1E18[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B1E18[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B1E18; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B1E18; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80187934[]; - extern u32 D_80187954, D_80187958, D_8018795C, D_80187960; - extern u32 D_80187954, D_80187958, D_8018795C, D_80187960; - extern u32 D_80187954, D_80187958, D_8018795C, D_80187960; - extern u32 D_80187954, D_80187958, D_8018795C, D_80187960; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80187934[0x00], p); - ApplyMatrixSV(mat, &D_80187934[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80187934[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80187934[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018795C; - *(u32 *)(prim + 0x24) = D_80187954; - *(u32 *)(prim + 0x28) = D_80187960; - *(u32 *)(prim + 0x2c) = D_80187958; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187964[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187964[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187964[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187964[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801879E0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801879E0[a1 & 0x7F]; -} - - - -extern s32 D_80187A00[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80187A00[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80187A7C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80187A7C[a1 & 0x7F]; -} - - - -extern u8 D_80187A9C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80187A9C[a1 & 0x7F]; -} - - - -extern u8 D_80187ABC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80187ABC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80187ADC[])(void); - D_80187ADC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187B58[])(void); - -void func_80165AC8(void) { - D_80187B58[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80187BD4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80187BD4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B15AC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B15AC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80187BE0[])(void); - -void func_80166018(void *a0) { - D_80187BE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80187BE8[])(void); - -void func_801663FC(void *a0) { - D_80187BE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80187CB0[])(void); - -void func_80166618(void *a0) { - D_80187CB0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80187CC0[])(void); - -void func_80166654(void *a0) { - D_80187CC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B1E98[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B1E98[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B1E98). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B1E98[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B1E98)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B1E98[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B1E98[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80187C04[]; - extern u8 D_80187BF0[]; - extern u8 D_80187C18[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80187C04; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80187BF0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187C18; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80167714); - - -extern void (*D_80187CD0[])(void); - -void func_801678B4(void *a0) { - D_80187CD0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80187CDC[])(void); - -void func_80167A9C(void *a0) { - D_80187CDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80187DE8; - extern u8 D_80187DFC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80187DE8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187DFC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80187C3C[]; -extern u8 D_80187C50[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80187C3C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187C50; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80187CF4[])(void); - -void func_80168744(void *a0) { - D_80187CF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80187CE4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80187CE4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80187CE4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80187CFC[])(void); - -void func_801689D8(void *a0) { - D_80187CFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80187D04[])(void); - -void func_80168AA8(void *a0) { - D_80187D04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80187D0C[])(void); - -void func_80168D58(void *a0) { - D_80187D0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80187D14[])(void); - -void func_8016901C(void *a0) { - D_80187D14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015AE2C", func_80169228); - - -extern void (*D_80187D1C[])(void); - -void func_801693CC(void *a0) { - D_80187D1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80187D24[])(void); - -void func_80169830(void *a0) { - D_80187D24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187DD8[])(void); - -void func_80169B80(void *a0) { - D_80187DD8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80187D2C[]; - extern u8 D_80187D9C[]; - extern u8 D_80187DCC[]; - extern u8 D_801B2F40[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80187DCC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80187D2C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B2F40; - RotMatrixYXZ(rot, D_801B2F40); - func_80048D9C(D_801B2F40, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80187D9C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80187DE0[])(void); - -void func_80169F00(void *a0) { - D_80187DE0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80187D90[]; -extern char D_80187D50[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80187D90, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187D50); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187E18[])(void); - -void func_8016A020(void *a0) { - D_80187E18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80187DE8; - extern u8 D_80187DFC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80187DE8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187DFC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80187E24[])(void); - -void func_8016A700(void *a0) { - D_80187E24[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80187E6C[])(void); - -void func_8016AB30(void *a0) { - D_80187E6C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c b/src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c new file mode 100644 index 000000000..1ec9e2ba0 --- /dev/null +++ b/src/ov_SC03_092/ov_SC03_092_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80187238; +extern u8 D_801871A8; +extern u8 D_80187184; +extern u8 D_80187160; +extern u8 D_80187214; +extern u8 D_801871F0; +extern u8 D_801871CC; +extern u8 D_8018713C; +extern void func_80145934(void); +extern u8 D_801872C8; +extern u8 D_801872A4; +extern u8 D_80187280; +extern u8 D_8018725C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801866C0[]; +extern unsigned char D_801866F0[]; +extern unsigned char D_80186740[]; +extern unsigned char D_80186770[]; +extern unsigned char D_801867A0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801867F0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801868B8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80186940[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186948; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B1CC8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B1CCC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186978; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80186A20[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80186A44[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80186A34; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186A58[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80186A64[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80186A74[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80186A8C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80186A7C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80186AA0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80186ABC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80186AAC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80186AD0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80186AE4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80186AF8; +extern void (*D_80186B20[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80186B00; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80186B6C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80186B70[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186FD4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80186FE4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B1D00; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018700C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80186FEC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80186FFC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018704C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80187054[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80187020; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80187060[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80187030; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B1D08; +extern s32 D_801B1D14; +extern s32 D_801B1D18; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018709C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80187070[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B1D10; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801872EC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018710C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80187390[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801874E4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80187300; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801874EC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80187310; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80187330; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801874F4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018751C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018739C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80187528[])(void); + +void func_8015C714(void *a0) { + D_80187528[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018739C[])(void*); + extern int D_80187340; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018739C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018739C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187340); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018739C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018739C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018739C[])(void*); + extern int D_80187340; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018739C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187340); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018739C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80187538[])(void); + D_80187538[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018739C[])(struct Ent_8015CD20 *); + extern u8 D_80187350; + extern u8 D_80187540; + extern u8 D_80187550; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018739C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187350); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187540); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187550); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018739C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80187570[])(void); + D_80187570[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80187560; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80187560 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018739C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801875CC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801875CC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801866B0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801866B0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801875D4[])(void); + D_801875D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801875E0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801875E0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801875E0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801875E0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018739C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801875E0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80187360[]; + extern u8 D_80187370[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187360); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187370); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801875E0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801875E0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801875E0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80187614[])(void); + D_80187614[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018739C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018761C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80187634[])(void); + D_80187634[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018739C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018761C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018761C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80187654[])(void); + D_80187654[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018739C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018739C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80187664; +extern u16 D_80187666; +extern u16 D_80187668; +extern s32 D_8018766C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80187664 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80187666 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187668 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018766C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80187674; + +void func_8015E588(void) { + func_8013C9C4(&D_80187674); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018739C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018739C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80187688[])(void); + D_80187688[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018739C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018739C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80187690[])(void); + D_80187690[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80187380; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187380); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018739C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187698[])(void); + D_80187698[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018739C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018739C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801876A0[])(void); + D_801876A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018739C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801876A8; + extern s32 D_801876B8; + extern s32 D_801876C8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801876A8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801876B8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018739C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801876C8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801876D8[])(void); + D_801876D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018739C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018739C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018739C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018739C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801876E4[])(void); + D_801876E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018739C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018739C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018739C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018739C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801876F8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801876F8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018739C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018739C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018739C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018739C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80187774[])(void); + D_80187774[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018739C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018739C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80187784[])(void); + D_80187784[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018739C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018739C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018739C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018739C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018739C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018739C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018739C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018778C[])(void); + D_8018778C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018739C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018739C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018739C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018739C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187798[])(void); + D_80187798[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018739C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018739C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018739C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018739C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801877A8[])(void); + +void func_80160EA4(void *a0) { + D_801877A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018739C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018739C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801877D8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801877D8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018783C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018783C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B1D20[]; + extern u8 D_80187808[]; + extern u8 D_80187828[]; + extern u8 D_801B1D2C[]; + extern u8 D_801B1D54[]; + extern u8 D_801B1D6C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B1D20[0] = p; + func_80024054(&D_80187808, &D_801B1D2C); + func_8001CE28(p, &D_801B1D2C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B1D20[1] = p; + func_80024054(&D_80187828, &D_801B1D54); + func_8001CE28(p, &D_801B1D54); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B1D20[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B1D6C, 0x84); + func_8001CE68(p, &D_801B1D6C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B1D6C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B1D20[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B1D20; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018783C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018783C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018783C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018783C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B1D20[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B1D20; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80187860[])(void); + +void func_80162330(void *a0) { + D_80187860[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B1D78[i] via `extern int D_801B1D78[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018786C[]; + extern s32 D_80187884; + extern u8 D_801B1D84[]; + extern u8 D_801B1DAC[]; + extern u8 D_801B1DC8[]; + extern int D_801B1D78[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B1D78[0] = (s32)item; + func_80024054(D_8018786C, D_801B1D84); + func_8001CE28(item, D_801B1D84); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B1D78[1] = (s32)item; + func_80024054(((u8 *)&D_80187884), D_801B1DAC); + func_8001CE28(item, D_801B1DAC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B1D78[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B1DC8, 0x84); + func_8001CE68(item, D_801B1DC8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B1DC8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B1D78[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B1D78; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_801627E8); + + +extern void (*D_801878A8[])(void); + +void func_80162834(void *a0) { + D_801878A8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187898; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187898, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B159C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B159C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B159C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B159C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801878B0[])(void); + +void func_80163A58(void *a0) { + D_801878B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B15A4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B15A4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80187904[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80187904[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801878CC; +extern s16 D_80187900; +extern s16 D_801878FE; +extern s16 D_801878FC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801878CC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80187900 = 0x80; + D_801878FE = 0x80; + D_801878FC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80187900 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187900` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80187900 - 8; + D_80187900 = nv; + D_801878FE = nv; + D_801878FC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80187910[])(void); + +void func_80164BA0(void *a0) { + D_80187910[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B1DD8; +extern u8 D_801B1DD9; +extern u8 D_801B1DDA; +extern u8 D_801B1DDB; +extern u8 D_801B1DDC; +extern u8 D_801B1DDD; +extern u8 D_801B1DDE; +extern u8 D_801B1DDF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B1DD8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B1DD9 = 0xf0; + *(u8 *)base = 0xf0; + D_801B1DDA = 0xc0; + D_801B1DDE = 0; + D_801B1DDD = 0; + D_801B1DDC = 0; + D_801B1DDF = 0; + D_801B1DDB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B1DD8; +extern u8 D_801B1DD9; +extern u8 D_801B1DDA; + +s32 func_80164E40(void) { + u8 *p = &D_801B1DD8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B1DD9 != 0) { + D_801B1DD9 -= 0x10; + } + if (D_801B1DDA != 0) { + D_801B1DDA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80187920[])(void); + +void func_80164EA4(void *a0) { + D_80187920[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B1E24[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B1E24[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B1E18[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B1E18[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B1E18[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B1E18; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B1E18; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80187934[]; + extern u32 D_80187954, D_80187958, D_8018795C, D_80187960; + extern u32 D_80187954, D_80187958, D_8018795C, D_80187960; + extern u32 D_80187954, D_80187958, D_8018795C, D_80187960; + extern u32 D_80187954, D_80187958, D_8018795C, D_80187960; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80187934[0x00], p); + ApplyMatrixSV(mat, &D_80187934[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80187934[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80187934[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018795C; + *(u32 *)(prim + 0x24) = D_80187954; + *(u32 *)(prim + 0x28) = D_80187960; + *(u32 *)(prim + 0x2c) = D_80187958; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187964[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187964[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187964[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187964[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801879E0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801879E0[a1 & 0x7F]; +} + + + +extern s32 D_80187A00[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80187A00[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80187A7C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80187A7C[a1 & 0x7F]; +} + + + +extern u8 D_80187A9C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80187A9C[a1 & 0x7F]; +} + + + +extern u8 D_80187ABC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80187ABC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80187ADC[])(void); + D_80187ADC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187B58[])(void); + +void func_80165AC8(void) { + D_80187B58[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80187BD4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80187BD4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B15AC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B15AC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80187BE0[])(void); + +void func_80166018(void *a0) { + D_80187BE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80187BE8[])(void); + +void func_801663FC(void *a0) { + D_80187BE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80187CB0[])(void); + +void func_80166618(void *a0) { + D_80187CB0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80187CC0[])(void); + +void func_80166654(void *a0) { + D_80187CC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B1E98[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B1E98[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B1E98). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B1E98[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B1E98)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B1E98[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B1E98[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80187C04[]; + extern u8 D_80187BF0[]; + extern u8 D_80187C18[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80187C04; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80187BF0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187C18; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80167714); + + +extern void (*D_80187CD0[])(void); + +void func_801678B4(void *a0) { + D_80187CD0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80187CDC[])(void); + +void func_80167A9C(void *a0) { + D_80187CDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80187DE8; + extern u8 D_80187DFC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80187DE8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187DFC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80187C3C[]; +extern u8 D_80187C50[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80187C3C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187C50; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80187CF4[])(void); + +void func_80168744(void *a0) { + D_80187CF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80187CE4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80187CE4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80187CE4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80187CFC[])(void); + +void func_801689D8(void *a0) { + D_80187CFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80187D04[])(void); + +void func_80168AA8(void *a0) { + D_80187D04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80187D0C[])(void); + +void func_80168D58(void *a0) { + D_80187D0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80187D14[])(void); + +void func_8016901C(void *a0) { + D_80187D14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_092/nonmatchings/ov_SC03_092_jr_8015C32C", func_80169228); + + +extern void (*D_80187D1C[])(void); + +void func_801693CC(void *a0) { + D_80187D1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80187D24[])(void); + +void func_80169830(void *a0) { + D_80187D24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187DD8[])(void); + +void func_80169B80(void *a0) { + D_80187DD8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80187D2C[]; + extern u8 D_80187D9C[]; + extern u8 D_80187DCC[]; + extern u8 D_801B2F40[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80187DCC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80187D2C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B2F40; + RotMatrixYXZ(rot, D_801B2F40); + func_80048D9C(D_801B2F40, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80187D9C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80187DE0[])(void); + +void func_80169F00(void *a0) { + D_80187DE0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80187D90[]; +extern char D_80187D50[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80187D90, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187D50); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187E18[])(void); + +void func_8016A020(void *a0) { + D_80187E18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80187DE8; + extern u8 D_80187DFC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80187DE8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187DFC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80187E24[])(void); + +void func_8016A700(void *a0) { + D_80187E24[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80187E6C[])(void); + +void func_8016AB30(void *a0) { + D_80187E6C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_093/ov_SC03_093_jr_8015AE2C.c b/src/ov_SC03_093/ov_SC03_093_jr_8015AE2C.c index 74043f649..76654ec7a 100644 --- a/src/ov_SC03_093/ov_SC03_093_jr_8015AE2C.c +++ b/src/ov_SC03_093/ov_SC03_093_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80188700[])(void); - -void func_8015C714(void *a0) { - D_80188700[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80188574[])(void*); - extern int D_80188518; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80188574)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80188574)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188518); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80188574[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80188574[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80188574[])(void*); - extern int D_80188518; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80188574)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188518); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80188574)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80188710[])(void); - D_80188710[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80188574[])(struct Ent_8015CD20 *); - extern u8 D_80188528; - extern u8 D_80188718; - extern u8 D_80188728; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80188574[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188528); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188718); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188728); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80188574[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80188748[])(void); - D_80188748[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80188738; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80188738 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80188574[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801887A4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801887A4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80187888[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80187888; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801887AC[])(void); - D_801887AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801887B8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801887B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801887B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801887B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80188574[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801887B8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80188538[]; - extern u8 D_80188548[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188538); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188548); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801887B8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801887B8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801887B8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801887EC[])(void); - D_801887EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188574[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801887F4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018880C[])(void); - D_8018880C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188574[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801887F4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018882C[])(void); - D_8018882C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80188574[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188574)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018883C; -extern u16 D_8018883E; -extern u16 D_80188840; -extern s32 D_80188844; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018883C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018883E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80188840 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188844, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018884C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018884C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80188574[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188574)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80188860[])(void); - D_80188860[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80188574[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80188574[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80188868[])(void); - D_80188868[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80188558; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188558); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80188574[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80188870[])(void); - D_80188870[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80188574[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80188574[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80188878[])(void); - D_80188878[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80188574[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80188880; - extern s32 D_80188890; - extern s32 D_801888A0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80188574[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188880); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188890); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80188574[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801888A0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801888B0[])(void); - D_801888B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80188574[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80188574[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80188574[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188574[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801888BC[])(void); - D_801888BC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80188574[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188574[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80188574[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188574[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801888D0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801888D0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80188574[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80188574)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80188574[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188574[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018894C[])(void); - D_8018894C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80188574[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80188574)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018895C[])(void); - D_8018895C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80188574[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80188574[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80188574[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80188574[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80188574[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80188574[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80188574[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80188964[])(void); - D_80188964[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80188574[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80188574)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80188574[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80188574)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80188970[])(void); - D_80188970[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188574 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80188574[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80188574[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80188574[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80188980[])(void); - -void func_80160EA4(void *a0) { - D_80188980[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80188574[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80188574[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801889B0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801889B0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80188A14; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80188A14); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801CB190[]; - extern u8 D_801889E0[]; - extern u8 D_80188A00[]; - extern u8 D_801CB19C[]; - extern u8 D_801CB1C4[]; - extern u8 D_801CB1DC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801CB190[0] = p; - func_80024054(&D_801889E0, &D_801CB19C); - func_8001CE28(p, &D_801CB19C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801CB190[1] = p; - func_80024054(&D_80188A00, &D_801CB1C4); - func_8001CE28(p, &D_801CB1C4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801CB190[2] = p; - func_800242D0((s16)func_801620C4(), &D_801CB1DC, 0x84); - func_8001CE68(p, &D_801CB1DC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801CB1DC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CB190[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801CB190; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80188A14; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80188A14; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80188A14; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80188A14; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801CB190[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801CB190; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80188A38[])(void); - -void func_80162330(void *a0) { - D_80188A38[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801CB1E8[i] via `extern int D_801CB1E8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80188A44[]; - extern s32 D_80188A5C; - extern u8 D_801CB1F4[]; - extern u8 D_801CB21C[]; - extern u8 D_801CB238[]; - extern int D_801CB1E8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801CB1E8[0] = (s32)item; - func_80024054(D_80188A44, D_801CB1F4); - func_8001CE28(item, D_801CB1F4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801CB1E8[1] = (s32)item; - func_80024054(((u8 *)&D_80188A5C), D_801CB21C); - func_8001CE28(item, D_801CB21C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801CB1E8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801CB238, 0x84); - func_8001CE68(item, D_801CB238); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801CB238, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CB1E8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801CB1E8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_801627E8); - - -extern void (*D_80188A80[])(void); - -void func_80162834(void *a0) { - D_80188A80[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80188A70; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80188A70, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801CA9F0[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801CA9F0, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801CA9F0[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801CA9F0, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80188A88[])(void); - -void func_80163A58(void *a0) { - D_80188A88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801CA9F8; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801CA9F8; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80188ADC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80188ADC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80188AA4; -extern s16 D_80188AD8; -extern s16 D_80188AD6; -extern s16 D_80188AD4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80188AA4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80188AD8 = 0x80; - D_80188AD6 = 0x80; - D_80188AD4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80188AD8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188AD8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80188AD8 - 8; - D_80188AD8 = nv; - D_80188AD6 = nv; - D_80188AD4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80188AE8[])(void); - -void func_80164BA0(void *a0) { - D_80188AE8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801CB248; -extern u8 D_801CB249; -extern u8 D_801CB24A; -extern u8 D_801CB24B; -extern u8 D_801CB24C; -extern u8 D_801CB24D; -extern u8 D_801CB24E; -extern u8 D_801CB24F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801CB248; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801CB249 = 0xf0; - *(u8 *)base = 0xf0; - D_801CB24A = 0xc0; - D_801CB24E = 0; - D_801CB24D = 0; - D_801CB24C = 0; - D_801CB24F = 0; - D_801CB24B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801CB248; -extern u8 D_801CB249; -extern u8 D_801CB24A; - -s32 func_80164E40(void) { - u8 *p = &D_801CB248; - if (*p != 0) { - *p -= 0x10; - } - if (D_801CB249 != 0) { - D_801CB249 -= 0x10; - } - if (D_801CB24A != 0) { - D_801CB24A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80188AF8[])(void); - -void func_80164EA4(void *a0) { - D_80188AF8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801CB294[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801CB294[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801CB288[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801CB288[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801CB288[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801CB288; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801CB288; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80188B0C[]; - extern u32 D_80188B2C, D_80188B30, D_80188B34, D_80188B38; - extern u32 D_80188B2C, D_80188B30, D_80188B34, D_80188B38; - extern u32 D_80188B2C, D_80188B30, D_80188B34, D_80188B38; - extern u32 D_80188B2C, D_80188B30, D_80188B34, D_80188B38; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80188B0C[0x00], p); - ApplyMatrixSV(mat, &D_80188B0C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80188B0C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80188B0C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80188B34; - *(u32 *)(prim + 0x24) = D_80188B2C; - *(u32 *)(prim + 0x28) = D_80188B38; - *(u32 *)(prim + 0x2c) = D_80188B30; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80188B3C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80188B3C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80188B3C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80188B3C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80188BB8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80188BB8[a1 & 0x7F]; -} - - - -extern s32 D_80188BD8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80188BD8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80188C54[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80188C54[a1 & 0x7F]; -} - - - -extern u8 D_80188C74[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80188C74[a1 & 0x7F]; -} - - - -extern u8 D_80188C94[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80188C94[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80188CB4[])(void); - D_80188CB4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80188D30[])(void); - -void func_80165AC8(void) { - D_80188D30[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80188DAC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80188DAC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801CAA00; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801CAA00, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80188DB8[])(void); - -void func_80166018(void *a0) { - D_80188DB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80188DC0[])(void); - -void func_801663FC(void *a0) { - D_80188DC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80188E88[])(void); - -void func_80166618(void *a0) { - D_80188E88[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80188E98[])(void); - -void func_80166654(void *a0) { - D_80188E98[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801CB308[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801CB308[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CB308). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801CB308[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801CB308)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801CB308[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801CB308[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80188DDC[]; - extern u8 D_80188DC8[]; - extern u8 D_80188DF0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80188DDC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80188DC8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80188DF0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80167714); - - -extern void (*D_80188EA8[])(void); - -void func_801678B4(void *a0) { - D_80188EA8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80188EB4[])(void); - -void func_80167A9C(void *a0) { - D_80188EB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80188FC0; - extern u8 D_80188FD4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80188FC0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188FD4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80188E14[]; -extern u8 D_80188E28[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80188E14; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80188E28; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80188ECC[])(void); - -void func_80168744(void *a0) { - D_80188ECC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80188EBC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80188EBC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80188EBC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80188ED4[])(void); - -void func_801689D8(void *a0) { - D_80188ED4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80188EDC[])(void); - -void func_80168AA8(void *a0) { - D_80188EDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80188EE4[])(void); - -void func_80168D58(void *a0) { - D_80188EE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80188EEC[])(void); - -void func_8016901C(void *a0) { - D_80188EEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015AE2C", func_80169228); - - -extern void (*D_80188EF4[])(void); - -void func_801693CC(void *a0) { - D_80188EF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80188EFC[])(void); - -void func_80169830(void *a0) { - D_80188EFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80188FB0[])(void); - -void func_80169B80(void *a0) { - D_80188FB0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80188F04[]; - extern u8 D_80188F74[]; - extern u8 D_80188FA4[]; - extern u8 D_801CC598[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80188FA4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80188F04[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801CC598; - RotMatrixYXZ(rot, D_801CC598); - func_80048D9C(D_801CC598, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80188F74); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80188FB8[])(void); - -void func_80169F00(void *a0) { - D_80188FB8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80188F68[]; -extern char D_80188F28[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80188F68, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188F28); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80188FF0[])(void); - -void func_8016A020(void *a0) { - D_80188FF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80188FC0; - extern u8 D_80188FD4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80188FC0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188FD4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80188FFC[])(void); - -void func_8016A700(void *a0) { - D_80188FFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80189044[])(void); - -void func_8016AB30(void *a0) { - D_80189044[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c b/src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c new file mode 100644 index 000000000..aa4f777dd --- /dev/null +++ b/src/ov_SC03_093/ov_SC03_093_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80188410; +extern u8 D_80188380; +extern u8 D_8018835C; +extern u8 D_80188338; +extern u8 D_801883EC; +extern u8 D_801883C8; +extern u8 D_801883A4; +extern u8 D_80188314; +extern void func_80145934(void); +extern u8 D_801884A0; +extern u8 D_8018847C; +extern u8 D_80188458; +extern u8 D_80188434; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80187898[]; +extern unsigned char D_801878C8[]; +extern unsigned char D_80187918[]; +extern unsigned char D_80187948[]; +extern unsigned char D_80187978[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801879C8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80187A90[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80187B18[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80187B20; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801CB138; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801CB13C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80187B50; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80187BF8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80187C1C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80187C0C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80187C30[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80187C3C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80187C4C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80187C64[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80187C54; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80187C78[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80187C94[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80187C84; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80187CA8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80187CBC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80187CD0; +extern void (*D_80187CF8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80187CD8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80187D44[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80187D48[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801881AC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801881BC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801CB170; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801881E4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801881C4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801881D4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80188224[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018822C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801881F8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80188238[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80188208; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801CB178; +extern s32 D_801CB184; +extern s32 D_801CB188; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80188274[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80188248[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801CB180; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801884C4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801882E4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80188568[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801886BC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801884D8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801886C4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801884E8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80188508; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801886CC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801886F4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80188574[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80188574[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80188574[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80188574[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80188574[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80188574[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80188574[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80188574[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80188700[])(void); + +void func_8015C714(void *a0) { + D_80188700[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80188574[])(void*); + extern int D_80188518; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80188574)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80188574)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188518); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80188574[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80188574[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80188574[])(void*); + extern int D_80188518; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80188574)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188518); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80188574)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80188710[])(void); + D_80188710[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80188574[])(struct Ent_8015CD20 *); + extern u8 D_80188528; + extern u8 D_80188718; + extern u8 D_80188728; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80188574[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188528); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188718); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188728); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80188574[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80188748[])(void); + D_80188748[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80188738; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80188738 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80188574[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801887A4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801887A4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80187888[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80187888; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801887AC[])(void); + D_801887AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801887B8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801887B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801887B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801887B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80188574[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801887B8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80188538[]; + extern u8 D_80188548[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188538); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188548); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801887B8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801887B8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801887B8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801887EC[])(void); + D_801887EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188574[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801887F4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018880C[])(void); + D_8018880C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188574[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801887F4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801887F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018882C[])(void); + D_8018882C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80188574[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188574)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018883C; +extern u16 D_8018883E; +extern u16 D_80188840; +extern s32 D_80188844; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018883C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018883E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80188840 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188844, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018884C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018884C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80188574[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188574)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80188860[])(void); + D_80188860[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80188574[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80188574[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80188868[])(void); + D_80188868[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80188558; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188558); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80188574[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80188870[])(void); + D_80188870[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80188574[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80188574[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80188878[])(void); + D_80188878[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80188574[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80188880; + extern s32 D_80188890; + extern s32 D_801888A0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80188574[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188880); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188890); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80188574[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801888A0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801888B0[])(void); + D_801888B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80188574[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80188574[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80188574[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188574[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801888BC[])(void); + D_801888BC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80188574[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188574[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80188574[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188574[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801888D0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801888D0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80188574[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80188574)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80188574[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188574[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018894C[])(void); + D_8018894C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80188574[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80188574)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018895C[])(void); + D_8018895C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80188574[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80188574[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80188574[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80188574[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80188574[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80188574[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80188574[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80188964[])(void); + D_80188964[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80188574[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80188574)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80188574[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80188574)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80188970[])(void); + D_80188970[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188574 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80188574[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80188574[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80188574[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80188980[])(void); + +void func_80160EA4(void *a0) { + D_80188980[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80188574[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80188574[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801889B0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801889B0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80188A14; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80188A14); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801CB190[]; + extern u8 D_801889E0[]; + extern u8 D_80188A00[]; + extern u8 D_801CB19C[]; + extern u8 D_801CB1C4[]; + extern u8 D_801CB1DC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801CB190[0] = p; + func_80024054(&D_801889E0, &D_801CB19C); + func_8001CE28(p, &D_801CB19C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801CB190[1] = p; + func_80024054(&D_80188A00, &D_801CB1C4); + func_8001CE28(p, &D_801CB1C4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801CB190[2] = p; + func_800242D0((s16)func_801620C4(), &D_801CB1DC, 0x84); + func_8001CE68(p, &D_801CB1DC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801CB1DC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CB190[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801CB190; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80188A14; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80188A14; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80188A14; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80188A14; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801CB190[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801CB190; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80188A38[])(void); + +void func_80162330(void *a0) { + D_80188A38[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801CB1E8[i] via `extern int D_801CB1E8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80188A44[]; + extern s32 D_80188A5C; + extern u8 D_801CB1F4[]; + extern u8 D_801CB21C[]; + extern u8 D_801CB238[]; + extern int D_801CB1E8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801CB1E8[0] = (s32)item; + func_80024054(D_80188A44, D_801CB1F4); + func_8001CE28(item, D_801CB1F4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801CB1E8[1] = (s32)item; + func_80024054(((u8 *)&D_80188A5C), D_801CB21C); + func_8001CE28(item, D_801CB21C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801CB1E8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801CB238, 0x84); + func_8001CE68(item, D_801CB238); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801CB238, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CB1E8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801CB1E8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_801627E8); + + +extern void (*D_80188A80[])(void); + +void func_80162834(void *a0) { + D_80188A80[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80188A70; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80188A70, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801CA9F0[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801CA9F0, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801CA9F0[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801CA9F0, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80188A88[])(void); + +void func_80163A58(void *a0) { + D_80188A88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801CA9F8; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801CA9F8; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80188ADC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80188ADC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80188AA4; +extern s16 D_80188AD8; +extern s16 D_80188AD6; +extern s16 D_80188AD4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80188AA4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80188AD8 = 0x80; + D_80188AD6 = 0x80; + D_80188AD4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80188AD8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188AD8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80188AD8 - 8; + D_80188AD8 = nv; + D_80188AD6 = nv; + D_80188AD4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80188AE8[])(void); + +void func_80164BA0(void *a0) { + D_80188AE8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801CB248; +extern u8 D_801CB249; +extern u8 D_801CB24A; +extern u8 D_801CB24B; +extern u8 D_801CB24C; +extern u8 D_801CB24D; +extern u8 D_801CB24E; +extern u8 D_801CB24F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801CB248; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801CB249 = 0xf0; + *(u8 *)base = 0xf0; + D_801CB24A = 0xc0; + D_801CB24E = 0; + D_801CB24D = 0; + D_801CB24C = 0; + D_801CB24F = 0; + D_801CB24B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801CB248; +extern u8 D_801CB249; +extern u8 D_801CB24A; + +s32 func_80164E40(void) { + u8 *p = &D_801CB248; + if (*p != 0) { + *p -= 0x10; + } + if (D_801CB249 != 0) { + D_801CB249 -= 0x10; + } + if (D_801CB24A != 0) { + D_801CB24A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80188AF8[])(void); + +void func_80164EA4(void *a0) { + D_80188AF8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801CB294[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801CB294[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801CB288[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801CB288[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801CB288[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801CB288; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801CB288; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80188B0C[]; + extern u32 D_80188B2C, D_80188B30, D_80188B34, D_80188B38; + extern u32 D_80188B2C, D_80188B30, D_80188B34, D_80188B38; + extern u32 D_80188B2C, D_80188B30, D_80188B34, D_80188B38; + extern u32 D_80188B2C, D_80188B30, D_80188B34, D_80188B38; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80188B0C[0x00], p); + ApplyMatrixSV(mat, &D_80188B0C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80188B0C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80188B0C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80188B34; + *(u32 *)(prim + 0x24) = D_80188B2C; + *(u32 *)(prim + 0x28) = D_80188B38; + *(u32 *)(prim + 0x2c) = D_80188B30; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80188B3C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80188B3C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80188B3C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80188B3C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80188BB8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80188BB8[a1 & 0x7F]; +} + + + +extern s32 D_80188BD8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80188BD8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80188C54[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80188C54[a1 & 0x7F]; +} + + + +extern u8 D_80188C74[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80188C74[a1 & 0x7F]; +} + + + +extern u8 D_80188C94[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80188C94[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80188CB4[])(void); + D_80188CB4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80188D30[])(void); + +void func_80165AC8(void) { + D_80188D30[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80188DAC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80188DAC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801CAA00; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801CAA00, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80188DB8[])(void); + +void func_80166018(void *a0) { + D_80188DB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80188DC0[])(void); + +void func_801663FC(void *a0) { + D_80188DC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80188E88[])(void); + +void func_80166618(void *a0) { + D_80188E88[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80188E98[])(void); + +void func_80166654(void *a0) { + D_80188E98[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801CB308[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801CB308[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CB308). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801CB308[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801CB308)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801CB308[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801CB308[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80188DDC[]; + extern u8 D_80188DC8[]; + extern u8 D_80188DF0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80188DDC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80188DC8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80188DF0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80167714); + + +extern void (*D_80188EA8[])(void); + +void func_801678B4(void *a0) { + D_80188EA8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80188EB4[])(void); + +void func_80167A9C(void *a0) { + D_80188EB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80188FC0; + extern u8 D_80188FD4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80188FC0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188FD4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80188E14[]; +extern u8 D_80188E28[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80188E14; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80188E28; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80188ECC[])(void); + +void func_80168744(void *a0) { + D_80188ECC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80188EBC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80188EBC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80188EBC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80188ED4[])(void); + +void func_801689D8(void *a0) { + D_80188ED4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80188EDC[])(void); + +void func_80168AA8(void *a0) { + D_80188EDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80188EE4[])(void); + +void func_80168D58(void *a0) { + D_80188EE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80188EEC[])(void); + +void func_8016901C(void *a0) { + D_80188EEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_093/nonmatchings/ov_SC03_093_jr_8015C32C", func_80169228); + + +extern void (*D_80188EF4[])(void); + +void func_801693CC(void *a0) { + D_80188EF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80188EFC[])(void); + +void func_80169830(void *a0) { + D_80188EFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80188FB0[])(void); + +void func_80169B80(void *a0) { + D_80188FB0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80188F04[]; + extern u8 D_80188F74[]; + extern u8 D_80188FA4[]; + extern u8 D_801CC598[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80188FA4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80188F04[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801CC598; + RotMatrixYXZ(rot, D_801CC598); + func_80048D9C(D_801CC598, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80188F74); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80188FB8[])(void); + +void func_80169F00(void *a0) { + D_80188FB8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80188F68[]; +extern char D_80188F28[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80188F68, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188F28); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80188FF0[])(void); + +void func_8016A020(void *a0) { + D_80188FF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80188FC0; + extern u8 D_80188FD4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80188FC0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188FD4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80188FFC[])(void); + +void func_8016A700(void *a0) { + D_80188FFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80189044[])(void); + +void func_8016AB30(void *a0) { + D_80189044[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_094/ov_SC03_094_jr_8015AE2C.c b/src/ov_SC03_094/ov_SC03_094_jr_8015AE2C.c index c36f877d9..4af4160b3 100644 --- a/src/ov_SC03_094/ov_SC03_094_jr_8015AE2C.c +++ b/src/ov_SC03_094/ov_SC03_094_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018A0FC[])(void); - -void func_8015C714(void *a0) { - D_8018A0FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80189F70[])(void*); - extern int D_80189F14; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80189F70)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80189F70)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189F14); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80189F70[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80189F70[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80189F70[])(void*); - extern int D_80189F14; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80189F70)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189F14); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80189F70)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018A10C[])(void); - D_8018A10C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80189F70[])(struct Ent_8015CD20 *); - extern u8 D_80189F24; - extern u8 D_8018A114; - extern u8 D_8018A124; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80189F70[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189F24); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A114); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A124); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80189F70[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018A144[])(void); - D_8018A144[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018A134; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018A134 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80189F70[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018A1A0; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018A1A0, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80189284[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80189284; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018A1A8[])(void); - D_8018A1A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018A1B4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018A1B4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018A1B4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018A1B4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80189F70[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018A1B4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80189F34[]; - extern u8 D_80189F44[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189F34); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189F44); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018A1B4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018A1B4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018A1B4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018A1E8[])(void); - D_8018A1E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80189F70[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018A1F0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018A208[])(void); - D_8018A208[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80189F70[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018A1F0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018A228[])(void); - D_8018A228[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80189F70[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80189F70)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018A238; -extern u16 D_8018A23A; -extern u16 D_8018A23C; -extern s32 D_8018A240; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018A238 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018A23A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018A23C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018A240, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018A248; - -void func_8015E588(void) { - func_8013C9C4(&D_8018A248); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80189F70[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80189F70)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018A25C[])(void); - D_8018A25C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80189F70[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80189F70[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018A264[])(void); - D_8018A264[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80189F54; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80189F54); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80189F70[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018A26C[])(void); - D_8018A26C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80189F70[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80189F70[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018A274[])(void); - D_8018A274[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80189F70[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018A27C; - extern s32 D_8018A28C; - extern s32 D_8018A29C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80189F70[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A27C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A28C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80189F70[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A29C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018A2AC[])(void); - D_8018A2AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80189F70[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80189F70[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80189F70[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80189F70[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018A2B8[])(void); - D_8018A2B8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80189F70[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80189F70[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80189F70[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80189F70[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018A2CC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018A2CC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80189F70[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80189F70)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80189F70[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80189F70[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018A348[])(void); - D_8018A348[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80189F70[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80189F70)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018A358[])(void); - D_8018A358[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80189F70[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80189F70[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80189F70[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80189F70[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80189F70[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80189F70[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80189F70[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018A360[])(void); - D_8018A360[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80189F70[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80189F70)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80189F70[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80189F70)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018A36C[])(void); - D_8018A36C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80189F70 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80189F70[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80189F70[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80189F70[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018A37C[])(void); - -void func_80160EA4(void *a0) { - D_8018A37C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80189F70[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80189F70[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018A3AC[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018A3AC[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018A410; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018A410); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801D1FD0[]; - extern u8 D_8018A3DC[]; - extern u8 D_8018A3FC[]; - extern u8 D_801D1FDC[]; - extern u8 D_801D2004[]; - extern u8 D_801D201C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801D1FD0[0] = p; - func_80024054(&D_8018A3DC, &D_801D1FDC); - func_8001CE28(p, &D_801D1FDC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801D1FD0[1] = p; - func_80024054(&D_8018A3FC, &D_801D2004); - func_8001CE28(p, &D_801D2004); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801D1FD0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801D201C, 0x84); - func_8001CE68(p, &D_801D201C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801D201C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D1FD0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801D1FD0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018A410; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018A410; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018A410; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018A410; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801D1FD0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801D1FD0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018A434[])(void); - -void func_80162330(void *a0) { - D_8018A434[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801D2028[i] via `extern int D_801D2028[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018A440[]; - extern s32 D_8018A458; - extern u8 D_801D2034[]; - extern u8 D_801D205C[]; - extern u8 D_801D2078[]; - extern int D_801D2028[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801D2028[0] = (s32)item; - func_80024054(D_8018A440, D_801D2034); - func_8001CE28(item, D_801D2034); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801D2028[1] = (s32)item; - func_80024054(((u8 *)&D_8018A458), D_801D205C); - func_8001CE28(item, D_801D205C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801D2028[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801D2078, 0x84); - func_8001CE68(item, D_801D2078); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801D2078, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D2028[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801D2028; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018A47C[])(void); - -void func_80162834(void *a0) { - D_8018A47C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018A46C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018A46C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801D182C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801D182C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801D182C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801D182C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018A484[])(void); - -void func_80163A58(void *a0) { - D_8018A484[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801D1834; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801D1834; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018A4D8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018A4D8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018A4A0; -extern s16 D_8018A4D4; -extern s16 D_8018A4D2; -extern s16 D_8018A4D0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018A4A0; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018A4D4 = 0x80; - D_8018A4D2 = 0x80; - D_8018A4D0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018A4D4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018A4D4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018A4D4 - 8; - D_8018A4D4 = nv; - D_8018A4D2 = nv; - D_8018A4D0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018A4E4[])(void); - -void func_80164BA0(void *a0) { - D_8018A4E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801D2088; -extern u8 D_801D2089; -extern u8 D_801D208A; -extern u8 D_801D208B; -extern u8 D_801D208C; -extern u8 D_801D208D; -extern u8 D_801D208E; -extern u8 D_801D208F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801D2088; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801D2089 = 0xf0; - *(u8 *)base = 0xf0; - D_801D208A = 0xc0; - D_801D208E = 0; - D_801D208D = 0; - D_801D208C = 0; - D_801D208F = 0; - D_801D208B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801D2088; -extern u8 D_801D2089; -extern u8 D_801D208A; - -s32 func_80164E40(void) { - u8 *p = &D_801D2088; - if (*p != 0) { - *p -= 0x10; - } - if (D_801D2089 != 0) { - D_801D2089 -= 0x10; - } - if (D_801D208A != 0) { - D_801D208A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018A4F4[])(void); - -void func_80164EA4(void *a0) { - D_8018A4F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801D20D4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801D20D4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801D20C8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801D20C8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801D20C8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801D20C8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801D20C8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018A508[]; - extern u32 D_8018A528, D_8018A52C, D_8018A530, D_8018A534; - extern u32 D_8018A528, D_8018A52C, D_8018A530, D_8018A534; - extern u32 D_8018A528, D_8018A52C, D_8018A530, D_8018A534; - extern u32 D_8018A528, D_8018A52C, D_8018A530, D_8018A534; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018A508[0x00], p); - ApplyMatrixSV(mat, &D_8018A508[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018A508[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018A508[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018A530; - *(u32 *)(prim + 0x24) = D_8018A528; - *(u32 *)(prim + 0x28) = D_8018A534; - *(u32 *)(prim + 0x2c) = D_8018A52C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018A538[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018A538[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018A538[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018A538[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018A5B4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018A5B4[a1 & 0x7F]; -} - - - -extern s32 D_8018A5D4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018A5D4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018A650[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018A650[a1 & 0x7F]; -} - - - -extern u8 D_8018A670[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018A670[a1 & 0x7F]; -} - - - -extern u8 D_8018A690[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018A690[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018A6B0[])(void); - D_8018A6B0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018A72C[])(void); - -void func_80165AC8(void) { - D_8018A72C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018A7A8[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018A7A8[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801D183C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801D183C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018A7B4[])(void); - -void func_80166018(void *a0) { - D_8018A7B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018A7BC[])(void); - -void func_801663FC(void *a0) { - D_8018A7BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018A884[])(void); - -void func_80166618(void *a0) { - D_8018A884[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018A894[])(void); - -void func_80166654(void *a0) { - D_8018A894[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801D2148[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801D2148[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D2148). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801D2148[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801D2148)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801D2148[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801D2148[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018A7D8[]; - extern u8 D_8018A7C4[]; - extern u8 D_8018A7EC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018A7D8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018A7C4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018A7EC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80167714); - - -extern void (*D_8018A8A4[])(void); - -void func_801678B4(void *a0) { - D_8018A8A4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018A8B0[])(void); - -void func_80167A9C(void *a0) { - D_8018A8B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018A9BC; - extern u8 D_8018A9D0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018A9BC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018A9D0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018A810[]; -extern u8 D_8018A824[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018A810; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018A824; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018A8C8[])(void); - -void func_80168744(void *a0) { - D_8018A8C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018A8B8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018A8B8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018A8B8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018A8D0[])(void); - -void func_801689D8(void *a0) { - D_8018A8D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018A8D8[])(void); - -void func_80168AA8(void *a0) { - D_8018A8D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018A8E0[])(void); - -void func_80168D58(void *a0) { - D_8018A8E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018A8E8[])(void); - -void func_8016901C(void *a0) { - D_8018A8E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015AE2C", func_80169228); - - -extern void (*D_8018A8F0[])(void); - -void func_801693CC(void *a0) { - D_8018A8F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018A8F8[])(void); - -void func_80169830(void *a0) { - D_8018A8F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018A9AC[])(void); - -void func_80169B80(void *a0) { - D_8018A9AC[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018A900[]; - extern u8 D_8018A970[]; - extern u8 D_8018A9A0[]; - extern u8 D_801D3150[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018A9A0, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018A900[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801D3150; - RotMatrixYXZ(rot, D_801D3150); - func_80048D9C(D_801D3150, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018A970); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018A9B4[])(void); - -void func_80169F00(void *a0) { - D_8018A9B4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018A964[]; -extern char D_8018A924[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018A964, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018A924); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018A9EC[])(void); - -void func_8016A020(void *a0) { - D_8018A9EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018A9BC; - extern u8 D_8018A9D0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018A9BC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018A9D0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018A9F8[])(void); - -void func_8016A700(void *a0) { - D_8018A9F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018AA40[])(void); - -void func_8016AB30(void *a0) { - D_8018AA40[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c b/src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c new file mode 100644 index 000000000..2878353c7 --- /dev/null +++ b/src/ov_SC03_094/ov_SC03_094_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80189E0C; +extern u8 D_80189D7C; +extern u8 D_80189D58; +extern u8 D_80189D34; +extern u8 D_80189DE8; +extern u8 D_80189DC4; +extern u8 D_80189DA0; +extern u8 D_80189D10; +extern void func_80145934(void); +extern u8 D_80189E9C; +extern u8 D_80189E78; +extern u8 D_80189E54; +extern u8 D_80189E30; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80189294[]; +extern unsigned char D_801892C4[]; +extern unsigned char D_80189314[]; +extern unsigned char D_80189344[]; +extern unsigned char D_80189374[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801893C4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018948C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80189514[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018951C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801D1F78; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801D1F7C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018954C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801895F4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80189618[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80189608; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018962C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80189638[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80189648[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80189660[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80189650; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80189674[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80189690[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80189680; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801896A4[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801896B8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801896CC; +extern void (*D_801896F4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801896D4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80189740[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80189744[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80189BA8[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80189BB8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801D1FB0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80189BE0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80189BC0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80189BD0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80189C20[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80189C28[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80189BF4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80189C34[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80189C04; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801D1FB8; +extern s32 D_801D1FC4; +extern s32 D_801D1FC8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80189C70[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80189C44[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801D1FC0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80189EC0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80189CE0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80189F64[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018A0B8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80189ED4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018A0C0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80189EE4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80189F04; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018A0C8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018A0F0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80189F70[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018A0FC[])(void); + +void func_8015C714(void *a0) { + D_8018A0FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80189F70[])(void*); + extern int D_80189F14; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80189F70)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80189F70)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189F14); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80189F70[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80189F70[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80189F70[])(void*); + extern int D_80189F14; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80189F70)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189F14); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80189F70)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018A10C[])(void); + D_8018A10C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80189F70[])(struct Ent_8015CD20 *); + extern u8 D_80189F24; + extern u8 D_8018A114; + extern u8 D_8018A124; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80189F70[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189F24); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A114); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A124); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80189F70[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018A144[])(void); + D_8018A144[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018A134; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018A134 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80189F70[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018A1A0; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018A1A0, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80189284[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80189284; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018A1A8[])(void); + D_8018A1A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018A1B4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018A1B4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018A1B4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018A1B4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80189F70[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018A1B4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80189F34[]; + extern u8 D_80189F44[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189F34); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189F44); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018A1B4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018A1B4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018A1B4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018A1E8[])(void); + D_8018A1E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80189F70[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018A1F0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018A208[])(void); + D_8018A208[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80189F70[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018A1F0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018A1F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018A228[])(void); + D_8018A228[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80189F70[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80189F70)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018A238; +extern u16 D_8018A23A; +extern u16 D_8018A23C; +extern s32 D_8018A240; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018A238 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018A23A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018A23C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018A240, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018A248; + +void func_8015E588(void) { + func_8013C9C4(&D_8018A248); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80189F70[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80189F70)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018A25C[])(void); + D_8018A25C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80189F70[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80189F70[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018A264[])(void); + D_8018A264[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80189F54; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80189F54); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80189F70[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018A26C[])(void); + D_8018A26C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80189F70[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80189F70[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018A274[])(void); + D_8018A274[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80189F70[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018A27C; + extern s32 D_8018A28C; + extern s32 D_8018A29C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A27C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A28C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80189F70[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A29C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018A2AC[])(void); + D_8018A2AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80189F70[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80189F70[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80189F70[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80189F70[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018A2B8[])(void); + D_8018A2B8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80189F70[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80189F70[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80189F70[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80189F70[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018A2CC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018A2CC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80189F70[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80189F70)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80189F70[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80189F70[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018A348[])(void); + D_8018A348[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80189F70[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80189F70)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018A358[])(void); + D_8018A358[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80189F70[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80189F70[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80189F70[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80189F70[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80189F70[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80189F70[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80189F70[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018A360[])(void); + D_8018A360[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80189F70[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80189F70)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80189F70[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80189F70)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018A36C[])(void); + D_8018A36C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80189F70 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80189F70[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80189F70[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80189F70[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018A37C[])(void); + +void func_80160EA4(void *a0) { + D_8018A37C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80189F70[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80189F70[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018A3AC[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018A3AC[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018A410; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018A410); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801D1FD0[]; + extern u8 D_8018A3DC[]; + extern u8 D_8018A3FC[]; + extern u8 D_801D1FDC[]; + extern u8 D_801D2004[]; + extern u8 D_801D201C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801D1FD0[0] = p; + func_80024054(&D_8018A3DC, &D_801D1FDC); + func_8001CE28(p, &D_801D1FDC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801D1FD0[1] = p; + func_80024054(&D_8018A3FC, &D_801D2004); + func_8001CE28(p, &D_801D2004); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801D1FD0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801D201C, 0x84); + func_8001CE68(p, &D_801D201C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801D201C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D1FD0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801D1FD0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018A410; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018A410; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018A410; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018A410; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801D1FD0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801D1FD0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018A434[])(void); + +void func_80162330(void *a0) { + D_8018A434[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801D2028[i] via `extern int D_801D2028[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018A440[]; + extern s32 D_8018A458; + extern u8 D_801D2034[]; + extern u8 D_801D205C[]; + extern u8 D_801D2078[]; + extern int D_801D2028[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801D2028[0] = (s32)item; + func_80024054(D_8018A440, D_801D2034); + func_8001CE28(item, D_801D2034); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801D2028[1] = (s32)item; + func_80024054(((u8 *)&D_8018A458), D_801D205C); + func_8001CE28(item, D_801D205C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801D2028[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801D2078, 0x84); + func_8001CE68(item, D_801D2078); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801D2078, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D2028[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801D2028; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_801627E8); + + +extern void (*D_8018A47C[])(void); + +void func_80162834(void *a0) { + D_8018A47C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018A46C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018A46C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801D182C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801D182C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801D182C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801D182C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018A484[])(void); + +void func_80163A58(void *a0) { + D_8018A484[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801D1834; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801D1834; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018A4D8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018A4D8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018A4A0; +extern s16 D_8018A4D4; +extern s16 D_8018A4D2; +extern s16 D_8018A4D0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018A4A0; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018A4D4 = 0x80; + D_8018A4D2 = 0x80; + D_8018A4D0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018A4D4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018A4D4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018A4D4 - 8; + D_8018A4D4 = nv; + D_8018A4D2 = nv; + D_8018A4D0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018A4E4[])(void); + +void func_80164BA0(void *a0) { + D_8018A4E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801D2088; +extern u8 D_801D2089; +extern u8 D_801D208A; +extern u8 D_801D208B; +extern u8 D_801D208C; +extern u8 D_801D208D; +extern u8 D_801D208E; +extern u8 D_801D208F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801D2088; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801D2089 = 0xf0; + *(u8 *)base = 0xf0; + D_801D208A = 0xc0; + D_801D208E = 0; + D_801D208D = 0; + D_801D208C = 0; + D_801D208F = 0; + D_801D208B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801D2088; +extern u8 D_801D2089; +extern u8 D_801D208A; + +s32 func_80164E40(void) { + u8 *p = &D_801D2088; + if (*p != 0) { + *p -= 0x10; + } + if (D_801D2089 != 0) { + D_801D2089 -= 0x10; + } + if (D_801D208A != 0) { + D_801D208A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018A4F4[])(void); + +void func_80164EA4(void *a0) { + D_8018A4F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801D20D4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801D20D4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801D20C8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801D20C8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801D20C8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801D20C8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801D20C8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018A508[]; + extern u32 D_8018A528, D_8018A52C, D_8018A530, D_8018A534; + extern u32 D_8018A528, D_8018A52C, D_8018A530, D_8018A534; + extern u32 D_8018A528, D_8018A52C, D_8018A530, D_8018A534; + extern u32 D_8018A528, D_8018A52C, D_8018A530, D_8018A534; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018A508[0x00], p); + ApplyMatrixSV(mat, &D_8018A508[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018A508[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018A508[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018A530; + *(u32 *)(prim + 0x24) = D_8018A528; + *(u32 *)(prim + 0x28) = D_8018A534; + *(u32 *)(prim + 0x2c) = D_8018A52C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018A538[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018A538[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018A538[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018A538[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018A5B4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018A5B4[a1 & 0x7F]; +} + + + +extern s32 D_8018A5D4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018A5D4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018A650[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018A650[a1 & 0x7F]; +} + + + +extern u8 D_8018A670[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018A670[a1 & 0x7F]; +} + + + +extern u8 D_8018A690[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018A690[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018A6B0[])(void); + D_8018A6B0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018A72C[])(void); + +void func_80165AC8(void) { + D_8018A72C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018A7A8[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018A7A8[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801D183C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801D183C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018A7B4[])(void); + +void func_80166018(void *a0) { + D_8018A7B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018A7BC[])(void); + +void func_801663FC(void *a0) { + D_8018A7BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018A884[])(void); + +void func_80166618(void *a0) { + D_8018A884[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018A894[])(void); + +void func_80166654(void *a0) { + D_8018A894[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801D2148[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801D2148[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D2148). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801D2148[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801D2148)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801D2148[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801D2148[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018A7D8[]; + extern u8 D_8018A7C4[]; + extern u8 D_8018A7EC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018A7D8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018A7C4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018A7EC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80167714); + + +extern void (*D_8018A8A4[])(void); + +void func_801678B4(void *a0) { + D_8018A8A4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018A8B0[])(void); + +void func_80167A9C(void *a0) { + D_8018A8B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018A9BC; + extern u8 D_8018A9D0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018A9BC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018A9D0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018A810[]; +extern u8 D_8018A824[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018A810; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018A824; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018A8C8[])(void); + +void func_80168744(void *a0) { + D_8018A8C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018A8B8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018A8B8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018A8B8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018A8D0[])(void); + +void func_801689D8(void *a0) { + D_8018A8D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018A8D8[])(void); + +void func_80168AA8(void *a0) { + D_8018A8D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018A8E0[])(void); + +void func_80168D58(void *a0) { + D_8018A8E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018A8E8[])(void); + +void func_8016901C(void *a0) { + D_8018A8E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_094/nonmatchings/ov_SC03_094_jr_8015C32C", func_80169228); + + +extern void (*D_8018A8F0[])(void); + +void func_801693CC(void *a0) { + D_8018A8F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018A8F8[])(void); + +void func_80169830(void *a0) { + D_8018A8F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018A9AC[])(void); + +void func_80169B80(void *a0) { + D_8018A9AC[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018A900[]; + extern u8 D_8018A970[]; + extern u8 D_8018A9A0[]; + extern u8 D_801D3150[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018A9A0, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018A900[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801D3150; + RotMatrixYXZ(rot, D_801D3150); + func_80048D9C(D_801D3150, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018A970); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018A9B4[])(void); + +void func_80169F00(void *a0) { + D_8018A9B4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018A964[]; +extern char D_8018A924[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018A964, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018A924); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018A9EC[])(void); + +void func_8016A020(void *a0) { + D_8018A9EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018A9BC; + extern u8 D_8018A9D0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018A9BC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018A9D0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018A9F8[])(void); + +void func_8016A700(void *a0) { + D_8018A9F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018AA40[])(void); + +void func_8016AB30(void *a0) { + D_8018AA40[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_095/ov_SC03_095_jr_8015AE2C.c b/src/ov_SC03_095/ov_SC03_095_jr_8015AE2C.c index 2571fbc16..ee480f3bf 100644 --- a/src/ov_SC03_095/ov_SC03_095_jr_8015AE2C.c +++ b/src/ov_SC03_095/ov_SC03_095_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018375C[])(void); - -void func_8015C714(void *a0) { - D_8018375C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801835D0[])(void*); - extern int D_80183574; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801835D0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801835D0)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183574); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801835D0[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801835D0[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801835D0[])(void*); - extern int D_80183574; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801835D0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183574); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801835D0)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018376C[])(void); - D_8018376C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801835D0[])(struct Ent_8015CD20 *); - extern u8 D_80183584; - extern u8 D_80183774; - extern u8 D_80183784; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801835D0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183584); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183774); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183784); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801835D0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801837A4[])(void); - D_801837A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80183794; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80183794 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801835D0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80183800; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80183800, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801828E4[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801828E4; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80183808[])(void); - D_80183808[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80183814[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80183814[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80183814[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80183814[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801835D0[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80183814[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80183594[]; - extern u8 D_801835A4[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183594); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801835A4); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80183814[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183814[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183814[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80183848[])(void); - D_80183848[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801835D0[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80183850[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80183868[])(void); - D_80183868[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801835D0[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80183850[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80183888[])(void); - D_80183888[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801835D0[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801835D0)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80183898; -extern u16 D_8018389A; -extern u16 D_8018389C; -extern s32 D_801838A0; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80183898 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018389A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018389C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801838A0, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801838A8; - -void func_8015E588(void) { - func_8013C9C4(&D_801838A8); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801835D0[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801835D0)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801838BC[])(void); - D_801838BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801835D0[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801835D0[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801838C4[])(void); - D_801838C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801835B4; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801835B4); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801835D0[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801838CC[])(void); - D_801838CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801835D0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801835D0[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801838D4[])(void); - D_801838D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801835D0[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801838DC; - extern s32 D_801838EC; - extern s32 D_801838FC; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801835D0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838DC); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838EC); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801835D0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838FC); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018390C[])(void); - D_8018390C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801835D0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801835D0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801835D0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801835D0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80183918[])(void); - D_80183918[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801835D0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801835D0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801835D0[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801835D0[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018392C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018392C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801835D0[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801835D0)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801835D0[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801835D0[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801839A8[])(void); - D_801839A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801835D0[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801835D0)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801839B8[])(void); - D_801839B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801835D0[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801835D0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801835D0[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801835D0[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801835D0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801835D0[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801835D0[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801839C0[])(void); - D_801839C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801835D0[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801835D0)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801835D0[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801835D0)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801839CC[])(void); - D_801839CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801835D0 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801835D0[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801835D0[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801835D0[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801839DC[])(void); - -void func_80160EA4(void *a0) { - D_801839DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801835D0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801835D0[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80183A0C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80183A0C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80183A70; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80183A70); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019ABC8[]; - extern u8 D_80183A3C[]; - extern u8 D_80183A5C[]; - extern u8 D_8019ABD4[]; - extern u8 D_8019ABFC[]; - extern u8 D_8019AC14[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019ABC8[0] = p; - func_80024054(&D_80183A3C, &D_8019ABD4); - func_8001CE28(p, &D_8019ABD4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019ABC8[1] = p; - func_80024054(&D_80183A5C, &D_8019ABFC); - func_8001CE28(p, &D_8019ABFC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019ABC8[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019AC14, 0x84); - func_8001CE68(p, &D_8019AC14); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019AC14, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019ABC8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019ABC8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80183A70; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80183A70; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80183A70; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80183A70; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019ABC8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019ABC8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80183A94[])(void); - -void func_80162330(void *a0) { - D_80183A94[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019AC20[i] via `extern int D_8019AC20[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80183AA0[]; - extern s32 D_80183AB8; - extern u8 D_8019AC2C[]; - extern u8 D_8019AC54[]; - extern u8 D_8019AC70[]; - extern int D_8019AC20[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019AC20[0] = (s32)item; - func_80024054(D_80183AA0, D_8019AC2C); - func_8001CE28(item, D_8019AC2C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019AC20[1] = (s32)item; - func_80024054(((u8 *)&D_80183AB8), D_8019AC54); - func_8001CE28(item, D_8019AC54); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019AC20[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019AC70, 0x84); - func_8001CE68(item, D_8019AC70); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019AC70, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019AC20[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019AC20; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_801627E8); - - -extern void (*D_80183ADC[])(void); - -void func_80162834(void *a0) { - D_80183ADC[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80183ACC; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80183ACC, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019A458[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019A458, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019A458[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019A458, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80183AE4[])(void); - -void func_80163A58(void *a0) { - D_80183AE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019A460; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019A460; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80183B38[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80183B38[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80183B00; -extern s16 D_80183B34; -extern s16 D_80183B32; -extern s16 D_80183B30; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80183B00; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80183B34 = 0x80; - D_80183B32 = 0x80; - D_80183B30 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80183B34 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80183B34` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80183B34 - 8; - D_80183B34 = nv; - D_80183B32 = nv; - D_80183B30 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80183B44[])(void); - -void func_80164BA0(void *a0) { - D_80183B44[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019AC80; -extern u8 D_8019AC81; -extern u8 D_8019AC82; -extern u8 D_8019AC83; -extern u8 D_8019AC84; -extern u8 D_8019AC85; -extern u8 D_8019AC86; -extern u8 D_8019AC87; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019AC80; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019AC81 = 0xf0; - *(u8 *)base = 0xf0; - D_8019AC82 = 0xc0; - D_8019AC86 = 0; - D_8019AC85 = 0; - D_8019AC84 = 0; - D_8019AC87 = 0; - D_8019AC83 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019AC80; -extern u8 D_8019AC81; -extern u8 D_8019AC82; - -s32 func_80164E40(void) { - u8 *p = &D_8019AC80; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019AC81 != 0) { - D_8019AC81 -= 0x10; - } - if (D_8019AC82 != 0) { - D_8019AC82 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80183B54[])(void); - -void func_80164EA4(void *a0) { - D_80183B54[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019ACCC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019ACCC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019ACC0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019ACC0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019ACC0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019ACC0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019ACC0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80183B68[]; - extern u32 D_80183B88, D_80183B8C, D_80183B90, D_80183B94; - extern u32 D_80183B88, D_80183B8C, D_80183B90, D_80183B94; - extern u32 D_80183B88, D_80183B8C, D_80183B90, D_80183B94; - extern u32 D_80183B88, D_80183B8C, D_80183B90, D_80183B94; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80183B68[0x00], p); - ApplyMatrixSV(mat, &D_80183B68[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80183B68[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80183B68[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80183B90; - *(u32 *)(prim + 0x24) = D_80183B88; - *(u32 *)(prim + 0x28) = D_80183B94; - *(u32 *)(prim + 0x2c) = D_80183B8C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80183B98[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80183B98[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80183B98[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80183B98[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80183C14[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80183C14[a1 & 0x7F]; -} - - - -extern s32 D_80183C34[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80183C34[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80183CB0[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80183CB0[a1 & 0x7F]; -} - - - -extern u8 D_80183CD0[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80183CD0[a1 & 0x7F]; -} - - - -extern u8 D_80183CF0[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80183CF0[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80183D10[])(void); - D_80183D10[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80183D8C[])(void); - -void func_80165AC8(void) { - D_80183D8C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80183E08[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80183E08[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019A468; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019A468, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80183E14[])(void); - -void func_80166018(void *a0) { - D_80183E14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80183E1C[])(void); - -void func_801663FC(void *a0) { - D_80183E1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80183EE4[])(void); - -void func_80166618(void *a0) { - D_80183EE4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80183EF4[])(void); - -void func_80166654(void *a0) { - D_80183EF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019AD40[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019AD40[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019AD40). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019AD40[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019AD40)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019AD40[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019AD40[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80183E38[]; - extern u8 D_80183E24[]; - extern u8 D_80183E4C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80183E38; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80183E24; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80183E4C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80167714); - - -extern void (*D_80183F04[])(void); - -void func_801678B4(void *a0) { - D_80183F04[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80183F10[])(void); - -void func_80167A9C(void *a0) { - D_80183F10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018401C; - extern u8 D_80184030[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018401C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184030; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80183E70[]; -extern u8 D_80183E84[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80183E70; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80183E84; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80183F28[])(void); - -void func_80168744(void *a0) { - D_80183F28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80183F18 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80183F18[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80183F18; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80183F30[])(void); - -void func_801689D8(void *a0) { - D_80183F30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80183F38[])(void); - -void func_80168AA8(void *a0) { - D_80183F38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80183F40[])(void); - -void func_80168D58(void *a0) { - D_80183F40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80183F48[])(void); - -void func_8016901C(void *a0) { - D_80183F48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015AE2C", func_80169228); - - -extern void (*D_80183F50[])(void); - -void func_801693CC(void *a0) { - D_80183F50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80183F58[])(void); - -void func_80169830(void *a0) { - D_80183F58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018400C[])(void); - -void func_80169B80(void *a0) { - D_8018400C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80183F60[]; - extern u8 D_80183FD0[]; - extern u8 D_80184000[]; - extern u8 D_8019BD50[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80184000, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80183F60[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019BD50; - RotMatrixYXZ(rot, D_8019BD50); - func_80048D9C(D_8019BD50, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80183FD0); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80184014[])(void); - -void func_80169F00(void *a0) { - D_80184014[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80183FC4[]; -extern char D_80183F84[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80183FC4, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183F84); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018404C[])(void); - -void func_8016A020(void *a0) { - D_8018404C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018401C; - extern u8 D_80184030[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018401C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184030; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80184058[])(void); - -void func_8016A700(void *a0) { - D_80184058[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801840A0[])(void); - -void func_8016AB30(void *a0) { - D_801840A0[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c b/src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c new file mode 100644 index 000000000..5dd5df660 --- /dev/null +++ b/src/ov_SC03_095/ov_SC03_095_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018346C; +extern u8 D_801833DC; +extern u8 D_801833B8; +extern u8 D_80183394; +extern u8 D_80183448; +extern u8 D_80183424; +extern u8 D_80183400; +extern u8 D_80183370; +extern void func_80145934(void); +extern u8 D_801834FC; +extern u8 D_801834D8; +extern u8 D_801834B4; +extern u8 D_80183490; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801828F4[]; +extern unsigned char D_80182924[]; +extern unsigned char D_80182974[]; +extern unsigned char D_801829A4[]; +extern unsigned char D_801829D4[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80182A24[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80182AEC[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80182B74[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80182B7C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019AB70; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019AB74; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80182BAC; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80182C54[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80182C78[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80182C68; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80182C8C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80182C98[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80182CA8[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80182CC0[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80182CB0; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80182CD4[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80182CF0[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80182CE0; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80182D04[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80182D18[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80182D2C; +extern void (*D_80182D54[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80182D34; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80182DA0[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80182DA4[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80183208[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80183218[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019ABA8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80183240[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80183220; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80183230; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80183280[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80183288[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80183254; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80183294[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80183264; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019ABB0; +extern s32 D_8019ABBC; +extern s32 D_8019ABC0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801832D0[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801832A4[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019ABB8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80183520[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80183340[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801835C4[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80183718[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80183534; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80183720[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80183544; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80183564; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80183728[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80183750[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801835D0[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018375C[])(void); + +void func_8015C714(void *a0) { + D_8018375C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801835D0[])(void*); + extern int D_80183574; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801835D0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801835D0)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183574); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801835D0[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801835D0[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801835D0[])(void*); + extern int D_80183574; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801835D0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183574); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801835D0)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018376C[])(void); + D_8018376C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801835D0[])(struct Ent_8015CD20 *); + extern u8 D_80183584; + extern u8 D_80183774; + extern u8 D_80183784; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801835D0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183584); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183774); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183784); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801835D0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801837A4[])(void); + D_801837A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80183794; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80183794 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801835D0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80183800; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80183800, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801828E4[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801828E4; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80183808[])(void); + D_80183808[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80183814[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80183814[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80183814[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80183814[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801835D0[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80183814[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80183594[]; + extern u8 D_801835A4[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183594); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801835A4); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80183814[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183814[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183814[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80183848[])(void); + D_80183848[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801835D0[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80183850[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80183868[])(void); + D_80183868[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801835D0[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80183850[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80183850[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80183888[])(void); + D_80183888[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801835D0[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801835D0)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80183898; +extern u16 D_8018389A; +extern u16 D_8018389C; +extern s32 D_801838A0; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80183898 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018389A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018389C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801838A0, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801838A8; + +void func_8015E588(void) { + func_8013C9C4(&D_801838A8); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801835D0[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801835D0)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801838BC[])(void); + D_801838BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801835D0[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801835D0[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801838C4[])(void); + D_801838C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801835B4; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801835B4); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801835D0[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801838CC[])(void); + D_801838CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801835D0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801835D0[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801838D4[])(void); + D_801838D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801835D0[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801838DC; + extern s32 D_801838EC; + extern s32 D_801838FC; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838DC); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838EC); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801835D0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801838FC); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018390C[])(void); + D_8018390C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801835D0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801835D0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801835D0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801835D0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80183918[])(void); + D_80183918[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801835D0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801835D0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801835D0[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801835D0[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018392C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018392C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801835D0[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801835D0)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801835D0[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801835D0[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801839A8[])(void); + D_801839A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801835D0[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801835D0)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801839B8[])(void); + D_801839B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801835D0[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801835D0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801835D0[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801835D0[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801835D0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801835D0[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801835D0[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801839C0[])(void); + D_801839C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801835D0[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801835D0)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801835D0[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801835D0)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801839CC[])(void); + D_801839CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801835D0 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801835D0[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801835D0[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801835D0[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801839DC[])(void); + +void func_80160EA4(void *a0) { + D_801839DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801835D0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801835D0[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80183A0C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80183A0C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80183A70; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80183A70); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019ABC8[]; + extern u8 D_80183A3C[]; + extern u8 D_80183A5C[]; + extern u8 D_8019ABD4[]; + extern u8 D_8019ABFC[]; + extern u8 D_8019AC14[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019ABC8[0] = p; + func_80024054(&D_80183A3C, &D_8019ABD4); + func_8001CE28(p, &D_8019ABD4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019ABC8[1] = p; + func_80024054(&D_80183A5C, &D_8019ABFC); + func_8001CE28(p, &D_8019ABFC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019ABC8[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019AC14, 0x84); + func_8001CE68(p, &D_8019AC14); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019AC14, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019ABC8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019ABC8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80183A70; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80183A70; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80183A70; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80183A70; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019ABC8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019ABC8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80183A94[])(void); + +void func_80162330(void *a0) { + D_80183A94[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019AC20[i] via `extern int D_8019AC20[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80183AA0[]; + extern s32 D_80183AB8; + extern u8 D_8019AC2C[]; + extern u8 D_8019AC54[]; + extern u8 D_8019AC70[]; + extern int D_8019AC20[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019AC20[0] = (s32)item; + func_80024054(D_80183AA0, D_8019AC2C); + func_8001CE28(item, D_8019AC2C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019AC20[1] = (s32)item; + func_80024054(((u8 *)&D_80183AB8), D_8019AC54); + func_8001CE28(item, D_8019AC54); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019AC20[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019AC70, 0x84); + func_8001CE68(item, D_8019AC70); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019AC70, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019AC20[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019AC20; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_801627E8); + + +extern void (*D_80183ADC[])(void); + +void func_80162834(void *a0) { + D_80183ADC[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80183ACC; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80183ACC, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019A458[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019A458, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019A458[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019A458, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80183AE4[])(void); + +void func_80163A58(void *a0) { + D_80183AE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019A460; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019A460; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80183B38[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80183B38[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80183B00; +extern s16 D_80183B34; +extern s16 D_80183B32; +extern s16 D_80183B30; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80183B00; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80183B34 = 0x80; + D_80183B32 = 0x80; + D_80183B30 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80183B34 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80183B34` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80183B34 - 8; + D_80183B34 = nv; + D_80183B32 = nv; + D_80183B30 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80183B44[])(void); + +void func_80164BA0(void *a0) { + D_80183B44[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019AC80; +extern u8 D_8019AC81; +extern u8 D_8019AC82; +extern u8 D_8019AC83; +extern u8 D_8019AC84; +extern u8 D_8019AC85; +extern u8 D_8019AC86; +extern u8 D_8019AC87; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019AC80; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019AC81 = 0xf0; + *(u8 *)base = 0xf0; + D_8019AC82 = 0xc0; + D_8019AC86 = 0; + D_8019AC85 = 0; + D_8019AC84 = 0; + D_8019AC87 = 0; + D_8019AC83 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019AC80; +extern u8 D_8019AC81; +extern u8 D_8019AC82; + +s32 func_80164E40(void) { + u8 *p = &D_8019AC80; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019AC81 != 0) { + D_8019AC81 -= 0x10; + } + if (D_8019AC82 != 0) { + D_8019AC82 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80183B54[])(void); + +void func_80164EA4(void *a0) { + D_80183B54[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019ACCC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019ACCC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019ACC0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019ACC0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019ACC0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019ACC0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019ACC0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80183B68[]; + extern u32 D_80183B88, D_80183B8C, D_80183B90, D_80183B94; + extern u32 D_80183B88, D_80183B8C, D_80183B90, D_80183B94; + extern u32 D_80183B88, D_80183B8C, D_80183B90, D_80183B94; + extern u32 D_80183B88, D_80183B8C, D_80183B90, D_80183B94; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80183B68[0x00], p); + ApplyMatrixSV(mat, &D_80183B68[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80183B68[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80183B68[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80183B90; + *(u32 *)(prim + 0x24) = D_80183B88; + *(u32 *)(prim + 0x28) = D_80183B94; + *(u32 *)(prim + 0x2c) = D_80183B8C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80183B98[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80183B98[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80183B98[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80183B98[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80183C14[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80183C14[a1 & 0x7F]; +} + + + +extern s32 D_80183C34[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80183C34[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80183CB0[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80183CB0[a1 & 0x7F]; +} + + + +extern u8 D_80183CD0[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80183CD0[a1 & 0x7F]; +} + + + +extern u8 D_80183CF0[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80183CF0[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80183D10[])(void); + D_80183D10[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80183D8C[])(void); + +void func_80165AC8(void) { + D_80183D8C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80183E08[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80183E08[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019A468; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019A468, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80183E14[])(void); + +void func_80166018(void *a0) { + D_80183E14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80183E1C[])(void); + +void func_801663FC(void *a0) { + D_80183E1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80183EE4[])(void); + +void func_80166618(void *a0) { + D_80183EE4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80183EF4[])(void); + +void func_80166654(void *a0) { + D_80183EF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019AD40[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019AD40[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019AD40). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019AD40[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019AD40)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019AD40[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019AD40[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80183E38[]; + extern u8 D_80183E24[]; + extern u8 D_80183E4C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80183E38; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80183E24; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80183E4C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80167714); + + +extern void (*D_80183F04[])(void); + +void func_801678B4(void *a0) { + D_80183F04[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80183F10[])(void); + +void func_80167A9C(void *a0) { + D_80183F10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018401C; + extern u8 D_80184030[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018401C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184030; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80183E70[]; +extern u8 D_80183E84[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80183E70; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80183E84; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80183F28[])(void); + +void func_80168744(void *a0) { + D_80183F28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80183F18 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80183F18[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80183F18; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80183F30[])(void); + +void func_801689D8(void *a0) { + D_80183F30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80183F38[])(void); + +void func_80168AA8(void *a0) { + D_80183F38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80183F40[])(void); + +void func_80168D58(void *a0) { + D_80183F40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80183F48[])(void); + +void func_8016901C(void *a0) { + D_80183F48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_095/nonmatchings/ov_SC03_095_jr_8015C32C", func_80169228); + + +extern void (*D_80183F50[])(void); + +void func_801693CC(void *a0) { + D_80183F50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80183F58[])(void); + +void func_80169830(void *a0) { + D_80183F58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018400C[])(void); + +void func_80169B80(void *a0) { + D_8018400C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80183F60[]; + extern u8 D_80183FD0[]; + extern u8 D_80184000[]; + extern u8 D_8019BD50[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80184000, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80183F60[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019BD50; + RotMatrixYXZ(rot, D_8019BD50); + func_80048D9C(D_8019BD50, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80183FD0); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80184014[])(void); + +void func_80169F00(void *a0) { + D_80184014[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80183FC4[]; +extern char D_80183F84[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80183FC4, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183F84); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018404C[])(void); + +void func_8016A020(void *a0) { + D_8018404C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018401C; + extern u8 D_80184030[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018401C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184030; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80184058[])(void); + +void func_8016A700(void *a0) { + D_80184058[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801840A0[])(void); + +void func_8016AB30(void *a0) { + D_801840A0[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_096/ov_SC03_096_jr_8015AE2C.c b/src/ov_SC03_096/ov_SC03_096_jr_8015AE2C.c index 5402adbbd..4edc848c9 100644 --- a/src/ov_SC03_096/ov_SC03_096_jr_8015AE2C.c +++ b/src/ov_SC03_096/ov_SC03_096_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801832DC[])(void); - -void func_8015C714(void *a0) { - D_801832DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80183150[])(void*); - extern int D_801830F4; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80183150)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80183150)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801830F4); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80183150[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80183150[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80183150[])(void*); - extern int D_801830F4; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80183150)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801830F4); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80183150)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801832EC[])(void); - D_801832EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80183150[])(struct Ent_8015CD20 *); - extern u8 D_80183104; - extern u8 D_801832F4; - extern u8 D_80183304; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80183150[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183104); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801832F4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183304); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80183150[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80183324[])(void); - D_80183324[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80183314; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80183314 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80183150[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80183380; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80183380, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80182464[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80182464; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80183388[])(void); - D_80183388[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80183394[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80183394[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80183394[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80183394[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80183150[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80183394[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80183114[]; - extern u8 D_80183124[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183114); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183124); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80183394[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183394[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183394[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801833C8[])(void); - D_801833C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80183150[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801833D0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801833E8[])(void); - D_801833E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80183150[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801833D0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80183408[])(void); - D_80183408[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80183150[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80183150)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80183418; -extern u16 D_8018341A; -extern u16 D_8018341C; -extern s32 D_80183420; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80183418 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018341A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018341C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80183420, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80183428; - -void func_8015E588(void) { - func_8013C9C4(&D_80183428); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80183150[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80183150)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018343C[])(void); - D_8018343C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80183150[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80183150[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80183444[])(void); - D_80183444[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80183134; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80183134); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80183150[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018344C[])(void); - D_8018344C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80183150[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80183150[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80183454[])(void); - D_80183454[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80183150[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018345C; - extern s32 D_8018346C; - extern s32 D_8018347C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80183150[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018345C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018346C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80183150[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018347C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018348C[])(void); - D_8018348C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80183150[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80183150[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80183150[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80183150[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80183498[])(void); - D_80183498[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80183150[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80183150[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80183150[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80183150[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801834AC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801834AC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80183150[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80183150)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80183150[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80183150[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80183528[])(void); - D_80183528[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80183150[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80183150)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80183538[])(void); - D_80183538[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80183150[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80183150[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80183150[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80183150[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80183150[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80183150[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80183150[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80183540[])(void); - D_80183540[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80183150[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80183150)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80183150[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80183150)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018354C[])(void); - D_8018354C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80183150 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80183150[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80183150[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80183150[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018355C[])(void); - -void func_80160EA4(void *a0) { - D_8018355C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80183150[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80183150[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018358C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018358C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801835F0; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801835F0); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80199680[]; - extern u8 D_801835BC[]; - extern u8 D_801835DC[]; - extern u8 D_8019968C[]; - extern u8 D_801996B4[]; - extern u8 D_801996CC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80199680[0] = p; - func_80024054(&D_801835BC, &D_8019968C); - func_8001CE28(p, &D_8019968C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80199680[1] = p; - func_80024054(&D_801835DC, &D_801996B4); - func_8001CE28(p, &D_801996B4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80199680[2] = p; - func_800242D0((s16)func_801620C4(), &D_801996CC, 0x84); - func_8001CE68(p, &D_801996CC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801996CC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80199680[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80199680; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801835F0; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801835F0; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801835F0; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801835F0; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80199680[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80199680; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80183614[])(void); - -void func_80162330(void *a0) { - D_80183614[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801996D8[i] via `extern int D_801996D8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80183620[]; - extern s32 D_80183638; - extern u8 D_801996E4[]; - extern u8 D_8019970C[]; - extern u8 D_80199728[]; - extern int D_801996D8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801996D8[0] = (s32)item; - func_80024054(D_80183620, D_801996E4); - func_8001CE28(item, D_801996E4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801996D8[1] = (s32)item; - func_80024054(((u8 *)&D_80183638), D_8019970C); - func_8001CE28(item, D_8019970C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801996D8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80199728, 0x84); - func_8001CE68(item, D_80199728); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80199728, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801996D8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801996D8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018365C[])(void); - -void func_80162834(void *a0) { - D_8018365C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018364C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018364C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80198F0C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80198F0C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80198F0C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80198F0C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80183664[])(void); - -void func_80163A58(void *a0) { - D_80183664[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80198F14; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80198F14; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801836B8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801836B8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80183680; -extern s16 D_801836B4; -extern s16 D_801836B2; -extern s16 D_801836B0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80183680; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801836B4 = 0x80; - D_801836B2 = 0x80; - D_801836B0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801836B4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801836B4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801836B4 - 8; - D_801836B4 = nv; - D_801836B2 = nv; - D_801836B0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801836C4[])(void); - -void func_80164BA0(void *a0) { - D_801836C4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80199738; -extern u8 D_80199739; -extern u8 D_8019973A; -extern u8 D_8019973B; -extern u8 D_8019973C; -extern u8 D_8019973D; -extern u8 D_8019973E; -extern u8 D_8019973F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80199738; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80199739 = 0xf0; - *(u8 *)base = 0xf0; - D_8019973A = 0xc0; - D_8019973E = 0; - D_8019973D = 0; - D_8019973C = 0; - D_8019973F = 0; - D_8019973B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80199738; -extern u8 D_80199739; -extern u8 D_8019973A; - -s32 func_80164E40(void) { - u8 *p = &D_80199738; - if (*p != 0) { - *p -= 0x10; - } - if (D_80199739 != 0) { - D_80199739 -= 0x10; - } - if (D_8019973A != 0) { - D_8019973A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801836D4[])(void); - -void func_80164EA4(void *a0) { - D_801836D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80199784[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80199784[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80199778[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80199778[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80199778[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80199778; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80199778; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801836E8[]; - extern u32 D_80183708, D_8018370C, D_80183710, D_80183714; - extern u32 D_80183708, D_8018370C, D_80183710, D_80183714; - extern u32 D_80183708, D_8018370C, D_80183710, D_80183714; - extern u32 D_80183708, D_8018370C, D_80183710, D_80183714; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801836E8[0x00], p); - ApplyMatrixSV(mat, &D_801836E8[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801836E8[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801836E8[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80183710; - *(u32 *)(prim + 0x24) = D_80183708; - *(u32 *)(prim + 0x28) = D_80183714; - *(u32 *)(prim + 0x2c) = D_8018370C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80183718[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80183718[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80183718[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80183718[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80183794[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80183794[a1 & 0x7F]; -} - - - -extern s32 D_801837B4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801837B4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80183830[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80183830[a1 & 0x7F]; -} - - - -extern u8 D_80183850[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80183850[a1 & 0x7F]; -} - - - -extern u8 D_80183870[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80183870[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80183890[])(void); - D_80183890[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018390C[])(void); - -void func_80165AC8(void) { - D_8018390C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80183988[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80183988[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80198F1C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80198F1C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80183994[])(void); - -void func_80166018(void *a0) { - D_80183994[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018399C[])(void); - -void func_801663FC(void *a0) { - D_8018399C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80183A64[])(void); - -void func_80166618(void *a0) { - D_80183A64[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80183A74[])(void); - -void func_80166654(void *a0) { - D_80183A74[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801997F8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801997F8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801997F8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801997F8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801997F8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801997F8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801997F8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801839B8[]; - extern u8 D_801839A4[]; - extern u8 D_801839CC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801839B8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801839A4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801839CC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80167714); - - -extern void (*D_80183A84[])(void); - -void func_801678B4(void *a0) { - D_80183A84[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80183A90[])(void); - -void func_80167A9C(void *a0) { - D_80183A90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80183B9C; - extern u8 D_80183BB0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80183B9C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80183BB0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801839F0[]; -extern u8 D_80183A04[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801839F0; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80183A04; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80183AA8[])(void); - -void func_80168744(void *a0) { - D_80183AA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80183A98 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80183A98[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80183A98; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80183AB0[])(void); - -void func_801689D8(void *a0) { - D_80183AB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80183AB8[])(void); - -void func_80168AA8(void *a0) { - D_80183AB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80183AC0[])(void); - -void func_80168D58(void *a0) { - D_80183AC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80183AC8[])(void); - -void func_8016901C(void *a0) { - D_80183AC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015AE2C", func_80169228); - - -extern void (*D_80183AD0[])(void); - -void func_801693CC(void *a0) { - D_80183AD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80183AD8[])(void); - -void func_80169830(void *a0) { - D_80183AD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80183B8C[])(void); - -void func_80169B80(void *a0) { - D_80183B8C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80183AE0[]; - extern u8 D_80183B50[]; - extern u8 D_80183B80[]; - extern u8 D_8019A808[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80183B80, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80183AE0[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019A808; - RotMatrixYXZ(rot, D_8019A808); - func_80048D9C(D_8019A808, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80183B50); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80183B94[])(void); - -void func_80169F00(void *a0) { - D_80183B94[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80183B44[]; -extern char D_80183B04[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80183B44, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183B04); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80183BCC[])(void); - -void func_8016A020(void *a0) { - D_80183BCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80183B9C; - extern u8 D_80183BB0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80183B9C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80183BB0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80183BD8[])(void); - -void func_8016A700(void *a0) { - D_80183BD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80183C20[])(void); - -void func_8016AB30(void *a0) { - D_80183C20[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c b/src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c new file mode 100644 index 000000000..c1b13afd2 --- /dev/null +++ b/src/ov_SC03_096/ov_SC03_096_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80182FEC; +extern u8 D_80182F5C; +extern u8 D_80182F38; +extern u8 D_80182F14; +extern u8 D_80182FC8; +extern u8 D_80182FA4; +extern u8 D_80182F80; +extern u8 D_80182EF0; +extern void func_80145934(void); +extern u8 D_8018307C; +extern u8 D_80183058; +extern u8 D_80183034; +extern u8 D_80183010; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80182474[]; +extern unsigned char D_801824A4[]; +extern unsigned char D_801824F4[]; +extern unsigned char D_80182524[]; +extern unsigned char D_80182554[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801825A4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018266C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801826F4[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801826FC; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80199628; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019962C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018272C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801827D4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801827F8[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801827E8; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018280C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80182818[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80182828[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80182840[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80182830; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80182854[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80182870[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80182860; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80182884[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80182898[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801828AC; +extern void (*D_801828D4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801828B4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80182920[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80182924[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80182D88[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80182D98[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80199660; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80182DC0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80182DA0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80182DB0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80182E00[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80182E08[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80182DD4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80182E14[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80182DE4; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80199668; +extern s32 D_80199674; +extern s32 D_80199678; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80182E50[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80182E24[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80199670; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801830A0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80182EC0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80183144[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80183298[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801830B4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801832A0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801830C4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801830E4; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801832A8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801832D0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80183150[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80183150[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80183150[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80183150[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80183150[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80183150[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80183150[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80183150[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801832DC[])(void); + +void func_8015C714(void *a0) { + D_801832DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80183150[])(void*); + extern int D_801830F4; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80183150)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80183150)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801830F4); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80183150[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80183150[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80183150[])(void*); + extern int D_801830F4; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80183150)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801830F4); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80183150)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801832EC[])(void); + D_801832EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80183150[])(struct Ent_8015CD20 *); + extern u8 D_80183104; + extern u8 D_801832F4; + extern u8 D_80183304; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80183150[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183104); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801832F4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183304); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80183150[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80183324[])(void); + D_80183324[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80183314; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80183314 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80183150[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80183380; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80183380, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80182464[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80182464; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80183388[])(void); + D_80183388[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80183394[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80183394[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80183394[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80183394[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80183150[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80183394[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80183114[]; + extern u8 D_80183124[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183114); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183124); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80183394[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183394[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183394[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801833C8[])(void); + D_801833C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80183150[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801833D0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801833E8[])(void); + D_801833E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80183150[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801833D0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801833D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80183408[])(void); + D_80183408[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80183150[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80183150)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80183418; +extern u16 D_8018341A; +extern u16 D_8018341C; +extern s32 D_80183420; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80183418 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018341A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018341C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80183420, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80183428; + +void func_8015E588(void) { + func_8013C9C4(&D_80183428); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80183150[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80183150)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018343C[])(void); + D_8018343C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80183150[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80183150[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80183444[])(void); + D_80183444[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80183134; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80183134); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80183150[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018344C[])(void); + D_8018344C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80183150[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80183150[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80183454[])(void); + D_80183454[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80183150[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018345C; + extern s32 D_8018346C; + extern s32 D_8018347C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80183150[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018345C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018346C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80183150[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018347C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018348C[])(void); + D_8018348C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80183150[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80183150[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80183150[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80183150[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80183498[])(void); + D_80183498[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80183150[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80183150[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80183150[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80183150[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801834AC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801834AC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80183150[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80183150)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80183150[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80183150[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80183528[])(void); + D_80183528[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80183150[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80183150)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80183538[])(void); + D_80183538[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80183150[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80183150[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80183150[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80183150[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80183150[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80183150[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80183150[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80183540[])(void); + D_80183540[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80183150[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80183150)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80183150[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80183150)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018354C[])(void); + D_8018354C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80183150 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80183150[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80183150[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80183150[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018355C[])(void); + +void func_80160EA4(void *a0) { + D_8018355C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80183150[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80183150[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018358C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018358C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801835F0; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801835F0); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80199680[]; + extern u8 D_801835BC[]; + extern u8 D_801835DC[]; + extern u8 D_8019968C[]; + extern u8 D_801996B4[]; + extern u8 D_801996CC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80199680[0] = p; + func_80024054(&D_801835BC, &D_8019968C); + func_8001CE28(p, &D_8019968C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80199680[1] = p; + func_80024054(&D_801835DC, &D_801996B4); + func_8001CE28(p, &D_801996B4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80199680[2] = p; + func_800242D0((s16)func_801620C4(), &D_801996CC, 0x84); + func_8001CE68(p, &D_801996CC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801996CC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80199680[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80199680; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801835F0; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801835F0; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801835F0; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801835F0; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80199680[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80199680; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80183614[])(void); + +void func_80162330(void *a0) { + D_80183614[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801996D8[i] via `extern int D_801996D8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80183620[]; + extern s32 D_80183638; + extern u8 D_801996E4[]; + extern u8 D_8019970C[]; + extern u8 D_80199728[]; + extern int D_801996D8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801996D8[0] = (s32)item; + func_80024054(D_80183620, D_801996E4); + func_8001CE28(item, D_801996E4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801996D8[1] = (s32)item; + func_80024054(((u8 *)&D_80183638), D_8019970C); + func_8001CE28(item, D_8019970C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801996D8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80199728, 0x84); + func_8001CE68(item, D_80199728); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80199728, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801996D8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801996D8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_801627E8); + + +extern void (*D_8018365C[])(void); + +void func_80162834(void *a0) { + D_8018365C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018364C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018364C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80198F0C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80198F0C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80198F0C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80198F0C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80183664[])(void); + +void func_80163A58(void *a0) { + D_80183664[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80198F14; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80198F14; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801836B8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801836B8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80183680; +extern s16 D_801836B4; +extern s16 D_801836B2; +extern s16 D_801836B0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80183680; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801836B4 = 0x80; + D_801836B2 = 0x80; + D_801836B0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801836B4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801836B4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801836B4 - 8; + D_801836B4 = nv; + D_801836B2 = nv; + D_801836B0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801836C4[])(void); + +void func_80164BA0(void *a0) { + D_801836C4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80199738; +extern u8 D_80199739; +extern u8 D_8019973A; +extern u8 D_8019973B; +extern u8 D_8019973C; +extern u8 D_8019973D; +extern u8 D_8019973E; +extern u8 D_8019973F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80199738; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80199739 = 0xf0; + *(u8 *)base = 0xf0; + D_8019973A = 0xc0; + D_8019973E = 0; + D_8019973D = 0; + D_8019973C = 0; + D_8019973F = 0; + D_8019973B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80199738; +extern u8 D_80199739; +extern u8 D_8019973A; + +s32 func_80164E40(void) { + u8 *p = &D_80199738; + if (*p != 0) { + *p -= 0x10; + } + if (D_80199739 != 0) { + D_80199739 -= 0x10; + } + if (D_8019973A != 0) { + D_8019973A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801836D4[])(void); + +void func_80164EA4(void *a0) { + D_801836D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80199784[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80199784[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80199778[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80199778[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80199778[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80199778; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80199778; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801836E8[]; + extern u32 D_80183708, D_8018370C, D_80183710, D_80183714; + extern u32 D_80183708, D_8018370C, D_80183710, D_80183714; + extern u32 D_80183708, D_8018370C, D_80183710, D_80183714; + extern u32 D_80183708, D_8018370C, D_80183710, D_80183714; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801836E8[0x00], p); + ApplyMatrixSV(mat, &D_801836E8[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801836E8[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801836E8[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80183710; + *(u32 *)(prim + 0x24) = D_80183708; + *(u32 *)(prim + 0x28) = D_80183714; + *(u32 *)(prim + 0x2c) = D_8018370C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80183718[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80183718[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80183718[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80183718[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80183794[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80183794[a1 & 0x7F]; +} + + + +extern s32 D_801837B4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801837B4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80183830[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80183830[a1 & 0x7F]; +} + + + +extern u8 D_80183850[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80183850[a1 & 0x7F]; +} + + + +extern u8 D_80183870[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80183870[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80183890[])(void); + D_80183890[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018390C[])(void); + +void func_80165AC8(void) { + D_8018390C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80183988[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80183988[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80198F1C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80198F1C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80183994[])(void); + +void func_80166018(void *a0) { + D_80183994[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018399C[])(void); + +void func_801663FC(void *a0) { + D_8018399C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80183A64[])(void); + +void func_80166618(void *a0) { + D_80183A64[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80183A74[])(void); + +void func_80166654(void *a0) { + D_80183A74[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801997F8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801997F8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801997F8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801997F8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801997F8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801997F8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801997F8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801839B8[]; + extern u8 D_801839A4[]; + extern u8 D_801839CC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801839B8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801839A4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801839CC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80167714); + + +extern void (*D_80183A84[])(void); + +void func_801678B4(void *a0) { + D_80183A84[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80183A90[])(void); + +void func_80167A9C(void *a0) { + D_80183A90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80183B9C; + extern u8 D_80183BB0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80183B9C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80183BB0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801839F0[]; +extern u8 D_80183A04[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801839F0; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80183A04; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80183AA8[])(void); + +void func_80168744(void *a0) { + D_80183AA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80183A98 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80183A98[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80183A98; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80183AB0[])(void); + +void func_801689D8(void *a0) { + D_80183AB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80183AB8[])(void); + +void func_80168AA8(void *a0) { + D_80183AB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80183AC0[])(void); + +void func_80168D58(void *a0) { + D_80183AC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80183AC8[])(void); + +void func_8016901C(void *a0) { + D_80183AC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_096/nonmatchings/ov_SC03_096_jr_8015C32C", func_80169228); + + +extern void (*D_80183AD0[])(void); + +void func_801693CC(void *a0) { + D_80183AD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80183AD8[])(void); + +void func_80169830(void *a0) { + D_80183AD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80183B8C[])(void); + +void func_80169B80(void *a0) { + D_80183B8C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80183AE0[]; + extern u8 D_80183B50[]; + extern u8 D_80183B80[]; + extern u8 D_8019A808[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80183B80, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80183AE0[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019A808; + RotMatrixYXZ(rot, D_8019A808); + func_80048D9C(D_8019A808, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80183B50); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80183B94[])(void); + +void func_80169F00(void *a0) { + D_80183B94[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80183B44[]; +extern char D_80183B04[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80183B44, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183B04); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80183BCC[])(void); + +void func_8016A020(void *a0) { + D_80183BCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80183B9C; + extern u8 D_80183BB0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80183B9C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80183BB0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80183BD8[])(void); + +void func_8016A700(void *a0) { + D_80183BD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80183C20[])(void); + +void func_8016AB30(void *a0) { + D_80183C20[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_097/ov_SC03_097_jr_8015AE2C.c b/src/ov_SC03_097/ov_SC03_097_jr_8015AE2C.c index 68c62c835..f00b509a4 100644 --- a/src/ov_SC03_097/ov_SC03_097_jr_8015AE2C.c +++ b/src/ov_SC03_097/ov_SC03_097_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801886BC[])(void); - -void func_8015C714(void *a0) { - D_801886BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80188530[])(void*); - extern int D_801884D4; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80188530)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80188530)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801884D4); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80188530[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80188530[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80188530[])(void*); - extern int D_801884D4; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80188530)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801884D4); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80188530)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801886CC[])(void); - D_801886CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80188530[])(struct Ent_8015CD20 *); - extern u8 D_801884E4; - extern u8 D_801886D4; - extern u8 D_801886E4; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80188530[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801884E4); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801886D4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801886E4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80188530[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80188704[])(void); - D_80188704[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801886F4; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801886F4 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80188530[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80188760; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80188760, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80187844[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80187844; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80188768[])(void); - D_80188768[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80188774[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80188774[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80188774[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80188774[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80188530[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80188774[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801884F4[]; - extern u8 D_80188504[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801884F4); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188504); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80188774[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80188774[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80188774[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801887A8[])(void); - D_801887A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188530[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801887B0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801887C8[])(void); - D_801887C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188530[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801887B0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801887E8[])(void); - D_801887E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80188530[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188530)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801887F8; -extern u16 D_801887FA; -extern u16 D_801887FC; -extern s32 D_80188800; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801887F8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801887FA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801887FC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188800, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80188808; - -void func_8015E588(void) { - func_8013C9C4(&D_80188808); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80188530[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188530)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018881C[])(void); - D_8018881C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80188530[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80188530[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80188824[])(void); - D_80188824[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80188514; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188514); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80188530[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018882C[])(void); - D_8018882C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80188530[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80188530[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80188834[])(void); - D_80188834[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80188530[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018883C; - extern s32 D_8018884C; - extern s32 D_8018885C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80188530[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018883C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018884C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80188530[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018885C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018886C[])(void); - D_8018886C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80188530[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80188530[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80188530[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188530[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80188878[])(void); - D_80188878[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80188530[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188530[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80188530[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188530[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018888C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018888C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80188530[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80188530)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80188530[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188530[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80188908[])(void); - D_80188908[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80188530[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80188530)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80188918[])(void); - D_80188918[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80188530[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80188530[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80188530[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80188530[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80188530[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80188530[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80188530[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80188920[])(void); - D_80188920[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80188530[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80188530)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80188530[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80188530)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018892C[])(void); - D_8018892C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188530 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80188530[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80188530[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80188530[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018893C[])(void); - -void func_80160EA4(void *a0) { - D_8018893C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80188530[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80188530[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018896C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018896C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801889D0; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801889D0); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A9708[]; - extern u8 D_8018899C[]; - extern u8 D_801889BC[]; - extern u8 D_801A9714[]; - extern u8 D_801A973C[]; - extern u8 D_801A9754[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A9708[0] = p; - func_80024054(&D_8018899C, &D_801A9714); - func_8001CE28(p, &D_801A9714); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A9708[1] = p; - func_80024054(&D_801889BC, &D_801A973C); - func_8001CE28(p, &D_801A973C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A9708[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A9754, 0x84); - func_8001CE68(p, &D_801A9754); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A9754, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A9708[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A9708; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801889D0; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801889D0; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801889D0; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801889D0; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A9708[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A9708; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801889F4[])(void); - -void func_80162330(void *a0) { - D_801889F4[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A9760[i] via `extern int D_801A9760[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80188A00[]; - extern s32 D_80188A18; - extern u8 D_801A976C[]; - extern u8 D_801A9794[]; - extern u8 D_801A97B0[]; - extern int D_801A9760[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A9760[0] = (s32)item; - func_80024054(D_80188A00, D_801A976C); - func_8001CE28(item, D_801A976C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A9760[1] = (s32)item; - func_80024054(((u8 *)&D_80188A18), D_801A9794); - func_8001CE28(item, D_801A9794); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A9760[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A97B0, 0x84); - func_8001CE68(item, D_801A97B0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A97B0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A9760[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A9760; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_801627E8); - - -extern void (*D_80188A3C[])(void); - -void func_80162834(void *a0) { - D_80188A3C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80188A2C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80188A2C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801A8F7C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801A8F7C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801A8F7C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801A8F7C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80188A44[])(void); - -void func_80163A58(void *a0) { - D_80188A44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801A8F84; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801A8F84; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80188A98[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80188A98[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80188A60; -extern s16 D_80188A94; -extern s16 D_80188A92; -extern s16 D_80188A90; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80188A60; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80188A94 = 0x80; - D_80188A92 = 0x80; - D_80188A90 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80188A94 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188A94` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80188A94 - 8; - D_80188A94 = nv; - D_80188A92 = nv; - D_80188A90 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80188AA4[])(void); - -void func_80164BA0(void *a0) { - D_80188AA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A97C0; -extern u8 D_801A97C1; -extern u8 D_801A97C2; -extern u8 D_801A97C3; -extern u8 D_801A97C4; -extern u8 D_801A97C5; -extern u8 D_801A97C6; -extern u8 D_801A97C7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A97C0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A97C1 = 0xf0; - *(u8 *)base = 0xf0; - D_801A97C2 = 0xc0; - D_801A97C6 = 0; - D_801A97C5 = 0; - D_801A97C4 = 0; - D_801A97C7 = 0; - D_801A97C3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A97C0; -extern u8 D_801A97C1; -extern u8 D_801A97C2; - -s32 func_80164E40(void) { - u8 *p = &D_801A97C0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A97C1 != 0) { - D_801A97C1 -= 0x10; - } - if (D_801A97C2 != 0) { - D_801A97C2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80188AB4[])(void); - -void func_80164EA4(void *a0) { - D_80188AB4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A980C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A980C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A9800[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A9800[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A9800[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A9800; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A9800; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80188AC8[]; - extern u32 D_80188AE8, D_80188AEC, D_80188AF0, D_80188AF4; - extern u32 D_80188AE8, D_80188AEC, D_80188AF0, D_80188AF4; - extern u32 D_80188AE8, D_80188AEC, D_80188AF0, D_80188AF4; - extern u32 D_80188AE8, D_80188AEC, D_80188AF0, D_80188AF4; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80188AC8[0x00], p); - ApplyMatrixSV(mat, &D_80188AC8[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80188AC8[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80188AC8[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80188AF0; - *(u32 *)(prim + 0x24) = D_80188AE8; - *(u32 *)(prim + 0x28) = D_80188AF4; - *(u32 *)(prim + 0x2c) = D_80188AEC; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80188AF8[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80188AF8[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80188AF8[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80188AF8[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80188B74[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80188B74[a1 & 0x7F]; -} - - - -extern s32 D_80188B94[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80188B94[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80188C10[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80188C10[a1 & 0x7F]; -} - - - -extern u8 D_80188C30[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80188C30[a1 & 0x7F]; -} - - - -extern u8 D_80188C50[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80188C50[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80188C70[])(void); - D_80188C70[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80188CEC[])(void); - -void func_80165AC8(void) { - D_80188CEC[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80188D68[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80188D68[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801A8F8C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801A8F8C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80188D74[])(void); - -void func_80166018(void *a0) { - D_80188D74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80188D7C[])(void); - -void func_801663FC(void *a0) { - D_80188D7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80188E44[])(void); - -void func_80166618(void *a0) { - D_80188E44[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80188E54[])(void); - -void func_80166654(void *a0) { - D_80188E54[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A9880[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A9880[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A9880). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A9880[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A9880)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A9880[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A9880[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80188D98[]; - extern u8 D_80188D84[]; - extern u8 D_80188DAC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80188D98; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80188D84; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80188DAC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80167714); - - -extern void (*D_80188E64[])(void); - -void func_801678B4(void *a0) { - D_80188E64[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80188E70[])(void); - -void func_80167A9C(void *a0) { - D_80188E70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80188F7C; - extern u8 D_80188F90[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80188F7C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188F90; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80188DD0[]; -extern u8 D_80188DE4[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80188DD0; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80188DE4; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80188E88[])(void); - -void func_80168744(void *a0) { - D_80188E88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80188E78 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80188E78[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80188E78; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80188E90[])(void); - -void func_801689D8(void *a0) { - D_80188E90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80188E98[])(void); - -void func_80168AA8(void *a0) { - D_80188E98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80188EA0[])(void); - -void func_80168D58(void *a0) { - D_80188EA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80188EA8[])(void); - -void func_8016901C(void *a0) { - D_80188EA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015AE2C", func_80169228); - - -extern void (*D_80188EB0[])(void); - -void func_801693CC(void *a0) { - D_80188EB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80188EB8[])(void); - -void func_80169830(void *a0) { - D_80188EB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80188F6C[])(void); - -void func_80169B80(void *a0) { - D_80188F6C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80188EC0[]; - extern u8 D_80188F30[]; - extern u8 D_80188F60[]; - extern u8 D_801AAD88[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80188F60, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80188EC0[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801AAD88; - RotMatrixYXZ(rot, D_801AAD88); - func_80048D9C(D_801AAD88, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80188F30); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80188F74[])(void); - -void func_80169F00(void *a0) { - D_80188F74[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80188F24[]; -extern char D_80188EE4[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80188F24, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188EE4); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80188FAC[])(void); - -void func_8016A020(void *a0) { - D_80188FAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80188F7C; - extern u8 D_80188F90[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80188F7C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188F90; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80188FB8[])(void); - -void func_8016A700(void *a0) { - D_80188FB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80189000[])(void); - -void func_8016AB30(void *a0) { - D_80189000[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c b/src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c new file mode 100644 index 000000000..20302b659 --- /dev/null +++ b/src/ov_SC03_097/ov_SC03_097_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801883CC; +extern u8 D_8018833C; +extern u8 D_80188318; +extern u8 D_801882F4; +extern u8 D_801883A8; +extern u8 D_80188384; +extern u8 D_80188360; +extern u8 D_801882D0; +extern void func_80145934(void); +extern u8 D_8018845C; +extern u8 D_80188438; +extern u8 D_80188414; +extern u8 D_801883F0; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80187854[]; +extern unsigned char D_80187884[]; +extern unsigned char D_801878D4[]; +extern unsigned char D_80187904[]; +extern unsigned char D_80187934[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80187984[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80187A4C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80187AD4[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80187ADC; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A96B0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A96B4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80187B0C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80187BB4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80187BD8[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80187BC8; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80187BEC[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80187BF8[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80187C08[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80187C20[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80187C10; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80187C34[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80187C50[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80187C40; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80187C64[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80187C78[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80187C8C; +extern void (*D_80187CB4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80187C94; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80187D00[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80187D04[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80188168[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80188178[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A96E8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801881A0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80188180; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80188190; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801881E0[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801881E8[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801881B4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801881F4[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801881C4; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A96F0; +extern s32 D_801A96FC; +extern s32 D_801A9700; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80188230[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80188204[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A96F8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80188480[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801882A0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80188524[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80188678[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80188494; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80188680[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801884A4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801884C4; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80188688[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801886B0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80188530[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80188530[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80188530[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80188530[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80188530[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80188530[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80188530[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80188530[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801886BC[])(void); + +void func_8015C714(void *a0) { + D_801886BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80188530[])(void*); + extern int D_801884D4; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80188530)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80188530)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801884D4); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80188530[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80188530[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80188530[])(void*); + extern int D_801884D4; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80188530)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801884D4); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80188530)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801886CC[])(void); + D_801886CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80188530[])(struct Ent_8015CD20 *); + extern u8 D_801884E4; + extern u8 D_801886D4; + extern u8 D_801886E4; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80188530[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801884E4); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801886D4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801886E4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80188530[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80188704[])(void); + D_80188704[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801886F4; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801886F4 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80188530[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80188760; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80188760, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80187844[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80187844; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80188768[])(void); + D_80188768[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80188774[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80188774[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80188774[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80188774[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80188530[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80188774[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801884F4[]; + extern u8 D_80188504[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801884F4); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188504); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80188774[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80188774[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80188774[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801887A8[])(void); + D_801887A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188530[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801887B0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801887C8[])(void); + D_801887C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188530[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801887B0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801887B0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801887E8[])(void); + D_801887E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80188530[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188530)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801887F8; +extern u16 D_801887FA; +extern u16 D_801887FC; +extern s32 D_80188800; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801887F8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801887FA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801887FC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188800, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80188808; + +void func_8015E588(void) { + func_8013C9C4(&D_80188808); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80188530[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188530)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018881C[])(void); + D_8018881C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80188530[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80188530[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80188824[])(void); + D_80188824[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80188514; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188514); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80188530[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018882C[])(void); + D_8018882C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80188530[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80188530[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80188834[])(void); + D_80188834[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80188530[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018883C; + extern s32 D_8018884C; + extern s32 D_8018885C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80188530[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018883C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018884C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80188530[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018885C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018886C[])(void); + D_8018886C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80188530[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80188530[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80188530[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188530[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80188878[])(void); + D_80188878[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80188530[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188530[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80188530[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188530[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018888C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018888C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80188530[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80188530)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80188530[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188530[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80188908[])(void); + D_80188908[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80188530[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80188530)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80188918[])(void); + D_80188918[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80188530[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80188530[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80188530[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80188530[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80188530[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80188530[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80188530[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80188920[])(void); + D_80188920[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80188530[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80188530)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80188530[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80188530)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018892C[])(void); + D_8018892C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188530 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80188530[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80188530[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80188530[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018893C[])(void); + +void func_80160EA4(void *a0) { + D_8018893C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80188530[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80188530[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018896C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018896C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801889D0; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801889D0); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A9708[]; + extern u8 D_8018899C[]; + extern u8 D_801889BC[]; + extern u8 D_801A9714[]; + extern u8 D_801A973C[]; + extern u8 D_801A9754[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A9708[0] = p; + func_80024054(&D_8018899C, &D_801A9714); + func_8001CE28(p, &D_801A9714); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A9708[1] = p; + func_80024054(&D_801889BC, &D_801A973C); + func_8001CE28(p, &D_801A973C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A9708[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A9754, 0x84); + func_8001CE68(p, &D_801A9754); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A9754, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A9708[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A9708; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801889D0; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801889D0; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801889D0; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801889D0; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A9708[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A9708; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801889F4[])(void); + +void func_80162330(void *a0) { + D_801889F4[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A9760[i] via `extern int D_801A9760[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80188A00[]; + extern s32 D_80188A18; + extern u8 D_801A976C[]; + extern u8 D_801A9794[]; + extern u8 D_801A97B0[]; + extern int D_801A9760[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A9760[0] = (s32)item; + func_80024054(D_80188A00, D_801A976C); + func_8001CE28(item, D_801A976C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A9760[1] = (s32)item; + func_80024054(((u8 *)&D_80188A18), D_801A9794); + func_8001CE28(item, D_801A9794); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A9760[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A97B0, 0x84); + func_8001CE68(item, D_801A97B0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A97B0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A9760[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A9760; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_801627E8); + + +extern void (*D_80188A3C[])(void); + +void func_80162834(void *a0) { + D_80188A3C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80188A2C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80188A2C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801A8F7C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801A8F7C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801A8F7C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801A8F7C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80188A44[])(void); + +void func_80163A58(void *a0) { + D_80188A44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801A8F84; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801A8F84; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80188A98[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80188A98[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80188A60; +extern s16 D_80188A94; +extern s16 D_80188A92; +extern s16 D_80188A90; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80188A60; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80188A94 = 0x80; + D_80188A92 = 0x80; + D_80188A90 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80188A94 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188A94` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80188A94 - 8; + D_80188A94 = nv; + D_80188A92 = nv; + D_80188A90 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80188AA4[])(void); + +void func_80164BA0(void *a0) { + D_80188AA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A97C0; +extern u8 D_801A97C1; +extern u8 D_801A97C2; +extern u8 D_801A97C3; +extern u8 D_801A97C4; +extern u8 D_801A97C5; +extern u8 D_801A97C6; +extern u8 D_801A97C7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A97C0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A97C1 = 0xf0; + *(u8 *)base = 0xf0; + D_801A97C2 = 0xc0; + D_801A97C6 = 0; + D_801A97C5 = 0; + D_801A97C4 = 0; + D_801A97C7 = 0; + D_801A97C3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A97C0; +extern u8 D_801A97C1; +extern u8 D_801A97C2; + +s32 func_80164E40(void) { + u8 *p = &D_801A97C0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A97C1 != 0) { + D_801A97C1 -= 0x10; + } + if (D_801A97C2 != 0) { + D_801A97C2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80188AB4[])(void); + +void func_80164EA4(void *a0) { + D_80188AB4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A980C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A980C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A9800[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A9800[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A9800[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A9800; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A9800; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80188AC8[]; + extern u32 D_80188AE8, D_80188AEC, D_80188AF0, D_80188AF4; + extern u32 D_80188AE8, D_80188AEC, D_80188AF0, D_80188AF4; + extern u32 D_80188AE8, D_80188AEC, D_80188AF0, D_80188AF4; + extern u32 D_80188AE8, D_80188AEC, D_80188AF0, D_80188AF4; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80188AC8[0x00], p); + ApplyMatrixSV(mat, &D_80188AC8[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80188AC8[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80188AC8[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80188AF0; + *(u32 *)(prim + 0x24) = D_80188AE8; + *(u32 *)(prim + 0x28) = D_80188AF4; + *(u32 *)(prim + 0x2c) = D_80188AEC; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80188AF8[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80188AF8[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80188AF8[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80188AF8[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80188B74[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80188B74[a1 & 0x7F]; +} + + + +extern s32 D_80188B94[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80188B94[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80188C10[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80188C10[a1 & 0x7F]; +} + + + +extern u8 D_80188C30[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80188C30[a1 & 0x7F]; +} + + + +extern u8 D_80188C50[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80188C50[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80188C70[])(void); + D_80188C70[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80188CEC[])(void); + +void func_80165AC8(void) { + D_80188CEC[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80188D68[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80188D68[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801A8F8C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801A8F8C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80188D74[])(void); + +void func_80166018(void *a0) { + D_80188D74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80188D7C[])(void); + +void func_801663FC(void *a0) { + D_80188D7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80188E44[])(void); + +void func_80166618(void *a0) { + D_80188E44[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80188E54[])(void); + +void func_80166654(void *a0) { + D_80188E54[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A9880[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A9880[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A9880). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A9880[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A9880)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A9880[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A9880[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80188D98[]; + extern u8 D_80188D84[]; + extern u8 D_80188DAC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80188D98; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80188D84; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80188DAC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80167714); + + +extern void (*D_80188E64[])(void); + +void func_801678B4(void *a0) { + D_80188E64[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80188E70[])(void); + +void func_80167A9C(void *a0) { + D_80188E70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80188F7C; + extern u8 D_80188F90[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80188F7C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188F90; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80188DD0[]; +extern u8 D_80188DE4[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80188DD0; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80188DE4; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80188E88[])(void); + +void func_80168744(void *a0) { + D_80188E88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80188E78 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80188E78[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80188E78; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80188E90[])(void); + +void func_801689D8(void *a0) { + D_80188E90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80188E98[])(void); + +void func_80168AA8(void *a0) { + D_80188E98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80188EA0[])(void); + +void func_80168D58(void *a0) { + D_80188EA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80188EA8[])(void); + +void func_8016901C(void *a0) { + D_80188EA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_097/nonmatchings/ov_SC03_097_jr_8015C32C", func_80169228); + + +extern void (*D_80188EB0[])(void); + +void func_801693CC(void *a0) { + D_80188EB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80188EB8[])(void); + +void func_80169830(void *a0) { + D_80188EB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80188F6C[])(void); + +void func_80169B80(void *a0) { + D_80188F6C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80188EC0[]; + extern u8 D_80188F30[]; + extern u8 D_80188F60[]; + extern u8 D_801AAD88[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80188F60, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80188EC0[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801AAD88; + RotMatrixYXZ(rot, D_801AAD88); + func_80048D9C(D_801AAD88, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80188F30); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80188F74[])(void); + +void func_80169F00(void *a0) { + D_80188F74[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80188F24[]; +extern char D_80188EE4[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80188F24, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188EE4); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80188FAC[])(void); + +void func_8016A020(void *a0) { + D_80188FAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80188F7C; + extern u8 D_80188F90[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80188F7C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188F90; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80188FB8[])(void); + +void func_8016A700(void *a0) { + D_80188FB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80189000[])(void); + +void func_8016AB30(void *a0) { + D_80189000[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_098/ov_SC03_098_jr_8015AE2C.c b/src/ov_SC03_098/ov_SC03_098_jr_8015AE2C.c index 2c17a1e7f..3f540c60b 100644 --- a/src/ov_SC03_098/ov_SC03_098_jr_8015AE2C.c +++ b/src/ov_SC03_098/ov_SC03_098_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80187B48[])(void); - -void func_8015C714(void *a0) { - D_80187B48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801879BC[])(void*); - extern int D_80187960; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801879BC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801879BC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187960); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801879BC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801879BC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801879BC[])(void*); - extern int D_80187960; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801879BC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187960); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801879BC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80187B58[])(void); - D_80187B58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801879BC[])(struct Ent_8015CD20 *); - extern u8 D_80187970; - extern u8 D_80187B60; - extern u8 D_80187B70; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801879BC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187970); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187B60); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187B70); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801879BC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80187B90[])(void); - D_80187B90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80187B80; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80187B80 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801879BC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80187BEC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80187BEC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80186CD0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80186CD0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80187BF4[])(void); - D_80187BF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80187C00[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80187C00[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80187C00[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80187C00[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801879BC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80187C00[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80187980[]; - extern u8 D_80187990[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187980); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187990); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80187C00[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187C00[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187C00[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80187C34[])(void); - D_80187C34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801879BC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80187C3C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80187C54[])(void); - D_80187C54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801879BC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80187C3C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80187C74[])(void); - D_80187C74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801879BC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801879BC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80187C84; -extern u16 D_80187C86; -extern u16 D_80187C88; -extern s32 D_80187C8C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80187C84 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80187C86 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187C88 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187C8C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80187C94; - -void func_8015E588(void) { - func_8013C9C4(&D_80187C94); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801879BC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801879BC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80187CA8[])(void); - D_80187CA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801879BC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801879BC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80187CB0[])(void); - D_80187CB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801879A0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801879A0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801879BC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187CB8[])(void); - D_80187CB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801879BC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801879BC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80187CC0[])(void); - D_80187CC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801879BC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80187CC8; - extern s32 D_80187CD8; - extern s32 D_80187CE8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801879BC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187CC8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187CD8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801879BC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187CE8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80187CF8[])(void); - D_80187CF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801879BC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801879BC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801879BC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801879BC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80187D04[])(void); - D_80187D04[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801879BC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801879BC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801879BC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801879BC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80187D18[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80187D18[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801879BC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801879BC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801879BC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801879BC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80187D94[])(void); - D_80187D94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801879BC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801879BC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80187DA4[])(void); - D_80187DA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801879BC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801879BC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801879BC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801879BC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801879BC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801879BC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801879BC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80187DAC[])(void); - D_80187DAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801879BC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801879BC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801879BC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801879BC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187DB8[])(void); - D_80187DB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801879BC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801879BC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801879BC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801879BC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80187DC8[])(void); - -void func_80160EA4(void *a0) { - D_80187DC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801879BC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801879BC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80187DF8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80187DF8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80187E5C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80187E5C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C4378[]; - extern u8 D_80187E28[]; - extern u8 D_80187E48[]; - extern u8 D_801C4384[]; - extern u8 D_801C43AC[]; - extern u8 D_801C43C4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C4378[0] = p; - func_80024054(&D_80187E28, &D_801C4384); - func_8001CE28(p, &D_801C4384); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C4378[1] = p; - func_80024054(&D_80187E48, &D_801C43AC); - func_8001CE28(p, &D_801C43AC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C4378[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C43C4, 0x84); - func_8001CE68(p, &D_801C43C4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C43C4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C4378[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C4378; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80187E5C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80187E5C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80187E5C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80187E5C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C4378[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C4378; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80187E80[])(void); - -void func_80162330(void *a0) { - D_80187E80[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C43D0[i] via `extern int D_801C43D0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80187E8C[]; - extern s32 D_80187EA4; - extern u8 D_801C43DC[]; - extern u8 D_801C4404[]; - extern u8 D_801C4420[]; - extern int D_801C43D0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C43D0[0] = (s32)item; - func_80024054(D_80187E8C, D_801C43DC); - func_8001CE28(item, D_801C43DC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C43D0[1] = (s32)item; - func_80024054(((u8 *)&D_80187EA4), D_801C4404); - func_8001CE28(item, D_801C4404); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C43D0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C4420, 0x84); - func_8001CE68(item, D_801C4420); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C4420, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C43D0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C43D0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187EC8[])(void); - -void func_80162834(void *a0) { - D_80187EC8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187EB8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187EB8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C3C00[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C3C00, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C3C00[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C3C00, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80187ED0[])(void); - -void func_80163A58(void *a0) { - D_80187ED0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C3C08; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C3C08; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80187F24[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80187F24[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80187EEC; -extern s16 D_80187F20; -extern s16 D_80187F1E; -extern s16 D_80187F1C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80187EEC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80187F20 = 0x80; - D_80187F1E = 0x80; - D_80187F1C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80187F20 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187F20` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80187F20 - 8; - D_80187F20 = nv; - D_80187F1E = nv; - D_80187F1C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80187F30[])(void); - -void func_80164BA0(void *a0) { - D_80187F30[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C4430; -extern u8 D_801C4431; -extern u8 D_801C4432; -extern u8 D_801C4433; -extern u8 D_801C4434; -extern u8 D_801C4435; -extern u8 D_801C4436; -extern u8 D_801C4437; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C4430; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C4431 = 0xf0; - *(u8 *)base = 0xf0; - D_801C4432 = 0xc0; - D_801C4436 = 0; - D_801C4435 = 0; - D_801C4434 = 0; - D_801C4437 = 0; - D_801C4433 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C4430; -extern u8 D_801C4431; -extern u8 D_801C4432; - -s32 func_80164E40(void) { - u8 *p = &D_801C4430; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C4431 != 0) { - D_801C4431 -= 0x10; - } - if (D_801C4432 != 0) { - D_801C4432 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80187F40[])(void); - -void func_80164EA4(void *a0) { - D_80187F40[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C447C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C447C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C4470[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C4470[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C4470[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C4470; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C4470; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80187F54[]; - extern u32 D_80187F74, D_80187F78, D_80187F7C, D_80187F80; - extern u32 D_80187F74, D_80187F78, D_80187F7C, D_80187F80; - extern u32 D_80187F74, D_80187F78, D_80187F7C, D_80187F80; - extern u32 D_80187F74, D_80187F78, D_80187F7C, D_80187F80; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80187F54[0x00], p); - ApplyMatrixSV(mat, &D_80187F54[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80187F54[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80187F54[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80187F7C; - *(u32 *)(prim + 0x24) = D_80187F74; - *(u32 *)(prim + 0x28) = D_80187F80; - *(u32 *)(prim + 0x2c) = D_80187F78; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187F84[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187F84[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187F84[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187F84[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80188000[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80188000[a1 & 0x7F]; -} - - - -extern s32 D_80188020[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80188020[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018809C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018809C[a1 & 0x7F]; -} - - - -extern u8 D_801880BC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801880BC[a1 & 0x7F]; -} - - - -extern u8 D_801880DC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801880DC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801880FC[])(void); - D_801880FC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80188178[])(void); - -void func_80165AC8(void) { - D_80188178[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801881F4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801881F4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C3C10; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C3C10, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80188200[])(void); - -void func_80166018(void *a0) { - D_80188200[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80188208[])(void); - -void func_801663FC(void *a0) { - D_80188208[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801882D0[])(void); - -void func_80166618(void *a0) { - D_801882D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801882E0[])(void); - -void func_80166654(void *a0) { - D_801882E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C44F0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C44F0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C44F0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C44F0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C44F0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C44F0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C44F0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80188224[]; - extern u8 D_80188210[]; - extern u8 D_80188238[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80188224; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80188210; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80188238; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80167714); - - -extern void (*D_801882F0[])(void); - -void func_801678B4(void *a0) { - D_801882F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801882FC[])(void); - -void func_80167A9C(void *a0) { - D_801882FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80188408; - extern u8 D_8018841C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80188408); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018841C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018825C[]; -extern u8 D_80188270[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018825C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80188270; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80188314[])(void); - -void func_80168744(void *a0) { - D_80188314[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80188304 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80188304[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80188304; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018831C[])(void); - -void func_801689D8(void *a0) { - D_8018831C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80188324[])(void); - -void func_80168AA8(void *a0) { - D_80188324[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018832C[])(void); - -void func_80168D58(void *a0) { - D_8018832C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80188334[])(void); - -void func_8016901C(void *a0) { - D_80188334[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015AE2C", func_80169228); - - -extern void (*D_8018833C[])(void); - -void func_801693CC(void *a0) { - D_8018833C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80188344[])(void); - -void func_80169830(void *a0) { - D_80188344[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801883F8[])(void); - -void func_80169B80(void *a0) { - D_801883F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018834C[]; - extern u8 D_801883BC[]; - extern u8 D_801883EC[]; - extern u8 D_801C5770[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801883EC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018834C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C5770; - RotMatrixYXZ(rot, D_801C5770); - func_80048D9C(D_801C5770, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801883BC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80188400[])(void); - -void func_80169F00(void *a0) { - D_80188400[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801883B0[]; -extern char D_80188370[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801883B0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188370); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80188438[])(void); - -void func_8016A020(void *a0) { - D_80188438[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80188408; - extern u8 D_8018841C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80188408); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018841C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80188444[])(void); - -void func_8016A700(void *a0) { - D_80188444[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018848C[])(void); - -void func_8016AB30(void *a0) { - D_8018848C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c b/src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c new file mode 100644 index 000000000..c1b666570 --- /dev/null +++ b/src/ov_SC03_098/ov_SC03_098_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80187858; +extern u8 D_801877C8; +extern u8 D_801877A4; +extern u8 D_80187780; +extern u8 D_80187834; +extern u8 D_80187810; +extern u8 D_801877EC; +extern u8 D_8018775C; +extern void func_80145934(void); +extern u8 D_801878E8; +extern u8 D_801878C4; +extern u8 D_801878A0; +extern u8 D_8018787C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80186CE0[]; +extern unsigned char D_80186D10[]; +extern unsigned char D_80186D60[]; +extern unsigned char D_80186D90[]; +extern unsigned char D_80186DC0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80186E10[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80186ED8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80186F60[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186F68; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C4320; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C4324; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186F98; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80187040[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80187064[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80187054; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80187078[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80187084[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80187094[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801870AC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018709C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801870C0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801870DC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801870CC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801870F0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80187104[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80187118; +extern void (*D_80187140[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80187120; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018718C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80187190[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801875F4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80187604[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C4358; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018762C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018760C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018761C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018766C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80187674[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80187640; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80187680[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80187650; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C4360; +extern s32 D_801C436C; +extern s32 D_801C4370; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801876BC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80187690[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C4368; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018790C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018772C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801879B0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80187B04[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80187920; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80187B0C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80187930; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80187950; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80187B14[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80187B3C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801879BC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80187B48[])(void); + +void func_8015C714(void *a0) { + D_80187B48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801879BC[])(void*); + extern int D_80187960; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801879BC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801879BC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187960); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801879BC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801879BC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801879BC[])(void*); + extern int D_80187960; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801879BC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187960); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801879BC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80187B58[])(void); + D_80187B58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801879BC[])(struct Ent_8015CD20 *); + extern u8 D_80187970; + extern u8 D_80187B60; + extern u8 D_80187B70; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801879BC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187970); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187B60); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187B70); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801879BC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80187B90[])(void); + D_80187B90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80187B80; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80187B80 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801879BC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80187BEC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80187BEC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80186CD0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80186CD0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80187BF4[])(void); + D_80187BF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80187C00[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80187C00[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80187C00[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80187C00[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801879BC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80187C00[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80187980[]; + extern u8 D_80187990[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187980); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187990); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80187C00[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187C00[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187C00[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80187C34[])(void); + D_80187C34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801879BC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80187C3C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80187C54[])(void); + D_80187C54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801879BC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80187C3C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80187C3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80187C74[])(void); + D_80187C74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801879BC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801879BC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80187C84; +extern u16 D_80187C86; +extern u16 D_80187C88; +extern s32 D_80187C8C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80187C84 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80187C86 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187C88 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187C8C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80187C94; + +void func_8015E588(void) { + func_8013C9C4(&D_80187C94); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801879BC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801879BC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80187CA8[])(void); + D_80187CA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801879BC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801879BC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80187CB0[])(void); + D_80187CB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801879A0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801879A0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801879BC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187CB8[])(void); + D_80187CB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801879BC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801879BC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80187CC0[])(void); + D_80187CC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801879BC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80187CC8; + extern s32 D_80187CD8; + extern s32 D_80187CE8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187CC8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187CD8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801879BC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187CE8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80187CF8[])(void); + D_80187CF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801879BC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801879BC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801879BC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801879BC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80187D04[])(void); + D_80187D04[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801879BC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801879BC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801879BC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801879BC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80187D18[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80187D18[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801879BC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801879BC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801879BC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801879BC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80187D94[])(void); + D_80187D94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801879BC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801879BC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80187DA4[])(void); + D_80187DA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801879BC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801879BC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801879BC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801879BC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801879BC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801879BC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801879BC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80187DAC[])(void); + D_80187DAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801879BC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801879BC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801879BC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801879BC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187DB8[])(void); + D_80187DB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801879BC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801879BC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801879BC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801879BC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80187DC8[])(void); + +void func_80160EA4(void *a0) { + D_80187DC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801879BC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801879BC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80187DF8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80187DF8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80187E5C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80187E5C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C4378[]; + extern u8 D_80187E28[]; + extern u8 D_80187E48[]; + extern u8 D_801C4384[]; + extern u8 D_801C43AC[]; + extern u8 D_801C43C4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C4378[0] = p; + func_80024054(&D_80187E28, &D_801C4384); + func_8001CE28(p, &D_801C4384); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C4378[1] = p; + func_80024054(&D_80187E48, &D_801C43AC); + func_8001CE28(p, &D_801C43AC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C4378[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C43C4, 0x84); + func_8001CE68(p, &D_801C43C4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C43C4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C4378[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C4378; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80187E5C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80187E5C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80187E5C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80187E5C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C4378[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C4378; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80187E80[])(void); + +void func_80162330(void *a0) { + D_80187E80[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C43D0[i] via `extern int D_801C43D0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80187E8C[]; + extern s32 D_80187EA4; + extern u8 D_801C43DC[]; + extern u8 D_801C4404[]; + extern u8 D_801C4420[]; + extern int D_801C43D0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C43D0[0] = (s32)item; + func_80024054(D_80187E8C, D_801C43DC); + func_8001CE28(item, D_801C43DC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C43D0[1] = (s32)item; + func_80024054(((u8 *)&D_80187EA4), D_801C4404); + func_8001CE28(item, D_801C4404); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C43D0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C4420, 0x84); + func_8001CE68(item, D_801C4420); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C4420, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C43D0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C43D0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_801627E8); + + +extern void (*D_80187EC8[])(void); + +void func_80162834(void *a0) { + D_80187EC8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187EB8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187EB8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C3C00[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C3C00, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C3C00[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C3C00, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80187ED0[])(void); + +void func_80163A58(void *a0) { + D_80187ED0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C3C08; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C3C08; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80187F24[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80187F24[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80187EEC; +extern s16 D_80187F20; +extern s16 D_80187F1E; +extern s16 D_80187F1C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80187EEC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80187F20 = 0x80; + D_80187F1E = 0x80; + D_80187F1C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80187F20 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187F20` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80187F20 - 8; + D_80187F20 = nv; + D_80187F1E = nv; + D_80187F1C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80187F30[])(void); + +void func_80164BA0(void *a0) { + D_80187F30[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C4430; +extern u8 D_801C4431; +extern u8 D_801C4432; +extern u8 D_801C4433; +extern u8 D_801C4434; +extern u8 D_801C4435; +extern u8 D_801C4436; +extern u8 D_801C4437; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C4430; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C4431 = 0xf0; + *(u8 *)base = 0xf0; + D_801C4432 = 0xc0; + D_801C4436 = 0; + D_801C4435 = 0; + D_801C4434 = 0; + D_801C4437 = 0; + D_801C4433 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C4430; +extern u8 D_801C4431; +extern u8 D_801C4432; + +s32 func_80164E40(void) { + u8 *p = &D_801C4430; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C4431 != 0) { + D_801C4431 -= 0x10; + } + if (D_801C4432 != 0) { + D_801C4432 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80187F40[])(void); + +void func_80164EA4(void *a0) { + D_80187F40[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C447C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C447C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C4470[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C4470[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C4470[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C4470; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C4470; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80187F54[]; + extern u32 D_80187F74, D_80187F78, D_80187F7C, D_80187F80; + extern u32 D_80187F74, D_80187F78, D_80187F7C, D_80187F80; + extern u32 D_80187F74, D_80187F78, D_80187F7C, D_80187F80; + extern u32 D_80187F74, D_80187F78, D_80187F7C, D_80187F80; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80187F54[0x00], p); + ApplyMatrixSV(mat, &D_80187F54[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80187F54[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80187F54[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80187F7C; + *(u32 *)(prim + 0x24) = D_80187F74; + *(u32 *)(prim + 0x28) = D_80187F80; + *(u32 *)(prim + 0x2c) = D_80187F78; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187F84[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187F84[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187F84[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187F84[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80188000[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80188000[a1 & 0x7F]; +} + + + +extern s32 D_80188020[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80188020[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018809C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018809C[a1 & 0x7F]; +} + + + +extern u8 D_801880BC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801880BC[a1 & 0x7F]; +} + + + +extern u8 D_801880DC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801880DC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801880FC[])(void); + D_801880FC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80188178[])(void); + +void func_80165AC8(void) { + D_80188178[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801881F4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801881F4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C3C10; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C3C10, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80188200[])(void); + +void func_80166018(void *a0) { + D_80188200[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80188208[])(void); + +void func_801663FC(void *a0) { + D_80188208[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801882D0[])(void); + +void func_80166618(void *a0) { + D_801882D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801882E0[])(void); + +void func_80166654(void *a0) { + D_801882E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C44F0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C44F0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C44F0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C44F0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C44F0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C44F0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C44F0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80188224[]; + extern u8 D_80188210[]; + extern u8 D_80188238[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80188224; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80188210; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80188238; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80167714); + + +extern void (*D_801882F0[])(void); + +void func_801678B4(void *a0) { + D_801882F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801882FC[])(void); + +void func_80167A9C(void *a0) { + D_801882FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80188408; + extern u8 D_8018841C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80188408); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018841C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018825C[]; +extern u8 D_80188270[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018825C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80188270; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80188314[])(void); + +void func_80168744(void *a0) { + D_80188314[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80188304 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80188304[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80188304; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018831C[])(void); + +void func_801689D8(void *a0) { + D_8018831C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80188324[])(void); + +void func_80168AA8(void *a0) { + D_80188324[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018832C[])(void); + +void func_80168D58(void *a0) { + D_8018832C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80188334[])(void); + +void func_8016901C(void *a0) { + D_80188334[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_098/nonmatchings/ov_SC03_098_jr_8015C32C", func_80169228); + + +extern void (*D_8018833C[])(void); + +void func_801693CC(void *a0) { + D_8018833C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80188344[])(void); + +void func_80169830(void *a0) { + D_80188344[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801883F8[])(void); + +void func_80169B80(void *a0) { + D_801883F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018834C[]; + extern u8 D_801883BC[]; + extern u8 D_801883EC[]; + extern u8 D_801C5770[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801883EC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018834C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C5770; + RotMatrixYXZ(rot, D_801C5770); + func_80048D9C(D_801C5770, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801883BC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80188400[])(void); + +void func_80169F00(void *a0) { + D_80188400[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801883B0[]; +extern char D_80188370[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801883B0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188370); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80188438[])(void); + +void func_8016A020(void *a0) { + D_80188438[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80188408; + extern u8 D_8018841C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80188408); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018841C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80188444[])(void); + +void func_8016A700(void *a0) { + D_80188444[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018848C[])(void); + +void func_8016AB30(void *a0) { + D_8018848C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_099/ov_SC03_099_jr_8015AE2C.c b/src/ov_SC03_099/ov_SC03_099_jr_8015AE2C.c index 9cb432830..96662e54d 100644 --- a/src/ov_SC03_099/ov_SC03_099_jr_8015AE2C.c +++ b/src/ov_SC03_099/ov_SC03_099_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80185C48[])(void); - -void func_8015C714(void *a0) { - D_80185C48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80185ABC[])(void*); - extern int D_80185A60; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80185ABC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80185ABC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185A60); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80185ABC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80185ABC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80185ABC[])(void*); - extern int D_80185A60; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80185ABC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185A60); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80185ABC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80185C58[])(void); - D_80185C58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80185ABC[])(struct Ent_8015CD20 *); - extern u8 D_80185A70; - extern u8 D_80185C60; - extern u8 D_80185C70; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80185ABC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185A70); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185C60); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185C70); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80185ABC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80185C90[])(void); - D_80185C90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80185C80; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80185C80 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80185ABC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80185CEC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80185CEC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80184DD0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80184DD0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80185CF4[])(void); - D_80185CF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80185D00[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80185D00[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80185D00[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80185D00[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80185ABC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80185D00[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80185A80[]; - extern u8 D_80185A90[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185A80); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185A90); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80185D00[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185D00[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185D00[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80185D34[])(void); - D_80185D34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185ABC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80185D3C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80185D54[])(void); - D_80185D54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185ABC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80185D3C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80185D74[])(void); - D_80185D74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80185ABC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185ABC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80185D84; -extern u16 D_80185D86; -extern u16 D_80185D88; -extern s32 D_80185D8C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80185D84 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80185D86 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80185D88 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185D8C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80185D94; - -void func_8015E588(void) { - func_8013C9C4(&D_80185D94); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80185ABC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185ABC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80185DA8[])(void); - D_80185DA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80185ABC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80185ABC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80185DB0[])(void); - D_80185DB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80185AA0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185AA0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80185ABC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80185DB8[])(void); - D_80185DB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80185ABC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80185ABC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80185DC0[])(void); - D_80185DC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80185ABC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80185DC8; - extern s32 D_80185DD8; - extern s32 D_80185DE8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80185ABC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185DC8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185DD8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80185ABC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185DE8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80185DF8[])(void); - D_80185DF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80185ABC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80185ABC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80185ABC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185ABC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80185E04[])(void); - D_80185E04[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80185ABC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185ABC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80185ABC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185ABC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80185E18[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80185E18[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80185ABC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80185ABC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80185ABC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185ABC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80185E94[])(void); - D_80185E94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80185ABC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80185ABC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80185EA4[])(void); - D_80185EA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80185ABC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80185ABC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80185ABC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80185ABC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80185ABC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80185ABC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80185ABC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80185EAC[])(void); - D_80185EAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80185ABC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80185ABC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80185ABC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80185ABC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80185EB8[])(void); - D_80185EB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185ABC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80185ABC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80185ABC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80185ABC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80185EC8[])(void); - -void func_80160EA4(void *a0) { - D_80185EC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80185ABC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80185ABC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80185EF8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80185EF8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80185F5C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80185F5C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801BE048[]; - extern u8 D_80185F28[]; - extern u8 D_80185F48[]; - extern u8 D_801BE054[]; - extern u8 D_801BE07C[]; - extern u8 D_801BE094[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801BE048[0] = p; - func_80024054(&D_80185F28, &D_801BE054); - func_8001CE28(p, &D_801BE054); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801BE048[1] = p; - func_80024054(&D_80185F48, &D_801BE07C); - func_8001CE28(p, &D_801BE07C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801BE048[2] = p; - func_800242D0((s16)func_801620C4(), &D_801BE094, 0x84); - func_8001CE68(p, &D_801BE094); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801BE094, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BE048[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801BE048; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80185F5C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80185F5C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80185F5C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80185F5C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801BE048[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801BE048; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80185F80[])(void); - -void func_80162330(void *a0) { - D_80185F80[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801BE0A0[i] via `extern int D_801BE0A0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80185F8C[]; - extern s32 D_80185FA4; - extern u8 D_801BE0AC[]; - extern u8 D_801BE0D4[]; - extern u8 D_801BE0F0[]; - extern int D_801BE0A0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801BE0A0[0] = (s32)item; - func_80024054(D_80185F8C, D_801BE0AC); - func_8001CE28(item, D_801BE0AC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801BE0A0[1] = (s32)item; - func_80024054(((u8 *)&D_80185FA4), D_801BE0D4); - func_8001CE28(item, D_801BE0D4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801BE0A0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801BE0F0, 0x84); - func_8001CE68(item, D_801BE0F0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801BE0F0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BE0A0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801BE0A0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_801627E8); - - -extern void (*D_80185FC8[])(void); - -void func_80162834(void *a0) { - D_80185FC8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80185FB8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80185FB8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801BD8D4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801BD8D4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801BD8D4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801BD8D4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80185FD0[])(void); - -void func_80163A58(void *a0) { - D_80185FD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801BD8DC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801BD8DC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80186024[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80186024[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80185FEC; -extern s16 D_80186020; -extern s16 D_8018601E; -extern s16 D_8018601C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80185FEC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80186020 = 0x80; - D_8018601E = 0x80; - D_8018601C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80186020 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80186020` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80186020 - 8; - D_80186020 = nv; - D_8018601E = nv; - D_8018601C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80186030[])(void); - -void func_80164BA0(void *a0) { - D_80186030[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801BE100; -extern u8 D_801BE101; -extern u8 D_801BE102; -extern u8 D_801BE103; -extern u8 D_801BE104; -extern u8 D_801BE105; -extern u8 D_801BE106; -extern u8 D_801BE107; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801BE100; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801BE101 = 0xf0; - *(u8 *)base = 0xf0; - D_801BE102 = 0xc0; - D_801BE106 = 0; - D_801BE105 = 0; - D_801BE104 = 0; - D_801BE107 = 0; - D_801BE103 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801BE100; -extern u8 D_801BE101; -extern u8 D_801BE102; - -s32 func_80164E40(void) { - u8 *p = &D_801BE100; - if (*p != 0) { - *p -= 0x10; - } - if (D_801BE101 != 0) { - D_801BE101 -= 0x10; - } - if (D_801BE102 != 0) { - D_801BE102 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80186040[])(void); - -void func_80164EA4(void *a0) { - D_80186040[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801BE14C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801BE14C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801BE140[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801BE140[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801BE140[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801BE140; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801BE140; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80186054[]; - extern u32 D_80186074, D_80186078, D_8018607C, D_80186080; - extern u32 D_80186074, D_80186078, D_8018607C, D_80186080; - extern u32 D_80186074, D_80186078, D_8018607C, D_80186080; - extern u32 D_80186074, D_80186078, D_8018607C, D_80186080; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80186054[0x00], p); - ApplyMatrixSV(mat, &D_80186054[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80186054[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80186054[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018607C; - *(u32 *)(prim + 0x24) = D_80186074; - *(u32 *)(prim + 0x28) = D_80186080; - *(u32 *)(prim + 0x2c) = D_80186078; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80186084[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80186084[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80186084[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80186084[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80186100[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80186100[a1 & 0x7F]; -} - - - -extern s32 D_80186120[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80186120[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018619C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018619C[a1 & 0x7F]; -} - - - -extern u8 D_801861BC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801861BC[a1 & 0x7F]; -} - - - -extern u8 D_801861DC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801861DC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801861FC[])(void); - D_801861FC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80186278[])(void); - -void func_80165AC8(void) { - D_80186278[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801862F4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801862F4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801BD8E4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801BD8E4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80186300[])(void); - -void func_80166018(void *a0) { - D_80186300[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80186308[])(void); - -void func_801663FC(void *a0) { - D_80186308[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801863D0[])(void); - -void func_80166618(void *a0) { - D_801863D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801863E0[])(void); - -void func_80166654(void *a0) { - D_801863E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801BE1C0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801BE1C0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BE1C0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801BE1C0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801BE1C0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801BE1C0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801BE1C0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80186324[]; - extern u8 D_80186310[]; - extern u8 D_80186338[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80186324; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80186310; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80186338; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80167714); - - -extern void (*D_801863F0[])(void); - -void func_801678B4(void *a0) { - D_801863F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801863FC[])(void); - -void func_80167A9C(void *a0) { - D_801863FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80186508; - extern u8 D_8018651C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80186508); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018651C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018635C[]; -extern u8 D_80186370[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018635C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80186370; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80186414[])(void); - -void func_80168744(void *a0) { - D_80186414[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80186404 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80186404[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80186404; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018641C[])(void); - -void func_801689D8(void *a0) { - D_8018641C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80186424[])(void); - -void func_80168AA8(void *a0) { - D_80186424[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018642C[])(void); - -void func_80168D58(void *a0) { - D_8018642C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80186434[])(void); - -void func_8016901C(void *a0) { - D_80186434[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015AE2C", func_80169228); - - -extern void (*D_8018643C[])(void); - -void func_801693CC(void *a0) { - D_8018643C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80186444[])(void); - -void func_80169830(void *a0) { - D_80186444[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801864F8[])(void); - -void func_80169B80(void *a0) { - D_801864F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018644C[]; - extern u8 D_801864BC[]; - extern u8 D_801864EC[]; - extern u8 D_801BF318[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801864EC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018644C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801BF318; - RotMatrixYXZ(rot, D_801BF318); - func_80048D9C(D_801BF318, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801864BC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80186500[])(void); - -void func_80169F00(void *a0) { - D_80186500[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801864B0[]; -extern char D_80186470[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801864B0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80186470); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80186538[])(void); - -void func_8016A020(void *a0) { - D_80186538[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80186508; - extern u8 D_8018651C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80186508); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018651C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80186544[])(void); - -void func_8016A700(void *a0) { - D_80186544[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018658C[])(void); - -void func_8016AB30(void *a0) { - D_8018658C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c b/src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c new file mode 100644 index 000000000..34842d375 --- /dev/null +++ b/src/ov_SC03_099/ov_SC03_099_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80185958; +extern u8 D_801858C8; +extern u8 D_801858A4; +extern u8 D_80185880; +extern u8 D_80185934; +extern u8 D_80185910; +extern u8 D_801858EC; +extern u8 D_8018585C; +extern void func_80145934(void); +extern u8 D_801859E8; +extern u8 D_801859C4; +extern u8 D_801859A0; +extern u8 D_8018597C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80184DE0[]; +extern unsigned char D_80184E10[]; +extern unsigned char D_80184E60[]; +extern unsigned char D_80184E90[]; +extern unsigned char D_80184EC0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80184F10[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80184FD8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80185060[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80185068; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801BDFF0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801BDFF4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80185098; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80185140[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80185164[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80185154; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80185178[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80185184[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80185194[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801851AC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018519C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801851C0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801851DC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801851CC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801851F0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80185204[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80185218; +extern void (*D_80185240[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80185220; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018528C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80185290[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801856F4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80185704[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801BE028; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018572C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018570C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018571C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018576C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80185774[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80185740; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80185780[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80185750; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801BE030; +extern s32 D_801BE03C; +extern s32 D_801BE040; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801857BC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80185790[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801BE038; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80185A0C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018582C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80185AB0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80185C04[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80185A20; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80185C0C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80185A30; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80185A50; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80185C14[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80185C3C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80185ABC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80185C48[])(void); + +void func_8015C714(void *a0) { + D_80185C48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80185ABC[])(void*); + extern int D_80185A60; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80185ABC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80185ABC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185A60); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80185ABC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80185ABC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80185ABC[])(void*); + extern int D_80185A60; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80185ABC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185A60); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80185ABC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80185C58[])(void); + D_80185C58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80185ABC[])(struct Ent_8015CD20 *); + extern u8 D_80185A70; + extern u8 D_80185C60; + extern u8 D_80185C70; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80185ABC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185A70); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185C60); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185C70); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80185ABC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80185C90[])(void); + D_80185C90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80185C80; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80185C80 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80185ABC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80185CEC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80185CEC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80184DD0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80184DD0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80185CF4[])(void); + D_80185CF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80185D00[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80185D00[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80185D00[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80185D00[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80185ABC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80185D00[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80185A80[]; + extern u8 D_80185A90[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185A80); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185A90); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80185D00[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185D00[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185D00[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80185D34[])(void); + D_80185D34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185ABC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80185D3C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80185D54[])(void); + D_80185D54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185ABC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80185D3C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80185D3C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80185D74[])(void); + D_80185D74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80185ABC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185ABC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80185D84; +extern u16 D_80185D86; +extern u16 D_80185D88; +extern s32 D_80185D8C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80185D84 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80185D86 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80185D88 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185D8C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80185D94; + +void func_8015E588(void) { + func_8013C9C4(&D_80185D94); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80185ABC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185ABC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80185DA8[])(void); + D_80185DA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80185ABC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80185ABC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80185DB0[])(void); + D_80185DB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80185AA0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185AA0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80185ABC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80185DB8[])(void); + D_80185DB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80185ABC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80185ABC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80185DC0[])(void); + D_80185DC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80185ABC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80185DC8; + extern s32 D_80185DD8; + extern s32 D_80185DE8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185DC8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185DD8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80185ABC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185DE8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80185DF8[])(void); + D_80185DF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80185ABC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80185ABC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80185ABC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185ABC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80185E04[])(void); + D_80185E04[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80185ABC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185ABC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80185ABC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185ABC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80185E18[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80185E18[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80185ABC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80185ABC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80185ABC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185ABC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80185E94[])(void); + D_80185E94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80185ABC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80185ABC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80185EA4[])(void); + D_80185EA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80185ABC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80185ABC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80185ABC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80185ABC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80185ABC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80185ABC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80185ABC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80185EAC[])(void); + D_80185EAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80185ABC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80185ABC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80185ABC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80185ABC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80185EB8[])(void); + D_80185EB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185ABC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80185ABC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80185ABC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80185ABC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80185EC8[])(void); + +void func_80160EA4(void *a0) { + D_80185EC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80185ABC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80185ABC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80185EF8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80185EF8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80185F5C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80185F5C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801BE048[]; + extern u8 D_80185F28[]; + extern u8 D_80185F48[]; + extern u8 D_801BE054[]; + extern u8 D_801BE07C[]; + extern u8 D_801BE094[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801BE048[0] = p; + func_80024054(&D_80185F28, &D_801BE054); + func_8001CE28(p, &D_801BE054); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801BE048[1] = p; + func_80024054(&D_80185F48, &D_801BE07C); + func_8001CE28(p, &D_801BE07C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801BE048[2] = p; + func_800242D0((s16)func_801620C4(), &D_801BE094, 0x84); + func_8001CE68(p, &D_801BE094); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801BE094, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BE048[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801BE048; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80185F5C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80185F5C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80185F5C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80185F5C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801BE048[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801BE048; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80185F80[])(void); + +void func_80162330(void *a0) { + D_80185F80[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801BE0A0[i] via `extern int D_801BE0A0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80185F8C[]; + extern s32 D_80185FA4; + extern u8 D_801BE0AC[]; + extern u8 D_801BE0D4[]; + extern u8 D_801BE0F0[]; + extern int D_801BE0A0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801BE0A0[0] = (s32)item; + func_80024054(D_80185F8C, D_801BE0AC); + func_8001CE28(item, D_801BE0AC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801BE0A0[1] = (s32)item; + func_80024054(((u8 *)&D_80185FA4), D_801BE0D4); + func_8001CE28(item, D_801BE0D4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801BE0A0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801BE0F0, 0x84); + func_8001CE68(item, D_801BE0F0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801BE0F0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BE0A0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801BE0A0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_801627E8); + + +extern void (*D_80185FC8[])(void); + +void func_80162834(void *a0) { + D_80185FC8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80185FB8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80185FB8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801BD8D4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801BD8D4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801BD8D4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801BD8D4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80185FD0[])(void); + +void func_80163A58(void *a0) { + D_80185FD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801BD8DC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801BD8DC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80186024[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80186024[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80185FEC; +extern s16 D_80186020; +extern s16 D_8018601E; +extern s16 D_8018601C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80185FEC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80186020 = 0x80; + D_8018601E = 0x80; + D_8018601C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80186020 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80186020` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80186020 - 8; + D_80186020 = nv; + D_8018601E = nv; + D_8018601C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80186030[])(void); + +void func_80164BA0(void *a0) { + D_80186030[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801BE100; +extern u8 D_801BE101; +extern u8 D_801BE102; +extern u8 D_801BE103; +extern u8 D_801BE104; +extern u8 D_801BE105; +extern u8 D_801BE106; +extern u8 D_801BE107; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801BE100; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801BE101 = 0xf0; + *(u8 *)base = 0xf0; + D_801BE102 = 0xc0; + D_801BE106 = 0; + D_801BE105 = 0; + D_801BE104 = 0; + D_801BE107 = 0; + D_801BE103 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801BE100; +extern u8 D_801BE101; +extern u8 D_801BE102; + +s32 func_80164E40(void) { + u8 *p = &D_801BE100; + if (*p != 0) { + *p -= 0x10; + } + if (D_801BE101 != 0) { + D_801BE101 -= 0x10; + } + if (D_801BE102 != 0) { + D_801BE102 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80186040[])(void); + +void func_80164EA4(void *a0) { + D_80186040[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801BE14C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801BE14C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801BE140[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801BE140[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801BE140[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801BE140; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801BE140; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80186054[]; + extern u32 D_80186074, D_80186078, D_8018607C, D_80186080; + extern u32 D_80186074, D_80186078, D_8018607C, D_80186080; + extern u32 D_80186074, D_80186078, D_8018607C, D_80186080; + extern u32 D_80186074, D_80186078, D_8018607C, D_80186080; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80186054[0x00], p); + ApplyMatrixSV(mat, &D_80186054[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80186054[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80186054[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018607C; + *(u32 *)(prim + 0x24) = D_80186074; + *(u32 *)(prim + 0x28) = D_80186080; + *(u32 *)(prim + 0x2c) = D_80186078; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80186084[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80186084[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80186084[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80186084[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80186100[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80186100[a1 & 0x7F]; +} + + + +extern s32 D_80186120[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80186120[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018619C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018619C[a1 & 0x7F]; +} + + + +extern u8 D_801861BC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801861BC[a1 & 0x7F]; +} + + + +extern u8 D_801861DC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801861DC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801861FC[])(void); + D_801861FC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80186278[])(void); + +void func_80165AC8(void) { + D_80186278[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801862F4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801862F4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801BD8E4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801BD8E4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80186300[])(void); + +void func_80166018(void *a0) { + D_80186300[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80186308[])(void); + +void func_801663FC(void *a0) { + D_80186308[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801863D0[])(void); + +void func_80166618(void *a0) { + D_801863D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801863E0[])(void); + +void func_80166654(void *a0) { + D_801863E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801BE1C0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801BE1C0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BE1C0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801BE1C0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801BE1C0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801BE1C0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801BE1C0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80186324[]; + extern u8 D_80186310[]; + extern u8 D_80186338[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80186324; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80186310; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80186338; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80167714); + + +extern void (*D_801863F0[])(void); + +void func_801678B4(void *a0) { + D_801863F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801863FC[])(void); + +void func_80167A9C(void *a0) { + D_801863FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80186508; + extern u8 D_8018651C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80186508); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018651C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018635C[]; +extern u8 D_80186370[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018635C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80186370; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80186414[])(void); + +void func_80168744(void *a0) { + D_80186414[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80186404 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80186404[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80186404; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018641C[])(void); + +void func_801689D8(void *a0) { + D_8018641C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80186424[])(void); + +void func_80168AA8(void *a0) { + D_80186424[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018642C[])(void); + +void func_80168D58(void *a0) { + D_8018642C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80186434[])(void); + +void func_8016901C(void *a0) { + D_80186434[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_099/nonmatchings/ov_SC03_099_jr_8015C32C", func_80169228); + + +extern void (*D_8018643C[])(void); + +void func_801693CC(void *a0) { + D_8018643C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80186444[])(void); + +void func_80169830(void *a0) { + D_80186444[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801864F8[])(void); + +void func_80169B80(void *a0) { + D_801864F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018644C[]; + extern u8 D_801864BC[]; + extern u8 D_801864EC[]; + extern u8 D_801BF318[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801864EC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018644C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801BF318; + RotMatrixYXZ(rot, D_801BF318); + func_80048D9C(D_801BF318, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801864BC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80186500[])(void); + +void func_80169F00(void *a0) { + D_80186500[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801864B0[]; +extern char D_80186470[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801864B0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80186470); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80186538[])(void); + +void func_8016A020(void *a0) { + D_80186538[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80186508; + extern u8 D_8018651C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80186508); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018651C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80186544[])(void); + +void func_8016A700(void *a0) { + D_80186544[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018658C[])(void); + +void func_8016AB30(void *a0) { + D_8018658C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_100/ov_SC03_100_jr_8015AE2C.c b/src/ov_SC03_100/ov_SC03_100_jr_8015AE2C.c index eded5f322..169fe209a 100644 --- a/src/ov_SC03_100/ov_SC03_100_jr_8015AE2C.c +++ b/src/ov_SC03_100/ov_SC03_100_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80187114[])(void); - -void func_8015C714(void *a0) { - D_80187114[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80186F88[])(void*); - extern int D_80186F2C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80186F88)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80186F88)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186F2C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80186F88[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80186F88[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80186F88[])(void*); - extern int D_80186F2C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80186F88)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186F2C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80186F88)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80187124[])(void); - D_80187124[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80186F88[])(struct Ent_8015CD20 *); - extern u8 D_80186F3C; - extern u8 D_8018712C; - extern u8 D_8018713C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80186F88[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F3C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018712C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018713C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80186F88[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018715C[])(void); - D_8018715C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018714C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018714C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80186F88[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801871B8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801871B8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018629C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018629C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801871C0[])(void); - D_801871C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801871CC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801871CC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801871CC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801871CC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80186F88[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801871CC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80186F4C[]; - extern u8 D_80186F5C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F4C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F5C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801871CC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801871CC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801871CC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80187200[])(void); - D_80187200[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186F88[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80187208[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80187220[])(void); - D_80187220[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186F88[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80187208[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80187240[])(void); - D_80187240[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80186F88[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186F88)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80187250; -extern u16 D_80187252; -extern u16 D_80187254; -extern s32 D_80187258; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80187250 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80187252 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187254 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187258, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80187260; - -void func_8015E588(void) { - func_8013C9C4(&D_80187260); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80186F88[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186F88)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80187274[])(void); - D_80187274[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80186F88[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80186F88[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018727C[])(void); - D_8018727C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80186F6C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186F6C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80186F88[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187284[])(void); - D_80187284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80186F88[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80186F88[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018728C[])(void); - D_8018728C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80186F88[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80187294; - extern s32 D_801872A4; - extern s32 D_801872B4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80186F88[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187294); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872A4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80186F88[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872B4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801872C4[])(void); - D_801872C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80186F88[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80186F88[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80186F88[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186F88[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801872D0[])(void); - D_801872D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80186F88[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186F88[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80186F88[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186F88[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801872E4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801872E4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80186F88[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80186F88)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80186F88[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186F88[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80187360[])(void); - D_80187360[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80186F88[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80186F88)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80187370[])(void); - D_80187370[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80186F88[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80186F88[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80186F88[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80186F88[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80186F88[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80186F88[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80186F88[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80187378[])(void); - D_80187378[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80186F88[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80186F88)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80186F88[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80186F88)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187384[])(void); - D_80187384[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186F88 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80186F88[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80186F88[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80186F88[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80187394[])(void); - -void func_80160EA4(void *a0) { - D_80187394[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80186F88[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80186F88[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801873C4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801873C4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80187428; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80187428); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C72D0[]; - extern u8 D_801873F4[]; - extern u8 D_80187414[]; - extern u8 D_801C72DC[]; - extern u8 D_801C7304[]; - extern u8 D_801C731C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C72D0[0] = p; - func_80024054(&D_801873F4, &D_801C72DC); - func_8001CE28(p, &D_801C72DC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C72D0[1] = p; - func_80024054(&D_80187414, &D_801C7304); - func_8001CE28(p, &D_801C7304); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C72D0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C731C, 0x84); - func_8001CE68(p, &D_801C731C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C731C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C72D0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C72D0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80187428; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80187428; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80187428; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80187428; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C72D0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C72D0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018744C[])(void); - -void func_80162330(void *a0) { - D_8018744C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C7328[i] via `extern int D_801C7328[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80187458[]; - extern s32 D_80187470; - extern u8 D_801C7334[]; - extern u8 D_801C735C[]; - extern u8 D_801C7378[]; - extern int D_801C7328[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C7328[0] = (s32)item; - func_80024054(D_80187458, D_801C7334); - func_8001CE28(item, D_801C7334); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C7328[1] = (s32)item; - func_80024054(((u8 *)&D_80187470), D_801C735C); - func_8001CE28(item, D_801C735C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C7328[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C7378, 0x84); - func_8001CE68(item, D_801C7378); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C7378, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C7328[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C7328; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187494[])(void); - -void func_80162834(void *a0) { - D_80187494[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187484; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187484, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C6B58[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C6B58, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C6B58[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C6B58, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018749C[])(void); - -void func_80163A58(void *a0) { - D_8018749C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C6B60; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C6B60; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801874F0[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801874F0[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801874B8; -extern s16 D_801874EC; -extern s16 D_801874EA; -extern s16 D_801874E8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801874B8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801874EC = 0x80; - D_801874EA = 0x80; - D_801874E8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801874EC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801874EC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801874EC - 8; - D_801874EC = nv; - D_801874EA = nv; - D_801874E8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801874FC[])(void); - -void func_80164BA0(void *a0) { - D_801874FC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C7388; -extern u8 D_801C7389; -extern u8 D_801C738A; -extern u8 D_801C738B; -extern u8 D_801C738C; -extern u8 D_801C738D; -extern u8 D_801C738E; -extern u8 D_801C738F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C7388; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C7389 = 0xf0; - *(u8 *)base = 0xf0; - D_801C738A = 0xc0; - D_801C738E = 0; - D_801C738D = 0; - D_801C738C = 0; - D_801C738F = 0; - D_801C738B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C7388; -extern u8 D_801C7389; -extern u8 D_801C738A; - -s32 func_80164E40(void) { - u8 *p = &D_801C7388; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C7389 != 0) { - D_801C7389 -= 0x10; - } - if (D_801C738A != 0) { - D_801C738A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018750C[])(void); - -void func_80164EA4(void *a0) { - D_8018750C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C73D4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C73D4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C73C8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C73C8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C73C8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C73C8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C73C8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80187520[]; - extern u32 D_80187540, D_80187544, D_80187548, D_8018754C; - extern u32 D_80187540, D_80187544, D_80187548, D_8018754C; - extern u32 D_80187540, D_80187544, D_80187548, D_8018754C; - extern u32 D_80187540, D_80187544, D_80187548, D_8018754C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80187520[0x00], p); - ApplyMatrixSV(mat, &D_80187520[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80187520[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80187520[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80187548; - *(u32 *)(prim + 0x24) = D_80187540; - *(u32 *)(prim + 0x28) = D_8018754C; - *(u32 *)(prim + 0x2c) = D_80187544; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187550[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187550[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187550[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187550[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801875CC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801875CC[a1 & 0x7F]; -} - - - -extern s32 D_801875EC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801875EC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80187668[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80187668[a1 & 0x7F]; -} - - - -extern u8 D_80187688[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80187688[a1 & 0x7F]; -} - - - -extern u8 D_801876A8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801876A8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801876C8[])(void); - D_801876C8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187744[])(void); - -void func_80165AC8(void) { - D_80187744[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801877C0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801877C0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C6B68; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C6B68, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801877CC[])(void); - -void func_80166018(void *a0) { - D_801877CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801877D4[])(void); - -void func_801663FC(void *a0) { - D_801877D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018789C[])(void); - -void func_80166618(void *a0) { - D_8018789C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801878AC[])(void); - -void func_80166654(void *a0) { - D_801878AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C7448[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C7448[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C7448). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C7448[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C7448)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C7448[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C7448[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801877F0[]; - extern u8 D_801877DC[]; - extern u8 D_80187804[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801877F0; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801877DC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187804; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80167714); - - -extern void (*D_801878BC[])(void); - -void func_801678B4(void *a0) { - D_801878BC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801878C8[])(void); - -void func_80167A9C(void *a0) { - D_801878C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801879D4; - extern u8 D_801879E8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801879D4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801879E8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80187828[]; -extern u8 D_8018783C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80187828; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018783C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801878E0[])(void); - -void func_80168744(void *a0) { - D_801878E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801878D0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801878D0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801878D0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801878E8[])(void); - -void func_801689D8(void *a0) { - D_801878E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801878F0[])(void); - -void func_80168AA8(void *a0) { - D_801878F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801878F8[])(void); - -void func_80168D58(void *a0) { - D_801878F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80187900[])(void); - -void func_8016901C(void *a0) { - D_80187900[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015AE2C", func_80169228); - - -extern void (*D_80187908[])(void); - -void func_801693CC(void *a0) { - D_80187908[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80187910[])(void); - -void func_80169830(void *a0) { - D_80187910[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801879C4[])(void); - -void func_80169B80(void *a0) { - D_801879C4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80187918[]; - extern u8 D_80187988[]; - extern u8 D_801879B8[]; - extern u8 D_801C8820[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801879B8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80187918[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C8820; - RotMatrixYXZ(rot, D_801C8820); - func_80048D9C(D_801C8820, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80187988); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801879CC[])(void); - -void func_80169F00(void *a0) { - D_801879CC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018797C[]; -extern char D_8018793C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018797C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018793C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187A04[])(void); - -void func_8016A020(void *a0) { - D_80187A04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801879D4; - extern u8 D_801879E8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801879D4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801879E8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80187A10[])(void); - -void func_8016A700(void *a0) { - D_80187A10[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80187A58[])(void); - -void func_8016AB30(void *a0) { - D_80187A58[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c b/src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c new file mode 100644 index 000000000..0e2294dd6 --- /dev/null +++ b/src/ov_SC03_100/ov_SC03_100_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80186E24; +extern u8 D_80186D94; +extern u8 D_80186D70; +extern u8 D_80186D4C; +extern u8 D_80186E00; +extern u8 D_80186DDC; +extern u8 D_80186DB8; +extern u8 D_80186D28; +extern void func_80145934(void); +extern u8 D_80186EB4; +extern u8 D_80186E90; +extern u8 D_80186E6C; +extern u8 D_80186E48; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801862AC[]; +extern unsigned char D_801862DC[]; +extern unsigned char D_8018632C[]; +extern unsigned char D_8018635C[]; +extern unsigned char D_8018638C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801863DC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801864A4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018652C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186534; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C7278; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C727C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186564; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018660C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80186630[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80186620; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186644[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80186650[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80186660[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80186678[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80186668; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018668C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801866A8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80186698; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801866BC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801866D0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801866E4; +extern void (*D_8018670C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801866EC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80186758[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018675C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186BC0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80186BD0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C72B0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80186BF8[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80186BD8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80186BE8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80186C38[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80186C40[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80186C0C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80186C4C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80186C1C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C72B8; +extern s32 D_801C72C4; +extern s32 D_801C72C8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80186C88[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80186C5C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C72C0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80186ED8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80186CF8[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80186F7C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801870D0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186EEC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801870D8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186EFC; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80186F1C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801870E0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80187108[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80186F88[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80187114[])(void); + +void func_8015C714(void *a0) { + D_80187114[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80186F88[])(void*); + extern int D_80186F2C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80186F88)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80186F88)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186F2C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80186F88[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80186F88[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80186F88[])(void*); + extern int D_80186F2C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80186F88)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186F2C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80186F88)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80187124[])(void); + D_80187124[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80186F88[])(struct Ent_8015CD20 *); + extern u8 D_80186F3C; + extern u8 D_8018712C; + extern u8 D_8018713C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80186F88[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F3C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018712C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018713C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80186F88[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018715C[])(void); + D_8018715C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018714C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018714C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80186F88[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801871B8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801871B8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018629C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018629C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801871C0[])(void); + D_801871C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801871CC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801871CC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801871CC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801871CC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80186F88[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801871CC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80186F4C[]; + extern u8 D_80186F5C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F4C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F5C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801871CC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801871CC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801871CC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80187200[])(void); + D_80187200[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186F88[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80187208[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80187220[])(void); + D_80187220[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186F88[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80187208[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80187208[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80187240[])(void); + D_80187240[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80186F88[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186F88)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80187250; +extern u16 D_80187252; +extern u16 D_80187254; +extern s32 D_80187258; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80187250 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80187252 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187254 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187258, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80187260; + +void func_8015E588(void) { + func_8013C9C4(&D_80187260); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80186F88[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186F88)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80187274[])(void); + D_80187274[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80186F88[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80186F88[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018727C[])(void); + D_8018727C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80186F6C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186F6C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80186F88[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187284[])(void); + D_80187284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80186F88[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80186F88[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018728C[])(void); + D_8018728C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80186F88[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80187294; + extern s32 D_801872A4; + extern s32 D_801872B4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187294); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872A4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80186F88[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872B4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801872C4[])(void); + D_801872C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80186F88[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80186F88[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80186F88[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186F88[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801872D0[])(void); + D_801872D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80186F88[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186F88[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80186F88[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186F88[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801872E4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801872E4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80186F88[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80186F88)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80186F88[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186F88[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80187360[])(void); + D_80187360[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80186F88[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80186F88)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80187370[])(void); + D_80187370[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80186F88[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80186F88[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80186F88[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80186F88[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80186F88[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80186F88[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80186F88[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80187378[])(void); + D_80187378[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80186F88[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80186F88)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80186F88[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80186F88)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187384[])(void); + D_80187384[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186F88 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80186F88[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80186F88[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80186F88[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80187394[])(void); + +void func_80160EA4(void *a0) { + D_80187394[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80186F88[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80186F88[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801873C4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801873C4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80187428; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80187428); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C72D0[]; + extern u8 D_801873F4[]; + extern u8 D_80187414[]; + extern u8 D_801C72DC[]; + extern u8 D_801C7304[]; + extern u8 D_801C731C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C72D0[0] = p; + func_80024054(&D_801873F4, &D_801C72DC); + func_8001CE28(p, &D_801C72DC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C72D0[1] = p; + func_80024054(&D_80187414, &D_801C7304); + func_8001CE28(p, &D_801C7304); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C72D0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C731C, 0x84); + func_8001CE68(p, &D_801C731C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C731C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C72D0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C72D0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80187428; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80187428; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80187428; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80187428; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C72D0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C72D0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018744C[])(void); + +void func_80162330(void *a0) { + D_8018744C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C7328[i] via `extern int D_801C7328[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80187458[]; + extern s32 D_80187470; + extern u8 D_801C7334[]; + extern u8 D_801C735C[]; + extern u8 D_801C7378[]; + extern int D_801C7328[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C7328[0] = (s32)item; + func_80024054(D_80187458, D_801C7334); + func_8001CE28(item, D_801C7334); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C7328[1] = (s32)item; + func_80024054(((u8 *)&D_80187470), D_801C735C); + func_8001CE28(item, D_801C735C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C7328[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C7378, 0x84); + func_8001CE68(item, D_801C7378); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C7378, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C7328[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C7328; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_801627E8); + + +extern void (*D_80187494[])(void); + +void func_80162834(void *a0) { + D_80187494[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187484; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187484, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C6B58[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C6B58, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C6B58[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C6B58, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018749C[])(void); + +void func_80163A58(void *a0) { + D_8018749C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C6B60; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C6B60; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801874F0[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801874F0[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801874B8; +extern s16 D_801874EC; +extern s16 D_801874EA; +extern s16 D_801874E8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801874B8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801874EC = 0x80; + D_801874EA = 0x80; + D_801874E8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801874EC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801874EC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801874EC - 8; + D_801874EC = nv; + D_801874EA = nv; + D_801874E8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801874FC[])(void); + +void func_80164BA0(void *a0) { + D_801874FC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C7388; +extern u8 D_801C7389; +extern u8 D_801C738A; +extern u8 D_801C738B; +extern u8 D_801C738C; +extern u8 D_801C738D; +extern u8 D_801C738E; +extern u8 D_801C738F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C7388; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C7389 = 0xf0; + *(u8 *)base = 0xf0; + D_801C738A = 0xc0; + D_801C738E = 0; + D_801C738D = 0; + D_801C738C = 0; + D_801C738F = 0; + D_801C738B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C7388; +extern u8 D_801C7389; +extern u8 D_801C738A; + +s32 func_80164E40(void) { + u8 *p = &D_801C7388; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C7389 != 0) { + D_801C7389 -= 0x10; + } + if (D_801C738A != 0) { + D_801C738A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018750C[])(void); + +void func_80164EA4(void *a0) { + D_8018750C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C73D4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C73D4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C73C8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C73C8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C73C8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C73C8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C73C8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80187520[]; + extern u32 D_80187540, D_80187544, D_80187548, D_8018754C; + extern u32 D_80187540, D_80187544, D_80187548, D_8018754C; + extern u32 D_80187540, D_80187544, D_80187548, D_8018754C; + extern u32 D_80187540, D_80187544, D_80187548, D_8018754C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80187520[0x00], p); + ApplyMatrixSV(mat, &D_80187520[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80187520[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80187520[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80187548; + *(u32 *)(prim + 0x24) = D_80187540; + *(u32 *)(prim + 0x28) = D_8018754C; + *(u32 *)(prim + 0x2c) = D_80187544; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187550[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187550[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187550[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187550[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801875CC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801875CC[a1 & 0x7F]; +} + + + +extern s32 D_801875EC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801875EC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80187668[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80187668[a1 & 0x7F]; +} + + + +extern u8 D_80187688[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80187688[a1 & 0x7F]; +} + + + +extern u8 D_801876A8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801876A8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801876C8[])(void); + D_801876C8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187744[])(void); + +void func_80165AC8(void) { + D_80187744[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801877C0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801877C0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C6B68; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C6B68, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801877CC[])(void); + +void func_80166018(void *a0) { + D_801877CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801877D4[])(void); + +void func_801663FC(void *a0) { + D_801877D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018789C[])(void); + +void func_80166618(void *a0) { + D_8018789C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801878AC[])(void); + +void func_80166654(void *a0) { + D_801878AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C7448[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C7448[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C7448). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C7448[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C7448)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C7448[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C7448[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801877F0[]; + extern u8 D_801877DC[]; + extern u8 D_80187804[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801877F0; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801877DC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187804; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80167714); + + +extern void (*D_801878BC[])(void); + +void func_801678B4(void *a0) { + D_801878BC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801878C8[])(void); + +void func_80167A9C(void *a0) { + D_801878C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801879D4; + extern u8 D_801879E8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801879D4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801879E8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80187828[]; +extern u8 D_8018783C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80187828; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018783C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801878E0[])(void); + +void func_80168744(void *a0) { + D_801878E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801878D0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801878D0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801878D0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801878E8[])(void); + +void func_801689D8(void *a0) { + D_801878E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801878F0[])(void); + +void func_80168AA8(void *a0) { + D_801878F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801878F8[])(void); + +void func_80168D58(void *a0) { + D_801878F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80187900[])(void); + +void func_8016901C(void *a0) { + D_80187900[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_100/nonmatchings/ov_SC03_100_jr_8015C32C", func_80169228); + + +extern void (*D_80187908[])(void); + +void func_801693CC(void *a0) { + D_80187908[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80187910[])(void); + +void func_80169830(void *a0) { + D_80187910[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801879C4[])(void); + +void func_80169B80(void *a0) { + D_801879C4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80187918[]; + extern u8 D_80187988[]; + extern u8 D_801879B8[]; + extern u8 D_801C8820[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801879B8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80187918[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C8820; + RotMatrixYXZ(rot, D_801C8820); + func_80048D9C(D_801C8820, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80187988); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801879CC[])(void); + +void func_80169F00(void *a0) { + D_801879CC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018797C[]; +extern char D_8018793C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018797C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018793C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187A04[])(void); + +void func_8016A020(void *a0) { + D_80187A04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801879D4; + extern u8 D_801879E8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801879D4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801879E8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80187A10[])(void); + +void func_8016A700(void *a0) { + D_80187A10[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80187A58[])(void); + +void func_8016AB30(void *a0) { + D_80187A58[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_101/ov_SC03_101_jr_8015AE2C.c b/src/ov_SC03_101/ov_SC03_101_jr_8015AE2C.c index 058a35270..1e24827a6 100644 --- a/src/ov_SC03_101/ov_SC03_101_jr_8015AE2C.c +++ b/src/ov_SC03_101/ov_SC03_101_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801860F0[])(void); - -void func_8015C714(void *a0) { - D_801860F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80185F64[])(void*); - extern int D_80185F08; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80185F64)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80185F64)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185F08); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80185F64[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80185F64[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80185F64[])(void*); - extern int D_80185F08; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80185F64)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185F08); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80185F64)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80186100[])(void); - D_80186100[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80185F64[])(struct Ent_8015CD20 *); - extern u8 D_80185F18; - extern u8 D_80186108; - extern u8 D_80186118; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80185F64[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185F18); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186108); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186118); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80185F64[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80186138[])(void); - D_80186138[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80186128; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80186128 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80185F64[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80186194; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80186194, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80185278[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80185278; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018619C[])(void); - D_8018619C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801861A8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801861A8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801861A8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801861A8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80185F64[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801861A8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80185F28[]; - extern u8 D_80185F38[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185F28); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185F38); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801861A8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801861A8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801861A8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801861DC[])(void); - D_801861DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185F64[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801861E4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801861FC[])(void); - D_801861FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185F64[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801861E4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018621C[])(void); - D_8018621C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80185F64[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185F64)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018622C; -extern u16 D_8018622E; -extern u16 D_80186230; -extern s32 D_80186234; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018622C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018622E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80186230 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186234, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018623C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018623C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80185F64[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185F64)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80186250[])(void); - D_80186250[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80185F64[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80185F64[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80186258[])(void); - D_80186258[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80185F48; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185F48); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80185F64[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80186260[])(void); - D_80186260[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80185F64[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80185F64[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80186268[])(void); - D_80186268[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80185F64[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80186270; - extern s32 D_80186280; - extern s32 D_80186290; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80185F64[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186270); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186280); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80185F64[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186290); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801862A0[])(void); - D_801862A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80185F64[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80185F64[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80185F64[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185F64[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801862AC[])(void); - D_801862AC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80185F64[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185F64[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80185F64[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185F64[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801862C0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801862C0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80185F64[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80185F64)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80185F64[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185F64[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018633C[])(void); - D_8018633C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80185F64[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80185F64)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018634C[])(void); - D_8018634C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80185F64[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80185F64[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80185F64[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80185F64[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80185F64[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80185F64[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80185F64[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80186354[])(void); - D_80186354[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80185F64[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80185F64)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80185F64[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80185F64)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80186360[])(void); - D_80186360[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185F64 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80185F64[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80185F64[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80185F64[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80186370[])(void); - -void func_80160EA4(void *a0) { - D_80186370[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80185F64[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80185F64[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801863A0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801863A0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80186404; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80186404); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019CB98[]; - extern u8 D_801863D0[]; - extern u8 D_801863F0[]; - extern u8 D_8019CBA4[]; - extern u8 D_8019CBCC[]; - extern u8 D_8019CBE4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019CB98[0] = p; - func_80024054(&D_801863D0, &D_8019CBA4); - func_8001CE28(p, &D_8019CBA4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019CB98[1] = p; - func_80024054(&D_801863F0, &D_8019CBCC); - func_8001CE28(p, &D_8019CBCC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019CB98[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019CBE4, 0x84); - func_8001CE68(p, &D_8019CBE4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019CBE4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019CB98[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019CB98; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80186404; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80186404; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80186404; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80186404; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019CB98[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019CB98; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80186428[])(void); - -void func_80162330(void *a0) { - D_80186428[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019CBF0[i] via `extern int D_8019CBF0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80186434[]; - extern s32 D_8018644C; - extern u8 D_8019CBFC[]; - extern u8 D_8019CC24[]; - extern u8 D_8019CC40[]; - extern int D_8019CBF0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019CBF0[0] = (s32)item; - func_80024054(D_80186434, D_8019CBFC); - func_8001CE28(item, D_8019CBFC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019CBF0[1] = (s32)item; - func_80024054(((u8 *)&D_8018644C), D_8019CC24); - func_8001CE28(item, D_8019CC24); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019CBF0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019CC40, 0x84); - func_8001CE68(item, D_8019CC40); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019CC40, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019CBF0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019CBF0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_801627E8); - - -extern void (*D_80186470[])(void); - -void func_80162834(void *a0) { - D_80186470[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80186460; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80186460, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019C420[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019C420, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019C420[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019C420, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80186478[])(void); - -void func_80163A58(void *a0) { - D_80186478[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019C428; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019C428; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801864CC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801864CC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80186494; -extern s16 D_801864C8; -extern s16 D_801864C6; -extern s16 D_801864C4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80186494; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801864C8 = 0x80; - D_801864C6 = 0x80; - D_801864C4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801864C8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801864C8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801864C8 - 8; - D_801864C8 = nv; - D_801864C6 = nv; - D_801864C4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801864D8[])(void); - -void func_80164BA0(void *a0) { - D_801864D8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019CC50; -extern u8 D_8019CC51; -extern u8 D_8019CC52; -extern u8 D_8019CC53; -extern u8 D_8019CC54; -extern u8 D_8019CC55; -extern u8 D_8019CC56; -extern u8 D_8019CC57; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019CC50; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019CC51 = 0xf0; - *(u8 *)base = 0xf0; - D_8019CC52 = 0xc0; - D_8019CC56 = 0; - D_8019CC55 = 0; - D_8019CC54 = 0; - D_8019CC57 = 0; - D_8019CC53 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019CC50; -extern u8 D_8019CC51; -extern u8 D_8019CC52; - -s32 func_80164E40(void) { - u8 *p = &D_8019CC50; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019CC51 != 0) { - D_8019CC51 -= 0x10; - } - if (D_8019CC52 != 0) { - D_8019CC52 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801864E8[])(void); - -void func_80164EA4(void *a0) { - D_801864E8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019CC9C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019CC9C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019CC90[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019CC90[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019CC90[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019CC90; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019CC90; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801864FC[]; - extern u32 D_8018651C, D_80186520, D_80186524, D_80186528; - extern u32 D_8018651C, D_80186520, D_80186524, D_80186528; - extern u32 D_8018651C, D_80186520, D_80186524, D_80186528; - extern u32 D_8018651C, D_80186520, D_80186524, D_80186528; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801864FC[0x00], p); - ApplyMatrixSV(mat, &D_801864FC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801864FC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801864FC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80186524; - *(u32 *)(prim + 0x24) = D_8018651C; - *(u32 *)(prim + 0x28) = D_80186528; - *(u32 *)(prim + 0x2c) = D_80186520; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018652C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018652C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018652C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018652C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801865A8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801865A8[a1 & 0x7F]; -} - - - -extern s32 D_801865C8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801865C8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80186644[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80186644[a1 & 0x7F]; -} - - - -extern u8 D_80186664[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80186664[a1 & 0x7F]; -} - - - -extern u8 D_80186684[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80186684[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801866A4[])(void); - D_801866A4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80186720[])(void); - -void func_80165AC8(void) { - D_80186720[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018679C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018679C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019C430; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019C430, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801867A8[])(void); - -void func_80166018(void *a0) { - D_801867A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801867B0[])(void); - -void func_801663FC(void *a0) { - D_801867B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80186878[])(void); - -void func_80166618(void *a0) { - D_80186878[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80186888[])(void); - -void func_80166654(void *a0) { - D_80186888[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019CD10[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019CD10[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019CD10). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019CD10[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019CD10)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019CD10[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019CD10[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801867CC[]; - extern u8 D_801867B8[]; - extern u8 D_801867E0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801867CC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801867B8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801867E0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80167714); - - -extern void (*D_80186898[])(void); - -void func_801678B4(void *a0) { - D_80186898[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801868A4[])(void); - -void func_80167A9C(void *a0) { - D_801868A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801869B0; - extern u8 D_801869C4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801869B0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801869C4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80186804[]; -extern u8 D_80186818[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80186804; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80186818; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801868BC[])(void); - -void func_80168744(void *a0) { - D_801868BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801868AC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801868AC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801868AC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801868C4[])(void); - -void func_801689D8(void *a0) { - D_801868C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801868CC[])(void); - -void func_80168AA8(void *a0) { - D_801868CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801868D4[])(void); - -void func_80168D58(void *a0) { - D_801868D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801868DC[])(void); - -void func_8016901C(void *a0) { - D_801868DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015AE2C", func_80169228); - - -extern void (*D_801868E4[])(void); - -void func_801693CC(void *a0) { - D_801868E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801868EC[])(void); - -void func_80169830(void *a0) { - D_801868EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801869A0[])(void); - -void func_80169B80(void *a0) { - D_801869A0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801868F4[]; - extern u8 D_80186964[]; - extern u8 D_80186994[]; - extern u8 D_8019E0E0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80186994, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801868F4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019E0E0; - RotMatrixYXZ(rot, D_8019E0E0); - func_80048D9C(D_8019E0E0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80186964); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801869A8[])(void); - -void func_80169F00(void *a0) { - D_801869A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80186958[]; -extern char D_80186918[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80186958, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80186918); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801869E0[])(void); - -void func_8016A020(void *a0) { - D_801869E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801869B0; - extern u8 D_801869C4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801869B0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801869C4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801869EC[])(void); - -void func_8016A700(void *a0) { - D_801869EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80186A34[])(void); - -void func_8016AB30(void *a0) { - D_80186A34[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c b/src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c new file mode 100644 index 000000000..0b71c887d --- /dev/null +++ b/src/ov_SC03_101/ov_SC03_101_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80185E00; +extern u8 D_80185D70; +extern u8 D_80185D4C; +extern u8 D_80185D28; +extern u8 D_80185DDC; +extern u8 D_80185DB8; +extern u8 D_80185D94; +extern u8 D_80185D04; +extern void func_80145934(void); +extern u8 D_80185E90; +extern u8 D_80185E6C; +extern u8 D_80185E48; +extern u8 D_80185E24; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80185288[]; +extern unsigned char D_801852B8[]; +extern unsigned char D_80185308[]; +extern unsigned char D_80185338[]; +extern unsigned char D_80185368[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801853B8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80185480[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80185508[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80185510; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019CB40; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019CB44; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80185540; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801855E8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018560C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801855FC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80185620[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018562C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018563C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80185654[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80185644; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80185668[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80185684[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80185674; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80185698[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801856AC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801856C0; +extern void (*D_801856E8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801856C8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80185734[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80185738[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80185B9C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80185BAC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019CB78; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80185BD4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80185BB4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80185BC4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80185C14[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80185C1C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80185BE8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80185C28[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80185BF8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019CB80; +extern s32 D_8019CB8C; +extern s32 D_8019CB90; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80185C64[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80185C38[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019CB88; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80185EB4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80185CD4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80185F58[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801860AC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80185EC8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801860B4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80185ED8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80185EF8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801860BC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801860E4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80185F64[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801860F0[])(void); + +void func_8015C714(void *a0) { + D_801860F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80185F64[])(void*); + extern int D_80185F08; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80185F64)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80185F64)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185F08); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80185F64[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80185F64[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80185F64[])(void*); + extern int D_80185F08; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80185F64)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185F08); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80185F64)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80186100[])(void); + D_80186100[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80185F64[])(struct Ent_8015CD20 *); + extern u8 D_80185F18; + extern u8 D_80186108; + extern u8 D_80186118; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80185F64[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185F18); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186108); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186118); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80185F64[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80186138[])(void); + D_80186138[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80186128; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80186128 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80185F64[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80186194; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80186194, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80185278[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80185278; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018619C[])(void); + D_8018619C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801861A8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801861A8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801861A8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801861A8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80185F64[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801861A8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80185F28[]; + extern u8 D_80185F38[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185F28); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185F38); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801861A8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801861A8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801861A8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801861DC[])(void); + D_801861DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185F64[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801861E4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801861FC[])(void); + D_801861FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185F64[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801861E4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801861E4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018621C[])(void); + D_8018621C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80185F64[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185F64)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018622C; +extern u16 D_8018622E; +extern u16 D_80186230; +extern s32 D_80186234; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018622C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018622E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80186230 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186234, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018623C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018623C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80185F64[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185F64)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80186250[])(void); + D_80186250[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80185F64[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80185F64[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80186258[])(void); + D_80186258[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80185F48; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185F48); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80185F64[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80186260[])(void); + D_80186260[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80185F64[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80185F64[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80186268[])(void); + D_80186268[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80185F64[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80186270; + extern s32 D_80186280; + extern s32 D_80186290; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186270); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186280); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80185F64[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186290); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801862A0[])(void); + D_801862A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80185F64[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80185F64[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80185F64[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185F64[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801862AC[])(void); + D_801862AC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80185F64[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185F64[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80185F64[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185F64[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801862C0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801862C0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80185F64[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80185F64)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80185F64[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185F64[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018633C[])(void); + D_8018633C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80185F64[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80185F64)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018634C[])(void); + D_8018634C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80185F64[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80185F64[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80185F64[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80185F64[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80185F64[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80185F64[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80185F64[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80186354[])(void); + D_80186354[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80185F64[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80185F64)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80185F64[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80185F64)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80186360[])(void); + D_80186360[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185F64 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80185F64[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80185F64[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80185F64[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80186370[])(void); + +void func_80160EA4(void *a0) { + D_80186370[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80185F64[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80185F64[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801863A0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801863A0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80186404; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80186404); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019CB98[]; + extern u8 D_801863D0[]; + extern u8 D_801863F0[]; + extern u8 D_8019CBA4[]; + extern u8 D_8019CBCC[]; + extern u8 D_8019CBE4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019CB98[0] = p; + func_80024054(&D_801863D0, &D_8019CBA4); + func_8001CE28(p, &D_8019CBA4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019CB98[1] = p; + func_80024054(&D_801863F0, &D_8019CBCC); + func_8001CE28(p, &D_8019CBCC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019CB98[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019CBE4, 0x84); + func_8001CE68(p, &D_8019CBE4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019CBE4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019CB98[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019CB98; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80186404; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80186404; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80186404; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80186404; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019CB98[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019CB98; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80186428[])(void); + +void func_80162330(void *a0) { + D_80186428[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019CBF0[i] via `extern int D_8019CBF0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80186434[]; + extern s32 D_8018644C; + extern u8 D_8019CBFC[]; + extern u8 D_8019CC24[]; + extern u8 D_8019CC40[]; + extern int D_8019CBF0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019CBF0[0] = (s32)item; + func_80024054(D_80186434, D_8019CBFC); + func_8001CE28(item, D_8019CBFC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019CBF0[1] = (s32)item; + func_80024054(((u8 *)&D_8018644C), D_8019CC24); + func_8001CE28(item, D_8019CC24); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019CBF0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019CC40, 0x84); + func_8001CE68(item, D_8019CC40); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019CC40, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019CBF0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019CBF0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_801627E8); + + +extern void (*D_80186470[])(void); + +void func_80162834(void *a0) { + D_80186470[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80186460; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80186460, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019C420[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019C420, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019C420[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019C420, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80186478[])(void); + +void func_80163A58(void *a0) { + D_80186478[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019C428; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019C428; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801864CC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801864CC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80186494; +extern s16 D_801864C8; +extern s16 D_801864C6; +extern s16 D_801864C4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80186494; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801864C8 = 0x80; + D_801864C6 = 0x80; + D_801864C4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801864C8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801864C8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801864C8 - 8; + D_801864C8 = nv; + D_801864C6 = nv; + D_801864C4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801864D8[])(void); + +void func_80164BA0(void *a0) { + D_801864D8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019CC50; +extern u8 D_8019CC51; +extern u8 D_8019CC52; +extern u8 D_8019CC53; +extern u8 D_8019CC54; +extern u8 D_8019CC55; +extern u8 D_8019CC56; +extern u8 D_8019CC57; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019CC50; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019CC51 = 0xf0; + *(u8 *)base = 0xf0; + D_8019CC52 = 0xc0; + D_8019CC56 = 0; + D_8019CC55 = 0; + D_8019CC54 = 0; + D_8019CC57 = 0; + D_8019CC53 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019CC50; +extern u8 D_8019CC51; +extern u8 D_8019CC52; + +s32 func_80164E40(void) { + u8 *p = &D_8019CC50; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019CC51 != 0) { + D_8019CC51 -= 0x10; + } + if (D_8019CC52 != 0) { + D_8019CC52 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801864E8[])(void); + +void func_80164EA4(void *a0) { + D_801864E8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019CC9C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019CC9C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019CC90[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019CC90[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019CC90[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019CC90; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019CC90; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801864FC[]; + extern u32 D_8018651C, D_80186520, D_80186524, D_80186528; + extern u32 D_8018651C, D_80186520, D_80186524, D_80186528; + extern u32 D_8018651C, D_80186520, D_80186524, D_80186528; + extern u32 D_8018651C, D_80186520, D_80186524, D_80186528; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801864FC[0x00], p); + ApplyMatrixSV(mat, &D_801864FC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801864FC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801864FC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80186524; + *(u32 *)(prim + 0x24) = D_8018651C; + *(u32 *)(prim + 0x28) = D_80186528; + *(u32 *)(prim + 0x2c) = D_80186520; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018652C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018652C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018652C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018652C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801865A8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801865A8[a1 & 0x7F]; +} + + + +extern s32 D_801865C8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801865C8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80186644[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80186644[a1 & 0x7F]; +} + + + +extern u8 D_80186664[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80186664[a1 & 0x7F]; +} + + + +extern u8 D_80186684[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80186684[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801866A4[])(void); + D_801866A4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80186720[])(void); + +void func_80165AC8(void) { + D_80186720[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018679C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018679C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019C430; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019C430, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801867A8[])(void); + +void func_80166018(void *a0) { + D_801867A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801867B0[])(void); + +void func_801663FC(void *a0) { + D_801867B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80186878[])(void); + +void func_80166618(void *a0) { + D_80186878[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80186888[])(void); + +void func_80166654(void *a0) { + D_80186888[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019CD10[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019CD10[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019CD10). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019CD10[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019CD10)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019CD10[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019CD10[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801867CC[]; + extern u8 D_801867B8[]; + extern u8 D_801867E0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801867CC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801867B8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801867E0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80167714); + + +extern void (*D_80186898[])(void); + +void func_801678B4(void *a0) { + D_80186898[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801868A4[])(void); + +void func_80167A9C(void *a0) { + D_801868A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801869B0; + extern u8 D_801869C4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801869B0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801869C4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80186804[]; +extern u8 D_80186818[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80186804; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80186818; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801868BC[])(void); + +void func_80168744(void *a0) { + D_801868BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801868AC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801868AC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801868AC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801868C4[])(void); + +void func_801689D8(void *a0) { + D_801868C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801868CC[])(void); + +void func_80168AA8(void *a0) { + D_801868CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801868D4[])(void); + +void func_80168D58(void *a0) { + D_801868D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801868DC[])(void); + +void func_8016901C(void *a0) { + D_801868DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_101/nonmatchings/ov_SC03_101_jr_8015C32C", func_80169228); + + +extern void (*D_801868E4[])(void); + +void func_801693CC(void *a0) { + D_801868E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801868EC[])(void); + +void func_80169830(void *a0) { + D_801868EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801869A0[])(void); + +void func_80169B80(void *a0) { + D_801869A0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801868F4[]; + extern u8 D_80186964[]; + extern u8 D_80186994[]; + extern u8 D_8019E0E0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80186994, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801868F4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019E0E0; + RotMatrixYXZ(rot, D_8019E0E0); + func_80048D9C(D_8019E0E0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80186964); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801869A8[])(void); + +void func_80169F00(void *a0) { + D_801869A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80186958[]; +extern char D_80186918[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80186958, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80186918); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801869E0[])(void); + +void func_8016A020(void *a0) { + D_801869E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801869B0; + extern u8 D_801869C4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801869B0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801869C4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801869EC[])(void); + +void func_8016A700(void *a0) { + D_801869EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80186A34[])(void); + +void func_8016AB30(void *a0) { + D_80186A34[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_102/ov_SC03_102_jr_8015AE2C.c b/src/ov_SC03_102/ov_SC03_102_jr_8015AE2C.c index bd38e7d56..c5e4916fe 100644 --- a/src/ov_SC03_102/ov_SC03_102_jr_8015AE2C.c +++ b/src/ov_SC03_102/ov_SC03_102_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801889A8[])(void); - -void func_8015C714(void *a0) { - D_801889A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018881C[])(void*); - extern int D_801887C0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018881C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018881C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801887C0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018881C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018881C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018881C[])(void*); - extern int D_801887C0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018881C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801887C0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018881C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801889B8[])(void); - D_801889B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018881C[])(struct Ent_8015CD20 *); - extern u8 D_801887D0; - extern u8 D_801889C0; - extern u8 D_801889D0; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018881C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801887D0); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801889C0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801889D0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018881C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801889F0[])(void); - D_801889F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801889E0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801889E0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018881C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80188A4C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80188A4C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80187B30[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80187B30; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80188A54[])(void); - D_80188A54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80188A60[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80188A60[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80188A60[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80188A60[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018881C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80188A60[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801887E0[]; - extern u8 D_801887F0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801887E0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801887F0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80188A60[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80188A60[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80188A60[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80188A94[])(void); - D_80188A94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018881C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188A9C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80188AB4[])(void); - D_80188AB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018881C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188A9C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80188AD4[])(void); - D_80188AD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018881C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018881C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80188AE4; -extern u16 D_80188AE6; -extern u16 D_80188AE8; -extern s32 D_80188AEC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80188AE4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80188AE6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80188AE8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188AEC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80188AF4; - -void func_8015E588(void) { - func_8013C9C4(&D_80188AF4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018881C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018881C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80188B08[])(void); - D_80188B08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018881C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018881C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80188B10[])(void); - D_80188B10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80188800; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188800); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018881C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80188B18[])(void); - D_80188B18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018881C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018881C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80188B20[])(void); - D_80188B20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018881C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80188B28; - extern s32 D_80188B38; - extern s32 D_80188B48; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018881C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188B28); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188B38); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018881C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188B48); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80188B58[])(void); - D_80188B58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018881C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018881C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018881C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018881C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80188B64[])(void); - D_80188B64[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018881C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018881C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018881C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018881C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80188B78[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80188B78[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018881C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018881C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018881C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018881C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80188BF4[])(void); - D_80188BF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018881C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018881C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80188C04[])(void); - D_80188C04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018881C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018881C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018881C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018881C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018881C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018881C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018881C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80188C0C[])(void); - D_80188C0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018881C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018881C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018881C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018881C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80188C18[])(void); - D_80188C18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018881C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018881C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018881C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018881C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80188C28[])(void); - -void func_80160EA4(void *a0) { - D_80188C28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018881C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018881C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80188C58[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80188C58[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80188CBC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80188CBC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B8810[]; - extern u8 D_80188C88[]; - extern u8 D_80188CA8[]; - extern u8 D_801B881C[]; - extern u8 D_801B8844[]; - extern u8 D_801B885C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B8810[0] = p; - func_80024054(&D_80188C88, &D_801B881C); - func_8001CE28(p, &D_801B881C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B8810[1] = p; - func_80024054(&D_80188CA8, &D_801B8844); - func_8001CE28(p, &D_801B8844); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B8810[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B885C, 0x84); - func_8001CE68(p, &D_801B885C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B885C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B8810[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B8810; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80188CBC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80188CBC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80188CBC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80188CBC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B8810[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B8810; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80188CE0[])(void); - -void func_80162330(void *a0) { - D_80188CE0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B8868[i] via `extern int D_801B8868[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80188CEC[]; - extern s32 D_80188D04; - extern u8 D_801B8874[]; - extern u8 D_801B889C[]; - extern u8 D_801B88B8[]; - extern int D_801B8868[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B8868[0] = (s32)item; - func_80024054(D_80188CEC, D_801B8874); - func_8001CE28(item, D_801B8874); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B8868[1] = (s32)item; - func_80024054(((u8 *)&D_80188D04), D_801B889C); - func_8001CE28(item, D_801B889C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B8868[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B88B8, 0x84); - func_8001CE68(item, D_801B88B8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B88B8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B8868[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B8868; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_801627E8); - - -extern void (*D_80188D28[])(void); - -void func_80162834(void *a0) { - D_80188D28[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80188D18; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80188D18, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B809C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B809C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B809C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B809C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80188D30[])(void); - -void func_80163A58(void *a0) { - D_80188D30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B80A4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B80A4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80188D84[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80188D84[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80188D4C; -extern s16 D_80188D80; -extern s16 D_80188D7E; -extern s16 D_80188D7C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80188D4C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80188D80 = 0x80; - D_80188D7E = 0x80; - D_80188D7C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80188D80 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188D80` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80188D80 - 8; - D_80188D80 = nv; - D_80188D7E = nv; - D_80188D7C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80188D90[])(void); - -void func_80164BA0(void *a0) { - D_80188D90[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B88C8; -extern u8 D_801B88C9; -extern u8 D_801B88CA; -extern u8 D_801B88CB; -extern u8 D_801B88CC; -extern u8 D_801B88CD; -extern u8 D_801B88CE; -extern u8 D_801B88CF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B88C8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B88C9 = 0xf0; - *(u8 *)base = 0xf0; - D_801B88CA = 0xc0; - D_801B88CE = 0; - D_801B88CD = 0; - D_801B88CC = 0; - D_801B88CF = 0; - D_801B88CB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B88C8; -extern u8 D_801B88C9; -extern u8 D_801B88CA; - -s32 func_80164E40(void) { - u8 *p = &D_801B88C8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B88C9 != 0) { - D_801B88C9 -= 0x10; - } - if (D_801B88CA != 0) { - D_801B88CA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80188DA0[])(void); - -void func_80164EA4(void *a0) { - D_80188DA0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B8914[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B8914[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B8908[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B8908[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B8908[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B8908; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B8908; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80188DB4[]; - extern u32 D_80188DD4, D_80188DD8, D_80188DDC, D_80188DE0; - extern u32 D_80188DD4, D_80188DD8, D_80188DDC, D_80188DE0; - extern u32 D_80188DD4, D_80188DD8, D_80188DDC, D_80188DE0; - extern u32 D_80188DD4, D_80188DD8, D_80188DDC, D_80188DE0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80188DB4[0x00], p); - ApplyMatrixSV(mat, &D_80188DB4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80188DB4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80188DB4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80188DDC; - *(u32 *)(prim + 0x24) = D_80188DD4; - *(u32 *)(prim + 0x28) = D_80188DE0; - *(u32 *)(prim + 0x2c) = D_80188DD8; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80188DE4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80188DE4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80188DE4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80188DE4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80188E60[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80188E60[a1 & 0x7F]; -} - - - -extern s32 D_80188E80[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80188E80[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80188EFC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80188EFC[a1 & 0x7F]; -} - - - -extern u8 D_80188F1C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80188F1C[a1 & 0x7F]; -} - - - -extern u8 D_80188F3C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80188F3C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80188F5C[])(void); - D_80188F5C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80188FD8[])(void); - -void func_80165AC8(void) { - D_80188FD8[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80189054[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80189054[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B80AC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B80AC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80189060[])(void); - -void func_80166018(void *a0) { - D_80189060[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80189068[])(void); - -void func_801663FC(void *a0) { - D_80189068[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80189130[])(void); - -void func_80166618(void *a0) { - D_80189130[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80189140[])(void); - -void func_80166654(void *a0) { - D_80189140[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B8988[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B8988[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B8988). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B8988[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B8988)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B8988[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B8988[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80189084[]; - extern u8 D_80189070[]; - extern u8 D_80189098[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80189084; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80189070; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80189098; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80167714); - - -extern void (*D_80189150[])(void); - -void func_801678B4(void *a0) { - D_80189150[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018915C[])(void); - -void func_80167A9C(void *a0) { - D_8018915C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80189268; - extern u8 D_8018927C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80189268); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018927C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801890BC[]; -extern u8 D_801890D0[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801890BC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801890D0; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80189174[])(void); - -void func_80168744(void *a0) { - D_80189174[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80189164 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80189164[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80189164; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018917C[])(void); - -void func_801689D8(void *a0) { - D_8018917C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80189184[])(void); - -void func_80168AA8(void *a0) { - D_80189184[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018918C[])(void); - -void func_80168D58(void *a0) { - D_8018918C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80189194[])(void); - -void func_8016901C(void *a0) { - D_80189194[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015AE2C", func_80169228); - - -extern void (*D_8018919C[])(void); - -void func_801693CC(void *a0) { - D_8018919C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801891A4[])(void); - -void func_80169830(void *a0) { - D_801891A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80189258[])(void); - -void func_80169B80(void *a0) { - D_80189258[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801891AC[]; - extern u8 D_8018921C[]; - extern u8 D_8018924C[]; - extern u8 D_801B9AE0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018924C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801891AC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B9AE0; - RotMatrixYXZ(rot, D_801B9AE0); - func_80048D9C(D_801B9AE0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018921C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80189260[])(void); - -void func_80169F00(void *a0) { - D_80189260[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80189210[]; -extern char D_801891D0[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80189210, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801891D0); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80189298[])(void); - -void func_8016A020(void *a0) { - D_80189298[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80189268; - extern u8 D_8018927C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80189268); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018927C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801892A4[])(void); - -void func_8016A700(void *a0) { - D_801892A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801892EC[])(void); - -void func_8016AB30(void *a0) { - D_801892EC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c b/src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c new file mode 100644 index 000000000..bf7c54f67 --- /dev/null +++ b/src/ov_SC03_102/ov_SC03_102_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801886B8; +extern u8 D_80188628; +extern u8 D_80188604; +extern u8 D_801885E0; +extern u8 D_80188694; +extern u8 D_80188670; +extern u8 D_8018864C; +extern u8 D_801885BC; +extern void func_80145934(void); +extern u8 D_80188748; +extern u8 D_80188724; +extern u8 D_80188700; +extern u8 D_801886DC; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80187B40[]; +extern unsigned char D_80187B70[]; +extern unsigned char D_80187BC0[]; +extern unsigned char D_80187BF0[]; +extern unsigned char D_80187C20[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80187C70[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80187D38[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80187DC0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80187DC8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B87B8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B87BC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80187DF8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80187EA0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80187EC4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80187EB4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80187ED8[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80187EE4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80187EF4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80187F0C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80187EFC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80187F20[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80187F3C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80187F2C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80187F50[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80187F64[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80187F78; +extern void (*D_80187FA0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80187F80; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80187FEC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80187FF0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80188454[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80188464[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B87F0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018848C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018846C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018847C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801884CC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801884D4[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801884A0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801884E0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801884B0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B87F8; +extern s32 D_801B8804; +extern s32 D_801B8808; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018851C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801884F0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B8800; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018876C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018858C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80188810[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80188964[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80188780; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018896C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80188790; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801887B0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80188974[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018899C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018881C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801889A8[])(void); + +void func_8015C714(void *a0) { + D_801889A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018881C[])(void*); + extern int D_801887C0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018881C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018881C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801887C0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018881C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018881C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018881C[])(void*); + extern int D_801887C0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018881C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801887C0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018881C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801889B8[])(void); + D_801889B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018881C[])(struct Ent_8015CD20 *); + extern u8 D_801887D0; + extern u8 D_801889C0; + extern u8 D_801889D0; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018881C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801887D0); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801889C0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801889D0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018881C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801889F0[])(void); + D_801889F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801889E0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801889E0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018881C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80188A4C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80188A4C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80187B30[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80187B30; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80188A54[])(void); + D_80188A54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80188A60[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80188A60[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80188A60[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80188A60[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018881C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80188A60[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801887E0[]; + extern u8 D_801887F0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801887E0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801887F0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80188A60[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80188A60[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80188A60[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80188A94[])(void); + D_80188A94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018881C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188A9C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80188AB4[])(void); + D_80188AB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018881C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188A9C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188A9C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80188AD4[])(void); + D_80188AD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018881C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018881C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80188AE4; +extern u16 D_80188AE6; +extern u16 D_80188AE8; +extern s32 D_80188AEC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80188AE4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80188AE6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80188AE8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188AEC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80188AF4; + +void func_8015E588(void) { + func_8013C9C4(&D_80188AF4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018881C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018881C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80188B08[])(void); + D_80188B08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018881C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018881C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80188B10[])(void); + D_80188B10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80188800; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188800); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018881C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80188B18[])(void); + D_80188B18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018881C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018881C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80188B20[])(void); + D_80188B20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018881C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80188B28; + extern s32 D_80188B38; + extern s32 D_80188B48; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188B28); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188B38); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018881C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188B48); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80188B58[])(void); + D_80188B58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018881C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018881C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018881C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018881C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80188B64[])(void); + D_80188B64[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018881C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018881C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018881C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018881C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80188B78[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80188B78[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018881C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018881C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018881C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018881C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80188BF4[])(void); + D_80188BF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018881C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018881C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80188C04[])(void); + D_80188C04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018881C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018881C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018881C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018881C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018881C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018881C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018881C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80188C0C[])(void); + D_80188C0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018881C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018881C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018881C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018881C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80188C18[])(void); + D_80188C18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018881C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018881C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018881C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018881C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80188C28[])(void); + +void func_80160EA4(void *a0) { + D_80188C28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018881C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018881C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80188C58[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80188C58[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80188CBC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80188CBC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B8810[]; + extern u8 D_80188C88[]; + extern u8 D_80188CA8[]; + extern u8 D_801B881C[]; + extern u8 D_801B8844[]; + extern u8 D_801B885C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B8810[0] = p; + func_80024054(&D_80188C88, &D_801B881C); + func_8001CE28(p, &D_801B881C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B8810[1] = p; + func_80024054(&D_80188CA8, &D_801B8844); + func_8001CE28(p, &D_801B8844); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B8810[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B885C, 0x84); + func_8001CE68(p, &D_801B885C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B885C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B8810[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B8810; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80188CBC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80188CBC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80188CBC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80188CBC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B8810[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B8810; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80188CE0[])(void); + +void func_80162330(void *a0) { + D_80188CE0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B8868[i] via `extern int D_801B8868[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80188CEC[]; + extern s32 D_80188D04; + extern u8 D_801B8874[]; + extern u8 D_801B889C[]; + extern u8 D_801B88B8[]; + extern int D_801B8868[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B8868[0] = (s32)item; + func_80024054(D_80188CEC, D_801B8874); + func_8001CE28(item, D_801B8874); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B8868[1] = (s32)item; + func_80024054(((u8 *)&D_80188D04), D_801B889C); + func_8001CE28(item, D_801B889C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B8868[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B88B8, 0x84); + func_8001CE68(item, D_801B88B8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B88B8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B8868[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B8868; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_801627E8); + + +extern void (*D_80188D28[])(void); + +void func_80162834(void *a0) { + D_80188D28[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80188D18; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80188D18, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B809C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B809C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B809C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B809C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80188D30[])(void); + +void func_80163A58(void *a0) { + D_80188D30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B80A4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B80A4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80188D84[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80188D84[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80188D4C; +extern s16 D_80188D80; +extern s16 D_80188D7E; +extern s16 D_80188D7C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80188D4C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80188D80 = 0x80; + D_80188D7E = 0x80; + D_80188D7C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80188D80 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188D80` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80188D80 - 8; + D_80188D80 = nv; + D_80188D7E = nv; + D_80188D7C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80188D90[])(void); + +void func_80164BA0(void *a0) { + D_80188D90[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B88C8; +extern u8 D_801B88C9; +extern u8 D_801B88CA; +extern u8 D_801B88CB; +extern u8 D_801B88CC; +extern u8 D_801B88CD; +extern u8 D_801B88CE; +extern u8 D_801B88CF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B88C8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B88C9 = 0xf0; + *(u8 *)base = 0xf0; + D_801B88CA = 0xc0; + D_801B88CE = 0; + D_801B88CD = 0; + D_801B88CC = 0; + D_801B88CF = 0; + D_801B88CB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B88C8; +extern u8 D_801B88C9; +extern u8 D_801B88CA; + +s32 func_80164E40(void) { + u8 *p = &D_801B88C8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B88C9 != 0) { + D_801B88C9 -= 0x10; + } + if (D_801B88CA != 0) { + D_801B88CA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80188DA0[])(void); + +void func_80164EA4(void *a0) { + D_80188DA0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B8914[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B8914[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B8908[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B8908[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B8908[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B8908; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B8908; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80188DB4[]; + extern u32 D_80188DD4, D_80188DD8, D_80188DDC, D_80188DE0; + extern u32 D_80188DD4, D_80188DD8, D_80188DDC, D_80188DE0; + extern u32 D_80188DD4, D_80188DD8, D_80188DDC, D_80188DE0; + extern u32 D_80188DD4, D_80188DD8, D_80188DDC, D_80188DE0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80188DB4[0x00], p); + ApplyMatrixSV(mat, &D_80188DB4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80188DB4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80188DB4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80188DDC; + *(u32 *)(prim + 0x24) = D_80188DD4; + *(u32 *)(prim + 0x28) = D_80188DE0; + *(u32 *)(prim + 0x2c) = D_80188DD8; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80188DE4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80188DE4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80188DE4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80188DE4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80188E60[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80188E60[a1 & 0x7F]; +} + + + +extern s32 D_80188E80[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80188E80[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80188EFC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80188EFC[a1 & 0x7F]; +} + + + +extern u8 D_80188F1C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80188F1C[a1 & 0x7F]; +} + + + +extern u8 D_80188F3C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80188F3C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80188F5C[])(void); + D_80188F5C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80188FD8[])(void); + +void func_80165AC8(void) { + D_80188FD8[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80189054[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80189054[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B80AC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B80AC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80189060[])(void); + +void func_80166018(void *a0) { + D_80189060[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80189068[])(void); + +void func_801663FC(void *a0) { + D_80189068[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80189130[])(void); + +void func_80166618(void *a0) { + D_80189130[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80189140[])(void); + +void func_80166654(void *a0) { + D_80189140[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B8988[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B8988[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B8988). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B8988[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B8988)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B8988[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B8988[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80189084[]; + extern u8 D_80189070[]; + extern u8 D_80189098[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80189084; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80189070; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80189098; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80167714); + + +extern void (*D_80189150[])(void); + +void func_801678B4(void *a0) { + D_80189150[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018915C[])(void); + +void func_80167A9C(void *a0) { + D_8018915C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80189268; + extern u8 D_8018927C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80189268); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018927C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801890BC[]; +extern u8 D_801890D0[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801890BC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801890D0; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80189174[])(void); + +void func_80168744(void *a0) { + D_80189174[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80189164 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80189164[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80189164; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018917C[])(void); + +void func_801689D8(void *a0) { + D_8018917C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80189184[])(void); + +void func_80168AA8(void *a0) { + D_80189184[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018918C[])(void); + +void func_80168D58(void *a0) { + D_8018918C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80189194[])(void); + +void func_8016901C(void *a0) { + D_80189194[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_102/nonmatchings/ov_SC03_102_jr_8015C32C", func_80169228); + + +extern void (*D_8018919C[])(void); + +void func_801693CC(void *a0) { + D_8018919C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801891A4[])(void); + +void func_80169830(void *a0) { + D_801891A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80189258[])(void); + +void func_80169B80(void *a0) { + D_80189258[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801891AC[]; + extern u8 D_8018921C[]; + extern u8 D_8018924C[]; + extern u8 D_801B9AE0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018924C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801891AC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B9AE0; + RotMatrixYXZ(rot, D_801B9AE0); + func_80048D9C(D_801B9AE0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018921C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80189260[])(void); + +void func_80169F00(void *a0) { + D_80189260[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80189210[]; +extern char D_801891D0[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80189210, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801891D0); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80189298[])(void); + +void func_8016A020(void *a0) { + D_80189298[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80189268; + extern u8 D_8018927C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80189268); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018927C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801892A4[])(void); + +void func_8016A700(void *a0) { + D_801892A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801892EC[])(void); + +void func_8016AB30(void *a0) { + D_801892EC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_103/ov_SC03_103_jr_8015AE2C.c b/src/ov_SC03_103/ov_SC03_103_jr_8015AE2C.c index 9e29e6ff0..382b0b3e7 100644 --- a/src/ov_SC03_103/ov_SC03_103_jr_8015AE2C.c +++ b/src/ov_SC03_103/ov_SC03_103_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80186958[])(void); - -void func_8015C714(void *a0) { - D_80186958[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801867CC[])(void*); - extern int D_80186770; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801867CC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801867CC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186770); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801867CC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801867CC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801867CC[])(void*); - extern int D_80186770; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801867CC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186770); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801867CC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80186968[])(void); - D_80186968[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801867CC[])(struct Ent_8015CD20 *); - extern u8 D_80186780; - extern u8 D_80186970; - extern u8 D_80186980; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801867CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186780); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186970); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186980); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801867CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801869A0[])(void); - D_801869A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80186990; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80186990 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801867CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801869FC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801869FC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80185AE0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80185AE0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80186A04[])(void); - D_80186A04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80186A10[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80186A10[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80186A10[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80186A10[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801867CC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80186A10[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80186790[]; - extern u8 D_801867A0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186790); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801867A0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80186A10[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186A10[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186A10[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80186A44[])(void); - D_80186A44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801867CC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186A4C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80186A64[])(void); - D_80186A64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801867CC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186A4C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80186A84[])(void); - D_80186A84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801867CC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801867CC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80186A94; -extern u16 D_80186A96; -extern u16 D_80186A98; -extern s32 D_80186A9C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80186A94 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80186A96 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80186A98 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186A9C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80186AA4; - -void func_8015E588(void) { - func_8013C9C4(&D_80186AA4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801867CC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801867CC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80186AB8[])(void); - D_80186AB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801867CC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801867CC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80186AC0[])(void); - D_80186AC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801867B0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801867B0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801867CC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80186AC8[])(void); - D_80186AC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801867CC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801867CC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80186AD0[])(void); - D_80186AD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801867CC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80186AD8; - extern s32 D_80186AE8; - extern s32 D_80186AF8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801867CC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186AD8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186AE8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801867CC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186AF8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80186B08[])(void); - D_80186B08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801867CC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801867CC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801867CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801867CC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80186B14[])(void); - D_80186B14[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801867CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801867CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801867CC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801867CC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80186B28[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80186B28[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801867CC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801867CC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801867CC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801867CC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80186BA4[])(void); - D_80186BA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801867CC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801867CC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80186BB4[])(void); - D_80186BB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801867CC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801867CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801867CC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801867CC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801867CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801867CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801867CC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80186BBC[])(void); - D_80186BBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801867CC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801867CC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801867CC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801867CC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80186BC8[])(void); - D_80186BC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801867CC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801867CC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801867CC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801867CC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80186BD8[])(void); - -void func_80160EA4(void *a0) { - D_80186BD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801867CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801867CC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80186C08[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80186C08[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80186C6C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80186C6C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C39C8[]; - extern u8 D_80186C38[]; - extern u8 D_80186C58[]; - extern u8 D_801C39D4[]; - extern u8 D_801C39FC[]; - extern u8 D_801C3A14[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C39C8[0] = p; - func_80024054(&D_80186C38, &D_801C39D4); - func_8001CE28(p, &D_801C39D4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C39C8[1] = p; - func_80024054(&D_80186C58, &D_801C39FC); - func_8001CE28(p, &D_801C39FC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C39C8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C3A14, 0x84); - func_8001CE68(p, &D_801C3A14); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C3A14, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C39C8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C39C8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80186C6C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80186C6C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80186C6C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80186C6C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C39C8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C39C8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80186C90[])(void); - -void func_80162330(void *a0) { - D_80186C90[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C3A20[i] via `extern int D_801C3A20[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80186C9C[]; - extern s32 D_80186CB4; - extern u8 D_801C3A2C[]; - extern u8 D_801C3A54[]; - extern u8 D_801C3A70[]; - extern int D_801C3A20[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C3A20[0] = (s32)item; - func_80024054(D_80186C9C, D_801C3A2C); - func_8001CE28(item, D_801C3A2C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C3A20[1] = (s32)item; - func_80024054(((u8 *)&D_80186CB4), D_801C3A54); - func_8001CE28(item, D_801C3A54); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C3A20[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C3A70, 0x84); - func_8001CE68(item, D_801C3A70); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C3A70, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C3A20[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C3A20; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_801627E8); - - -extern void (*D_80186CD8[])(void); - -void func_80162834(void *a0) { - D_80186CD8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80186CC8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80186CC8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C3250[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C3250, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C3250[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C3250, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80186CE0[])(void); - -void func_80163A58(void *a0) { - D_80186CE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C3258; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C3258; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80186D34[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80186D34[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80186CFC; -extern s16 D_80186D30; -extern s16 D_80186D2E; -extern s16 D_80186D2C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80186CFC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80186D30 = 0x80; - D_80186D2E = 0x80; - D_80186D2C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80186D30 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80186D30` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80186D30 - 8; - D_80186D30 = nv; - D_80186D2E = nv; - D_80186D2C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80186D40[])(void); - -void func_80164BA0(void *a0) { - D_80186D40[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C3A80; -extern u8 D_801C3A81; -extern u8 D_801C3A82; -extern u8 D_801C3A83; -extern u8 D_801C3A84; -extern u8 D_801C3A85; -extern u8 D_801C3A86; -extern u8 D_801C3A87; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C3A80; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C3A81 = 0xf0; - *(u8 *)base = 0xf0; - D_801C3A82 = 0xc0; - D_801C3A86 = 0; - D_801C3A85 = 0; - D_801C3A84 = 0; - D_801C3A87 = 0; - D_801C3A83 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C3A80; -extern u8 D_801C3A81; -extern u8 D_801C3A82; - -s32 func_80164E40(void) { - u8 *p = &D_801C3A80; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C3A81 != 0) { - D_801C3A81 -= 0x10; - } - if (D_801C3A82 != 0) { - D_801C3A82 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80186D50[])(void); - -void func_80164EA4(void *a0) { - D_80186D50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C3ACC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C3ACC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C3AC0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C3AC0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C3AC0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C3AC0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C3AC0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80186D64[]; - extern u32 D_80186D84, D_80186D88, D_80186D8C, D_80186D90; - extern u32 D_80186D84, D_80186D88, D_80186D8C, D_80186D90; - extern u32 D_80186D84, D_80186D88, D_80186D8C, D_80186D90; - extern u32 D_80186D84, D_80186D88, D_80186D8C, D_80186D90; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80186D64[0x00], p); - ApplyMatrixSV(mat, &D_80186D64[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80186D64[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80186D64[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80186D8C; - *(u32 *)(prim + 0x24) = D_80186D84; - *(u32 *)(prim + 0x28) = D_80186D90; - *(u32 *)(prim + 0x2c) = D_80186D88; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80186D94[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80186D94[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80186D94[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80186D94[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80186E10[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80186E10[a1 & 0x7F]; -} - - - -extern s32 D_80186E30[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80186E30[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80186EAC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80186EAC[a1 & 0x7F]; -} - - - -extern u8 D_80186ECC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80186ECC[a1 & 0x7F]; -} - - - -extern u8 D_80186EEC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80186EEC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80186F0C[])(void); - D_80186F0C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80186F88[])(void); - -void func_80165AC8(void) { - D_80186F88[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80187004[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80187004[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C3260; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C3260, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80187010[])(void); - -void func_80166018(void *a0) { - D_80187010[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80187018[])(void); - -void func_801663FC(void *a0) { - D_80187018[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801870E0[])(void); - -void func_80166618(void *a0) { - D_801870E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801870F0[])(void); - -void func_80166654(void *a0) { - D_801870F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C3B40[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C3B40[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C3B40). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C3B40[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C3B40)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C3B40[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C3B40[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80187034[]; - extern u8 D_80187020[]; - extern u8 D_80187048[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80187034; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80187020; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187048; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80167714); - - -extern void (*D_80187100[])(void); - -void func_801678B4(void *a0) { - D_80187100[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018710C[])(void); - -void func_80167A9C(void *a0) { - D_8018710C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80187218; - extern u8 D_8018722C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80187218); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018722C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018706C[]; -extern u8 D_80187080[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018706C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187080; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80187124[])(void); - -void func_80168744(void *a0) { - D_80187124[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80187114 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80187114[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80187114; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018712C[])(void); - -void func_801689D8(void *a0) { - D_8018712C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80187134[])(void); - -void func_80168AA8(void *a0) { - D_80187134[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018713C[])(void); - -void func_80168D58(void *a0) { - D_8018713C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80187144[])(void); - -void func_8016901C(void *a0) { - D_80187144[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015AE2C", func_80169228); - - -extern void (*D_8018714C[])(void); - -void func_801693CC(void *a0) { - D_8018714C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80187154[])(void); - -void func_80169830(void *a0) { - D_80187154[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187208[])(void); - -void func_80169B80(void *a0) { - D_80187208[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018715C[]; - extern u8 D_801871CC[]; - extern u8 D_801871FC[]; - extern u8 D_801C4C90[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801871FC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018715C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C4C90; - RotMatrixYXZ(rot, D_801C4C90); - func_80048D9C(D_801C4C90, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801871CC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80187210[])(void); - -void func_80169F00(void *a0) { - D_80187210[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801871C0[]; -extern char D_80187180[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801871C0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187180); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187248[])(void); - -void func_8016A020(void *a0) { - D_80187248[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80187218; - extern u8 D_8018722C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80187218); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018722C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80187254[])(void); - -void func_8016A700(void *a0) { - D_80187254[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018729C[])(void); - -void func_8016AB30(void *a0) { - D_8018729C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c b/src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c new file mode 100644 index 000000000..7d122ecde --- /dev/null +++ b/src/ov_SC03_103/ov_SC03_103_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80186668; +extern u8 D_801865D8; +extern u8 D_801865B4; +extern u8 D_80186590; +extern u8 D_80186644; +extern u8 D_80186620; +extern u8 D_801865FC; +extern u8 D_8018656C; +extern void func_80145934(void); +extern u8 D_801866F8; +extern u8 D_801866D4; +extern u8 D_801866B0; +extern u8 D_8018668C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80185AF0[]; +extern unsigned char D_80185B20[]; +extern unsigned char D_80185B70[]; +extern unsigned char D_80185BA0[]; +extern unsigned char D_80185BD0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80185C20[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80185CE8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80185D70[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80185D78; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C3970; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C3974; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80185DA8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80185E50[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80185E74[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80185E64; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80185E88[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80185E94[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80185EA4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80185EBC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80185EAC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80185ED0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80185EEC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80185EDC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80185F00[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80185F14[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80185F28; +extern void (*D_80185F50[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80185F30; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80185F9C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80185FA0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186404[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80186414[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C39A8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018643C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018641C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018642C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018647C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80186484[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80186450; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80186490[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80186460; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C39B0; +extern s32 D_801C39BC; +extern s32 D_801C39C0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801864CC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801864A0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C39B8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018671C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018653C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801867C0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80186914[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186730; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018691C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186740; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80186760; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80186924[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018694C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801867CC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80186958[])(void); + +void func_8015C714(void *a0) { + D_80186958[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801867CC[])(void*); + extern int D_80186770; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801867CC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801867CC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186770); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801867CC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801867CC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801867CC[])(void*); + extern int D_80186770; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801867CC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186770); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801867CC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80186968[])(void); + D_80186968[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801867CC[])(struct Ent_8015CD20 *); + extern u8 D_80186780; + extern u8 D_80186970; + extern u8 D_80186980; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801867CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186780); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186970); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186980); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801867CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801869A0[])(void); + D_801869A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80186990; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80186990 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801867CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801869FC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801869FC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80185AE0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80185AE0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80186A04[])(void); + D_80186A04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80186A10[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80186A10[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80186A10[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80186A10[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801867CC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80186A10[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80186790[]; + extern u8 D_801867A0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186790); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801867A0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80186A10[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186A10[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186A10[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80186A44[])(void); + D_80186A44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801867CC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186A4C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80186A64[])(void); + D_80186A64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801867CC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186A4C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186A4C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80186A84[])(void); + D_80186A84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801867CC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801867CC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80186A94; +extern u16 D_80186A96; +extern u16 D_80186A98; +extern s32 D_80186A9C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80186A94 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80186A96 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80186A98 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186A9C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80186AA4; + +void func_8015E588(void) { + func_8013C9C4(&D_80186AA4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801867CC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801867CC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80186AB8[])(void); + D_80186AB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801867CC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801867CC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80186AC0[])(void); + D_80186AC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801867B0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801867B0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801867CC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80186AC8[])(void); + D_80186AC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801867CC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801867CC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80186AD0[])(void); + D_80186AD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801867CC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80186AD8; + extern s32 D_80186AE8; + extern s32 D_80186AF8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186AD8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186AE8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801867CC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186AF8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80186B08[])(void); + D_80186B08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801867CC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801867CC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801867CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801867CC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80186B14[])(void); + D_80186B14[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801867CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801867CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801867CC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801867CC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80186B28[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80186B28[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801867CC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801867CC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801867CC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801867CC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80186BA4[])(void); + D_80186BA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801867CC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801867CC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80186BB4[])(void); + D_80186BB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801867CC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801867CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801867CC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801867CC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801867CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801867CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801867CC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80186BBC[])(void); + D_80186BBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801867CC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801867CC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801867CC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801867CC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80186BC8[])(void); + D_80186BC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801867CC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801867CC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801867CC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801867CC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80186BD8[])(void); + +void func_80160EA4(void *a0) { + D_80186BD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801867CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801867CC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80186C08[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80186C08[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80186C6C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80186C6C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C39C8[]; + extern u8 D_80186C38[]; + extern u8 D_80186C58[]; + extern u8 D_801C39D4[]; + extern u8 D_801C39FC[]; + extern u8 D_801C3A14[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C39C8[0] = p; + func_80024054(&D_80186C38, &D_801C39D4); + func_8001CE28(p, &D_801C39D4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C39C8[1] = p; + func_80024054(&D_80186C58, &D_801C39FC); + func_8001CE28(p, &D_801C39FC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C39C8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C3A14, 0x84); + func_8001CE68(p, &D_801C3A14); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C3A14, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C39C8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C39C8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80186C6C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80186C6C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80186C6C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80186C6C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C39C8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C39C8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80186C90[])(void); + +void func_80162330(void *a0) { + D_80186C90[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C3A20[i] via `extern int D_801C3A20[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80186C9C[]; + extern s32 D_80186CB4; + extern u8 D_801C3A2C[]; + extern u8 D_801C3A54[]; + extern u8 D_801C3A70[]; + extern int D_801C3A20[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C3A20[0] = (s32)item; + func_80024054(D_80186C9C, D_801C3A2C); + func_8001CE28(item, D_801C3A2C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C3A20[1] = (s32)item; + func_80024054(((u8 *)&D_80186CB4), D_801C3A54); + func_8001CE28(item, D_801C3A54); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C3A20[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C3A70, 0x84); + func_8001CE68(item, D_801C3A70); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C3A70, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C3A20[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C3A20; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_801627E8); + + +extern void (*D_80186CD8[])(void); + +void func_80162834(void *a0) { + D_80186CD8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80186CC8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80186CC8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C3250[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C3250, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C3250[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C3250, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80186CE0[])(void); + +void func_80163A58(void *a0) { + D_80186CE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C3258; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C3258; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80186D34[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80186D34[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80186CFC; +extern s16 D_80186D30; +extern s16 D_80186D2E; +extern s16 D_80186D2C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80186CFC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80186D30 = 0x80; + D_80186D2E = 0x80; + D_80186D2C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80186D30 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80186D30` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80186D30 - 8; + D_80186D30 = nv; + D_80186D2E = nv; + D_80186D2C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80186D40[])(void); + +void func_80164BA0(void *a0) { + D_80186D40[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C3A80; +extern u8 D_801C3A81; +extern u8 D_801C3A82; +extern u8 D_801C3A83; +extern u8 D_801C3A84; +extern u8 D_801C3A85; +extern u8 D_801C3A86; +extern u8 D_801C3A87; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C3A80; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C3A81 = 0xf0; + *(u8 *)base = 0xf0; + D_801C3A82 = 0xc0; + D_801C3A86 = 0; + D_801C3A85 = 0; + D_801C3A84 = 0; + D_801C3A87 = 0; + D_801C3A83 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C3A80; +extern u8 D_801C3A81; +extern u8 D_801C3A82; + +s32 func_80164E40(void) { + u8 *p = &D_801C3A80; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C3A81 != 0) { + D_801C3A81 -= 0x10; + } + if (D_801C3A82 != 0) { + D_801C3A82 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80186D50[])(void); + +void func_80164EA4(void *a0) { + D_80186D50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C3ACC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C3ACC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C3AC0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C3AC0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C3AC0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C3AC0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C3AC0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80186D64[]; + extern u32 D_80186D84, D_80186D88, D_80186D8C, D_80186D90; + extern u32 D_80186D84, D_80186D88, D_80186D8C, D_80186D90; + extern u32 D_80186D84, D_80186D88, D_80186D8C, D_80186D90; + extern u32 D_80186D84, D_80186D88, D_80186D8C, D_80186D90; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80186D64[0x00], p); + ApplyMatrixSV(mat, &D_80186D64[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80186D64[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80186D64[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80186D8C; + *(u32 *)(prim + 0x24) = D_80186D84; + *(u32 *)(prim + 0x28) = D_80186D90; + *(u32 *)(prim + 0x2c) = D_80186D88; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80186D94[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80186D94[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80186D94[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80186D94[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80186E10[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80186E10[a1 & 0x7F]; +} + + + +extern s32 D_80186E30[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80186E30[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80186EAC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80186EAC[a1 & 0x7F]; +} + + + +extern u8 D_80186ECC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80186ECC[a1 & 0x7F]; +} + + + +extern u8 D_80186EEC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80186EEC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80186F0C[])(void); + D_80186F0C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80186F88[])(void); + +void func_80165AC8(void) { + D_80186F88[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80187004[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80187004[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C3260; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C3260, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80187010[])(void); + +void func_80166018(void *a0) { + D_80187010[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80187018[])(void); + +void func_801663FC(void *a0) { + D_80187018[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801870E0[])(void); + +void func_80166618(void *a0) { + D_801870E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801870F0[])(void); + +void func_80166654(void *a0) { + D_801870F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C3B40[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C3B40[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C3B40). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C3B40[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C3B40)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C3B40[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C3B40[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80187034[]; + extern u8 D_80187020[]; + extern u8 D_80187048[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80187034; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80187020; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187048; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80167714); + + +extern void (*D_80187100[])(void); + +void func_801678B4(void *a0) { + D_80187100[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018710C[])(void); + +void func_80167A9C(void *a0) { + D_8018710C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80187218; + extern u8 D_8018722C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80187218); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018722C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018706C[]; +extern u8 D_80187080[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018706C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187080; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80187124[])(void); + +void func_80168744(void *a0) { + D_80187124[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80187114 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80187114[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80187114; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018712C[])(void); + +void func_801689D8(void *a0) { + D_8018712C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80187134[])(void); + +void func_80168AA8(void *a0) { + D_80187134[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018713C[])(void); + +void func_80168D58(void *a0) { + D_8018713C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80187144[])(void); + +void func_8016901C(void *a0) { + D_80187144[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_103/nonmatchings/ov_SC03_103_jr_8015C32C", func_80169228); + + +extern void (*D_8018714C[])(void); + +void func_801693CC(void *a0) { + D_8018714C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80187154[])(void); + +void func_80169830(void *a0) { + D_80187154[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187208[])(void); + +void func_80169B80(void *a0) { + D_80187208[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018715C[]; + extern u8 D_801871CC[]; + extern u8 D_801871FC[]; + extern u8 D_801C4C90[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801871FC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018715C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C4C90; + RotMatrixYXZ(rot, D_801C4C90); + func_80048D9C(D_801C4C90, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801871CC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80187210[])(void); + +void func_80169F00(void *a0) { + D_80187210[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801871C0[]; +extern char D_80187180[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801871C0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187180); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187248[])(void); + +void func_8016A020(void *a0) { + D_80187248[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80187218; + extern u8 D_8018722C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80187218); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018722C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80187254[])(void); + +void func_8016A700(void *a0) { + D_80187254[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018729C[])(void); + +void func_8016AB30(void *a0) { + D_8018729C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_104/ov_SC03_104_jr_8015AE2C.c b/src/ov_SC03_104/ov_SC03_104_jr_8015AE2C.c index ffa894446..831c137c2 100644 --- a/src/ov_SC03_104/ov_SC03_104_jr_8015AE2C.c +++ b/src/ov_SC03_104/ov_SC03_104_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018D4E8[])(void); - -void func_8015C714(void *a0) { - D_8018D4E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018D35C[])(void*); - extern int D_8018D300; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018D35C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018D35C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D300); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018D35C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018D35C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018D35C[])(void*); - extern int D_8018D300; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018D35C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D300); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018D35C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018D4F8[])(void); - D_8018D4F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018D35C[])(struct Ent_8015CD20 *); - extern u8 D_8018D310; - extern u8 D_8018D500; - extern u8 D_8018D510; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018D35C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D310); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D500); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D510); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018D35C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018D530[])(void); - D_8018D530[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018D520; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018D520 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018D35C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018D58C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018D58C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018C670[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018C670; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018D594[])(void); - D_8018D594[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018D5A0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018D5A0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018D5A0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018D5A0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018D35C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018D5A0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018D320[]; - extern u8 D_8018D330[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D320); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D330); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018D5A0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018D5A0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018D5A0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018D5D4[])(void); - D_8018D5D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D35C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018D5DC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018D5F4[])(void); - D_8018D5F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D35C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018D5DC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018D614[])(void); - D_8018D614[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018D35C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D35C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018D624; -extern u16 D_8018D626; -extern u16 D_8018D628; -extern s32 D_8018D62C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018D624 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018D626 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018D628 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018D62C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018D634; - -void func_8015E588(void) { - func_8013C9C4(&D_8018D634); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018D35C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D35C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018D648[])(void); - D_8018D648[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018D35C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018D35C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018D650[])(void); - D_8018D650[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018D340; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D340); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018D35C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018D658[])(void); - D_8018D658[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018D35C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018D35C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018D660[])(void); - D_8018D660[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018D35C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018D668; - extern s32 D_8018D678; - extern s32 D_8018D688; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018D35C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D668); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D678); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018D35C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D688); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018D698[])(void); - D_8018D698[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018D35C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018D35C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018D35C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D35C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018D6A4[])(void); - D_8018D6A4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018D35C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D35C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018D35C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D35C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018D6B8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018D6B8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018D35C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018D35C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018D35C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D35C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018D734[])(void); - D_8018D734[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018D35C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018D35C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018D744[])(void); - D_8018D744[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018D35C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018D35C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018D35C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018D35C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018D35C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018D35C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018D35C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018D74C[])(void); - D_8018D74C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018D35C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018D35C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018D35C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018D35C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018D758[])(void); - D_8018D758[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D35C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018D35C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018D35C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018D35C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018D768[])(void); - -void func_80160EA4(void *a0) { - D_8018D768[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018D35C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018D35C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018D798[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018D798[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018D7FC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018D7FC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801BEF60[]; - extern u8 D_8018D7C8[]; - extern u8 D_8018D7E8[]; - extern u8 D_801BEF6C[]; - extern u8 D_801BEF94[]; - extern u8 D_801BEFAC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801BEF60[0] = p; - func_80024054(&D_8018D7C8, &D_801BEF6C); - func_8001CE28(p, &D_801BEF6C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801BEF60[1] = p; - func_80024054(&D_8018D7E8, &D_801BEF94); - func_8001CE28(p, &D_801BEF94); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801BEF60[2] = p; - func_800242D0((s16)func_801620C4(), &D_801BEFAC, 0x84); - func_8001CE68(p, &D_801BEFAC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801BEFAC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BEF60[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801BEF60; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018D7FC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018D7FC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018D7FC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018D7FC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801BEF60[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801BEF60; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018D820[])(void); - -void func_80162330(void *a0) { - D_8018D820[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801BEFB8[i] via `extern int D_801BEFB8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018D82C[]; - extern s32 D_8018D844; - extern u8 D_801BEFC4[]; - extern u8 D_801BEFEC[]; - extern u8 D_801BF008[]; - extern int D_801BEFB8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801BEFB8[0] = (s32)item; - func_80024054(D_8018D82C, D_801BEFC4); - func_8001CE28(item, D_801BEFC4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801BEFB8[1] = (s32)item; - func_80024054(((u8 *)&D_8018D844), D_801BEFEC); - func_8001CE28(item, D_801BEFEC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801BEFB8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801BF008, 0x84); - func_8001CE68(item, D_801BF008); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801BF008, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BEFB8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801BEFB8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018D868[])(void); - -void func_80162834(void *a0) { - D_8018D868[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018D858; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018D858, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801BE7B0[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801BE7B0, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801BE7B0[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801BE7B0, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018D870[])(void); - -void func_80163A58(void *a0) { - D_8018D870[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801BE7B8; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801BE7B8; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018D8C4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018D8C4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018D88C; -extern s16 D_8018D8C0; -extern s16 D_8018D8BE; -extern s16 D_8018D8BC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018D88C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018D8C0 = 0x80; - D_8018D8BE = 0x80; - D_8018D8BC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018D8C0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D8C0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018D8C0 - 8; - D_8018D8C0 = nv; - D_8018D8BE = nv; - D_8018D8BC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018D8D0[])(void); - -void func_80164BA0(void *a0) { - D_8018D8D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801BF018; -extern u8 D_801BF019; -extern u8 D_801BF01A; -extern u8 D_801BF01B; -extern u8 D_801BF01C; -extern u8 D_801BF01D; -extern u8 D_801BF01E; -extern u8 D_801BF01F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801BF018; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801BF019 = 0xf0; - *(u8 *)base = 0xf0; - D_801BF01A = 0xc0; - D_801BF01E = 0; - D_801BF01D = 0; - D_801BF01C = 0; - D_801BF01F = 0; - D_801BF01B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801BF018; -extern u8 D_801BF019; -extern u8 D_801BF01A; - -s32 func_80164E40(void) { - u8 *p = &D_801BF018; - if (*p != 0) { - *p -= 0x10; - } - if (D_801BF019 != 0) { - D_801BF019 -= 0x10; - } - if (D_801BF01A != 0) { - D_801BF01A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018D8E0[])(void); - -void func_80164EA4(void *a0) { - D_8018D8E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801BF064[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801BF064[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801BF058[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801BF058[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801BF058[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801BF058; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801BF058; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018D8F4[]; - extern u32 D_8018D914, D_8018D918, D_8018D91C, D_8018D920; - extern u32 D_8018D914, D_8018D918, D_8018D91C, D_8018D920; - extern u32 D_8018D914, D_8018D918, D_8018D91C, D_8018D920; - extern u32 D_8018D914, D_8018D918, D_8018D91C, D_8018D920; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018D8F4[0x00], p); - ApplyMatrixSV(mat, &D_8018D8F4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018D8F4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018D8F4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018D91C; - *(u32 *)(prim + 0x24) = D_8018D914; - *(u32 *)(prim + 0x28) = D_8018D920; - *(u32 *)(prim + 0x2c) = D_8018D918; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018D924[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018D924[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018D924[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018D924[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018D9A0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018D9A0[a1 & 0x7F]; -} - - - -extern s32 D_8018D9C0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018D9C0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018DA3C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018DA3C[a1 & 0x7F]; -} - - - -extern u8 D_8018DA5C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018DA5C[a1 & 0x7F]; -} - - - -extern u8 D_8018DA7C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018DA7C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018DA9C[])(void); - D_8018DA9C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018DB18[])(void); - -void func_80165AC8(void) { - D_8018DB18[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018DB94[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018DB94[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801BE7C0; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801BE7C0, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018DBA0[])(void); - -void func_80166018(void *a0) { - D_8018DBA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018DBA8[])(void); - -void func_801663FC(void *a0) { - D_8018DBA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018DC70[])(void); - -void func_80166618(void *a0) { - D_8018DC70[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018DC80[])(void); - -void func_80166654(void *a0) { - D_8018DC80[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801BF0D8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801BF0D8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BF0D8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801BF0D8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801BF0D8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801BF0D8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801BF0D8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018DBC4[]; - extern u8 D_8018DBB0[]; - extern u8 D_8018DBD8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018DBC4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018DBB0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018DBD8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80167714); - - -extern void (*D_8018DC90[])(void); - -void func_801678B4(void *a0) { - D_8018DC90[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018DC9C[])(void); - -void func_80167A9C(void *a0) { - D_8018DC9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018DDA8; - extern u8 D_8018DDBC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018DDA8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018DDBC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018DBFC[]; -extern u8 D_8018DC10[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018DBFC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018DC10; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018DCB4[])(void); - -void func_80168744(void *a0) { - D_8018DCB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018DCA4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018DCA4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018DCA4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018DCBC[])(void); - -void func_801689D8(void *a0) { - D_8018DCBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018DCC4[])(void); - -void func_80168AA8(void *a0) { - D_8018DCC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018DCCC[])(void); - -void func_80168D58(void *a0) { - D_8018DCCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018DCD4[])(void); - -void func_8016901C(void *a0) { - D_8018DCD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015AE2C", func_80169228); - - -extern void (*D_8018DCDC[])(void); - -void func_801693CC(void *a0) { - D_8018DCDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018DCE4[])(void); - -void func_80169830(void *a0) { - D_8018DCE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018DD98[])(void); - -void func_80169B80(void *a0) { - D_8018DD98[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018DCEC[]; - extern u8 D_8018DD5C[]; - extern u8 D_8018DD8C[]; - extern u8 D_801C0350[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018DD8C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018DCEC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C0350; - RotMatrixYXZ(rot, D_801C0350); - func_80048D9C(D_801C0350, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018DD5C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018DDA0[])(void); - -void func_80169F00(void *a0) { - D_8018DDA0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018DD50[]; -extern char D_8018DD10[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018DD50, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018DD10); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018DDD8[])(void); - -void func_8016A020(void *a0) { - D_8018DDD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018DDA8; - extern u8 D_8018DDBC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018DDA8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018DDBC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018DDE4[])(void); - -void func_8016A700(void *a0) { - D_8018DDE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018DE2C[])(void); - -void func_8016AB30(void *a0) { - D_8018DE2C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c b/src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c new file mode 100644 index 000000000..3e2f6e17c --- /dev/null +++ b/src/ov_SC03_104/ov_SC03_104_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018D1F8; +extern u8 D_8018D168; +extern u8 D_8018D144; +extern u8 D_8018D120; +extern u8 D_8018D1D4; +extern u8 D_8018D1B0; +extern u8 D_8018D18C; +extern u8 D_8018D0FC; +extern void func_80145934(void); +extern u8 D_8018D288; +extern u8 D_8018D264; +extern u8 D_8018D240; +extern u8 D_8018D21C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018C680[]; +extern unsigned char D_8018C6B0[]; +extern unsigned char D_8018C700[]; +extern unsigned char D_8018C730[]; +extern unsigned char D_8018C760[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018C7B0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018C878[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018C900[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018C908; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801BEF08; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801BEF0C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018C938; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018C9E0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018CA04[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018C9F4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018CA18[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018CA24[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018CA34[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018CA4C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018CA3C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018CA60[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018CA7C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018CA6C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018CA90[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018CAA4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018CAB8; +extern void (*D_8018CAE0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018CAC0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018CB2C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018CB30[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018CF94[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018CFA4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801BEF40; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018CFCC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018CFAC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018CFBC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018D00C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018D014[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018CFE0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018D020[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018CFF0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801BEF48; +extern s32 D_801BEF54; +extern s32 D_801BEF58; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018D05C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018D030[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801BEF50; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018D2AC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018D0CC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018D350[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018D4A4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018D2C0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018D4AC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018D2D0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018D2F0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018D4B4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018D4DC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018D35C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018D4E8[])(void); + +void func_8015C714(void *a0) { + D_8018D4E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018D35C[])(void*); + extern int D_8018D300; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018D35C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018D35C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D300); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018D35C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018D35C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018D35C[])(void*); + extern int D_8018D300; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018D35C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D300); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018D35C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018D4F8[])(void); + D_8018D4F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018D35C[])(struct Ent_8015CD20 *); + extern u8 D_8018D310; + extern u8 D_8018D500; + extern u8 D_8018D510; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018D35C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D310); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D500); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D510); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018D35C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018D530[])(void); + D_8018D530[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018D520; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018D520 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018D35C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018D58C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018D58C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018C670[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018C670; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018D594[])(void); + D_8018D594[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018D5A0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018D5A0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018D5A0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018D5A0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018D35C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018D5A0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018D320[]; + extern u8 D_8018D330[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D320); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D330); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018D5A0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018D5A0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018D5A0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018D5D4[])(void); + D_8018D5D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D35C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018D5DC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018D5F4[])(void); + D_8018D5F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D35C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018D5DC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018D5DC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018D614[])(void); + D_8018D614[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018D35C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D35C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018D624; +extern u16 D_8018D626; +extern u16 D_8018D628; +extern s32 D_8018D62C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018D624 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018D626 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018D628 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018D62C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018D634; + +void func_8015E588(void) { + func_8013C9C4(&D_8018D634); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018D35C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D35C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018D648[])(void); + D_8018D648[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018D35C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018D35C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018D650[])(void); + D_8018D650[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018D340; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D340); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018D35C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018D658[])(void); + D_8018D658[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018D35C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018D35C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018D660[])(void); + D_8018D660[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018D35C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018D668; + extern s32 D_8018D678; + extern s32 D_8018D688; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D668); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D678); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018D35C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D688); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018D698[])(void); + D_8018D698[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018D35C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018D35C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018D35C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D35C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018D6A4[])(void); + D_8018D6A4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018D35C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D35C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018D35C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D35C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018D6B8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018D6B8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018D35C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018D35C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018D35C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D35C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018D734[])(void); + D_8018D734[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018D35C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018D35C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018D744[])(void); + D_8018D744[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018D35C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018D35C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018D35C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018D35C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018D35C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018D35C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018D35C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018D74C[])(void); + D_8018D74C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018D35C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018D35C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018D35C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018D35C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018D758[])(void); + D_8018D758[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D35C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018D35C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018D35C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018D35C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018D768[])(void); + +void func_80160EA4(void *a0) { + D_8018D768[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018D35C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018D35C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018D798[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018D798[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018D7FC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018D7FC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801BEF60[]; + extern u8 D_8018D7C8[]; + extern u8 D_8018D7E8[]; + extern u8 D_801BEF6C[]; + extern u8 D_801BEF94[]; + extern u8 D_801BEFAC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801BEF60[0] = p; + func_80024054(&D_8018D7C8, &D_801BEF6C); + func_8001CE28(p, &D_801BEF6C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801BEF60[1] = p; + func_80024054(&D_8018D7E8, &D_801BEF94); + func_8001CE28(p, &D_801BEF94); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801BEF60[2] = p; + func_800242D0((s16)func_801620C4(), &D_801BEFAC, 0x84); + func_8001CE68(p, &D_801BEFAC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801BEFAC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BEF60[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801BEF60; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018D7FC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018D7FC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018D7FC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018D7FC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801BEF60[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801BEF60; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018D820[])(void); + +void func_80162330(void *a0) { + D_8018D820[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801BEFB8[i] via `extern int D_801BEFB8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018D82C[]; + extern s32 D_8018D844; + extern u8 D_801BEFC4[]; + extern u8 D_801BEFEC[]; + extern u8 D_801BF008[]; + extern int D_801BEFB8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801BEFB8[0] = (s32)item; + func_80024054(D_8018D82C, D_801BEFC4); + func_8001CE28(item, D_801BEFC4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801BEFB8[1] = (s32)item; + func_80024054(((u8 *)&D_8018D844), D_801BEFEC); + func_8001CE28(item, D_801BEFEC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801BEFB8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801BF008, 0x84); + func_8001CE68(item, D_801BF008); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801BF008, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BEFB8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801BEFB8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_801627E8); + + +extern void (*D_8018D868[])(void); + +void func_80162834(void *a0) { + D_8018D868[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018D858; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018D858, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801BE7B0[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801BE7B0, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801BE7B0[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801BE7B0, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018D870[])(void); + +void func_80163A58(void *a0) { + D_8018D870[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801BE7B8; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801BE7B8; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018D8C4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018D8C4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018D88C; +extern s16 D_8018D8C0; +extern s16 D_8018D8BE; +extern s16 D_8018D8BC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018D88C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018D8C0 = 0x80; + D_8018D8BE = 0x80; + D_8018D8BC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018D8C0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D8C0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018D8C0 - 8; + D_8018D8C0 = nv; + D_8018D8BE = nv; + D_8018D8BC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018D8D0[])(void); + +void func_80164BA0(void *a0) { + D_8018D8D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801BF018; +extern u8 D_801BF019; +extern u8 D_801BF01A; +extern u8 D_801BF01B; +extern u8 D_801BF01C; +extern u8 D_801BF01D; +extern u8 D_801BF01E; +extern u8 D_801BF01F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801BF018; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801BF019 = 0xf0; + *(u8 *)base = 0xf0; + D_801BF01A = 0xc0; + D_801BF01E = 0; + D_801BF01D = 0; + D_801BF01C = 0; + D_801BF01F = 0; + D_801BF01B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801BF018; +extern u8 D_801BF019; +extern u8 D_801BF01A; + +s32 func_80164E40(void) { + u8 *p = &D_801BF018; + if (*p != 0) { + *p -= 0x10; + } + if (D_801BF019 != 0) { + D_801BF019 -= 0x10; + } + if (D_801BF01A != 0) { + D_801BF01A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018D8E0[])(void); + +void func_80164EA4(void *a0) { + D_8018D8E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801BF064[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801BF064[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801BF058[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801BF058[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801BF058[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801BF058; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801BF058; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018D8F4[]; + extern u32 D_8018D914, D_8018D918, D_8018D91C, D_8018D920; + extern u32 D_8018D914, D_8018D918, D_8018D91C, D_8018D920; + extern u32 D_8018D914, D_8018D918, D_8018D91C, D_8018D920; + extern u32 D_8018D914, D_8018D918, D_8018D91C, D_8018D920; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018D8F4[0x00], p); + ApplyMatrixSV(mat, &D_8018D8F4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018D8F4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018D8F4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018D91C; + *(u32 *)(prim + 0x24) = D_8018D914; + *(u32 *)(prim + 0x28) = D_8018D920; + *(u32 *)(prim + 0x2c) = D_8018D918; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018D924[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018D924[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018D924[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018D924[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018D9A0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018D9A0[a1 & 0x7F]; +} + + + +extern s32 D_8018D9C0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018D9C0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018DA3C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018DA3C[a1 & 0x7F]; +} + + + +extern u8 D_8018DA5C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018DA5C[a1 & 0x7F]; +} + + + +extern u8 D_8018DA7C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018DA7C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018DA9C[])(void); + D_8018DA9C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018DB18[])(void); + +void func_80165AC8(void) { + D_8018DB18[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018DB94[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018DB94[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801BE7C0; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801BE7C0, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018DBA0[])(void); + +void func_80166018(void *a0) { + D_8018DBA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018DBA8[])(void); + +void func_801663FC(void *a0) { + D_8018DBA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018DC70[])(void); + +void func_80166618(void *a0) { + D_8018DC70[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018DC80[])(void); + +void func_80166654(void *a0) { + D_8018DC80[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801BF0D8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801BF0D8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BF0D8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801BF0D8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801BF0D8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801BF0D8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801BF0D8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018DBC4[]; + extern u8 D_8018DBB0[]; + extern u8 D_8018DBD8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018DBC4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018DBB0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018DBD8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80167714); + + +extern void (*D_8018DC90[])(void); + +void func_801678B4(void *a0) { + D_8018DC90[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018DC9C[])(void); + +void func_80167A9C(void *a0) { + D_8018DC9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018DDA8; + extern u8 D_8018DDBC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018DDA8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018DDBC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018DBFC[]; +extern u8 D_8018DC10[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018DBFC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018DC10; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018DCB4[])(void); + +void func_80168744(void *a0) { + D_8018DCB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018DCA4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018DCA4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018DCA4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018DCBC[])(void); + +void func_801689D8(void *a0) { + D_8018DCBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018DCC4[])(void); + +void func_80168AA8(void *a0) { + D_8018DCC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018DCCC[])(void); + +void func_80168D58(void *a0) { + D_8018DCCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018DCD4[])(void); + +void func_8016901C(void *a0) { + D_8018DCD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_104/nonmatchings/ov_SC03_104_jr_8015C32C", func_80169228); + + +extern void (*D_8018DCDC[])(void); + +void func_801693CC(void *a0) { + D_8018DCDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018DCE4[])(void); + +void func_80169830(void *a0) { + D_8018DCE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018DD98[])(void); + +void func_80169B80(void *a0) { + D_8018DD98[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018DCEC[]; + extern u8 D_8018DD5C[]; + extern u8 D_8018DD8C[]; + extern u8 D_801C0350[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018DD8C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018DCEC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C0350; + RotMatrixYXZ(rot, D_801C0350); + func_80048D9C(D_801C0350, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018DD5C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018DDA0[])(void); + +void func_80169F00(void *a0) { + D_8018DDA0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018DD50[]; +extern char D_8018DD10[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018DD50, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018DD10); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018DDD8[])(void); + +void func_8016A020(void *a0) { + D_8018DDD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018DDA8; + extern u8 D_8018DDBC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018DDA8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018DDBC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018DDE4[])(void); + +void func_8016A700(void *a0) { + D_8018DDE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018DE2C[])(void); + +void func_8016AB30(void *a0) { + D_8018DE2C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_105/ov_SC03_105_jr_8015AE2C.c b/src/ov_SC03_105/ov_SC03_105_jr_8015AE2C.c index 65669261e..e01860899 100644 --- a/src/ov_SC03_105/ov_SC03_105_jr_8015AE2C.c +++ b/src/ov_SC03_105/ov_SC03_105_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018CB70[])(void); - -void func_8015C714(void *a0) { - D_8018CB70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018C9E4[])(void*); - extern int D_8018C988; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018C988); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018C9E4[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018C9E4[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018C9E4[])(void*); - extern int D_8018C988; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018C988); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018CB80[])(void); - D_8018CB80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018C9E4[])(struct Ent_8015CD20 *); - extern u8 D_8018C998; - extern u8 D_8018CB88; - extern u8 D_8018CB98; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018C9E4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C998); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CB88); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CB98); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018C9E4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018CBB8[])(void); - D_8018CBB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018CBA8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018CBA8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018C9E4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018CC14; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018CC14, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018BCF8[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018BCF8; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018CC1C[])(void); - D_8018CC1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018CC28[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018CC28[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018CC28[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018CC28[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018C9E4[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018CC28[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018C9A8[]; - extern u8 D_8018C9B8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018C9A8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018C9B8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018CC28[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018CC28[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018CC28[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018CC5C[])(void); - D_8018CC5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018C9E4[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018CC64[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018CC7C[])(void); - D_8018CC7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018C9E4[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018CC64[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018CC9C[])(void); - D_8018CC9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018C9E4[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018C9E4)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018CCAC; -extern u16 D_8018CCAE; -extern u16 D_8018CCB0; -extern s32 D_8018CCB4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018CCAC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018CCAE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018CCB0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018CCB4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018CCBC; - -void func_8015E588(void) { - func_8013C9C4(&D_8018CCBC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018C9E4[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018C9E4)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018CCD0[])(void); - D_8018CCD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018C9E4[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018C9E4[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018CCD8[])(void); - D_8018CCD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018C9C8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018C9C8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018C9E4[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018CCE0[])(void); - D_8018CCE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018C9E4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018C9E4[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018CCE8[])(void); - D_8018CCE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018C9E4[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018CCF0; - extern s32 D_8018CD00; - extern s32 D_8018CD10; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018C9E4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CCF0); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CD00); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018C9E4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CD10); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018CD20[])(void); - D_8018CD20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018C9E4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018C9E4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018C9E4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018C9E4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018CD2C[])(void); - D_8018CD2C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018C9E4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018C9E4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018C9E4[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018C9E4[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018CD40[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018CD40[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018C9E4[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018C9E4)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018C9E4[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018C9E4[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018CDBC[])(void); - D_8018CDBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018C9E4[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018C9E4)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018CDCC[])(void); - D_8018CDCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018C9E4[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018C9E4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018C9E4[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018C9E4[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018C9E4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018C9E4[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018C9E4[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018CDD4[])(void); - D_8018CDD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018C9E4[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018C9E4)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018C9E4[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018CDE0[])(void); - D_8018CDE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018C9E4 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018C9E4[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018C9E4[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018C9E4[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018CDF0[])(void); - -void func_80160EA4(void *a0) { - D_8018CDF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018C9E4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018C9E4[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018CE20[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018CE20[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018CE84; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018CE84); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B84F0[]; - extern u8 D_8018CE50[]; - extern u8 D_8018CE70[]; - extern u8 D_801B84FC[]; - extern u8 D_801B8524[]; - extern u8 D_801B853C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B84F0[0] = p; - func_80024054(&D_8018CE50, &D_801B84FC); - func_8001CE28(p, &D_801B84FC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B84F0[1] = p; - func_80024054(&D_8018CE70, &D_801B8524); - func_8001CE28(p, &D_801B8524); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B84F0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B853C, 0x84); - func_8001CE68(p, &D_801B853C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B853C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B84F0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B84F0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018CE84; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018CE84; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018CE84; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018CE84; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B84F0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B84F0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018CEA8[])(void); - -void func_80162330(void *a0) { - D_8018CEA8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B8548[i] via `extern int D_801B8548[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018CEB4[]; - extern s32 D_8018CECC; - extern u8 D_801B8554[]; - extern u8 D_801B857C[]; - extern u8 D_801B8598[]; - extern int D_801B8548[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B8548[0] = (s32)item; - func_80024054(D_8018CEB4, D_801B8554); - func_8001CE28(item, D_801B8554); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B8548[1] = (s32)item; - func_80024054(((u8 *)&D_8018CECC), D_801B857C); - func_8001CE28(item, D_801B857C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B8548[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B8598, 0x84); - func_8001CE68(item, D_801B8598); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B8598, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B8548[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B8548; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018CEF0[])(void); - -void func_80162834(void *a0) { - D_8018CEF0[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018CEE0; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018CEE0, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B7AA8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B7AA8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B7AA8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B7AA8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018CEF8[])(void); - -void func_80163A58(void *a0) { - D_8018CEF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B7AB0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B7AB0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018CF4C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018CF4C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018CF14; -extern s16 D_8018CF48; -extern s16 D_8018CF46; -extern s16 D_8018CF44; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018CF14; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018CF48 = 0x80; - D_8018CF46 = 0x80; - D_8018CF44 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018CF48 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018CF48` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018CF48 - 8; - D_8018CF48 = nv; - D_8018CF46 = nv; - D_8018CF44 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018CF58[])(void); - -void func_80164BA0(void *a0) { - D_8018CF58[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B85A8; -extern u8 D_801B85A9; -extern u8 D_801B85AA; -extern u8 D_801B85AB; -extern u8 D_801B85AC; -extern u8 D_801B85AD; -extern u8 D_801B85AE; -extern u8 D_801B85AF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B85A8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B85A9 = 0xf0; - *(u8 *)base = 0xf0; - D_801B85AA = 0xc0; - D_801B85AE = 0; - D_801B85AD = 0; - D_801B85AC = 0; - D_801B85AF = 0; - D_801B85AB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B85A8; -extern u8 D_801B85A9; -extern u8 D_801B85AA; - -s32 func_80164E40(void) { - u8 *p = &D_801B85A8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B85A9 != 0) { - D_801B85A9 -= 0x10; - } - if (D_801B85AA != 0) { - D_801B85AA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018CF68[])(void); - -void func_80164EA4(void *a0) { - D_8018CF68[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B85F4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B85F4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B85E8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B85E8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B85E8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B85E8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B85E8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018CF7C[]; - extern u32 D_8018CF9C, D_8018CFA0, D_8018CFA4, D_8018CFA8; - extern u32 D_8018CF9C, D_8018CFA0, D_8018CFA4, D_8018CFA8; - extern u32 D_8018CF9C, D_8018CFA0, D_8018CFA4, D_8018CFA8; - extern u32 D_8018CF9C, D_8018CFA0, D_8018CFA4, D_8018CFA8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018CF7C[0x00], p); - ApplyMatrixSV(mat, &D_8018CF7C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018CF7C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018CF7C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018CFA4; - *(u32 *)(prim + 0x24) = D_8018CF9C; - *(u32 *)(prim + 0x28) = D_8018CFA8; - *(u32 *)(prim + 0x2c) = D_8018CFA0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018CFAC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018CFAC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018CFAC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018CFAC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018D028[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018D028[a1 & 0x7F]; -} - - - -extern s32 D_8018D048[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018D048[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018D0C4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018D0C4[a1 & 0x7F]; -} - - - -extern u8 D_8018D0E4[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018D0E4[a1 & 0x7F]; -} - - - -extern u8 D_8018D104[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018D104[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018D124[])(void); - D_8018D124[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018D1A0[])(void); - -void func_80165AC8(void) { - D_8018D1A0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018D21C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018D21C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B7AB8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B7AB8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018D228[])(void); - -void func_80166018(void *a0) { - D_8018D228[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018D230[])(void); - -void func_801663FC(void *a0) { - D_8018D230[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018D2F8[])(void); - -void func_80166618(void *a0) { - D_8018D2F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018D308[])(void); - -void func_80166654(void *a0) { - D_8018D308[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B8668[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B8668[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B8668). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B8668[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B8668)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B8668[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B8668[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018D24C[]; - extern u8 D_8018D238[]; - extern u8 D_8018D260[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018D24C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018D238; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018D260; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80167714); - - -extern void (*D_8018D318[])(void); - -void func_801678B4(void *a0) { - D_8018D318[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018D324[])(void); - -void func_80167A9C(void *a0) { - D_8018D324[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018D430; - extern u8 D_8018D444[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018D430); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018D444; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018D284[]; -extern u8 D_8018D298[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018D284; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018D298; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018D33C[])(void); - -void func_80168744(void *a0) { - D_8018D33C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018D32C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018D32C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018D32C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018D344[])(void); - -void func_801689D8(void *a0) { - D_8018D344[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018D34C[])(void); - -void func_80168AA8(void *a0) { - D_8018D34C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018D354[])(void); - -void func_80168D58(void *a0) { - D_8018D354[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018D35C[])(void); - -void func_8016901C(void *a0) { - D_8018D35C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015AE2C", func_80169228); - - -extern void (*D_8018D364[])(void); - -void func_801693CC(void *a0) { - D_8018D364[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018D36C[])(void); - -void func_80169830(void *a0) { - D_8018D36C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018D420[])(void); - -void func_80169B80(void *a0) { - D_8018D420[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018D374[]; - extern u8 D_8018D3E4[]; - extern u8 D_8018D414[]; - extern u8 D_801BCBD8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018D414, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018D374[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801BCBD8; - RotMatrixYXZ(rot, D_801BCBD8); - func_80048D9C(D_801BCBD8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018D3E4); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018D428[])(void); - -void func_80169F00(void *a0) { - D_8018D428[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018D3D8[]; -extern char D_8018D398[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018D3D8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018D398); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018D460[])(void); - -void func_8016A020(void *a0) { - D_8018D460[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018D430; - extern u8 D_8018D444[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -((s32(*)(s32, s32))ratan2)(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018D430); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018D444; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018D46C[])(void); - -void func_8016A700(void *a0) { - D_8018D46C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018D4B4[])(void); - -void func_8016AB30(void *a0) { - D_8018D4B4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c b/src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c new file mode 100644 index 000000000..029fab4d6 --- /dev/null +++ b/src/ov_SC03_105/ov_SC03_105_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018C880; +extern u8 D_8018C7F0; +extern u8 D_8018C7CC; +extern u8 D_8018C7A8; +extern u8 D_8018C85C; +extern u8 D_8018C838; +extern u8 D_8018C814; +extern u8 D_8018C784; +extern void func_80145934(void); +extern u8 D_8018C910; +extern u8 D_8018C8EC; +extern u8 D_8018C8C8; +extern u8 D_8018C8A4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018BD08[]; +extern unsigned char D_8018BD38[]; +extern unsigned char D_8018BD88[]; +extern unsigned char D_8018BDB8[]; +extern unsigned char D_8018BDE8[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018BE38[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018BF00[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018BF88[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018BF90; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B8498; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B849C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018BFC0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018C068[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018C08C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018C07C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018C0A0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018C0AC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018C0BC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018C0D4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018C0C4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018C0E8[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018C104[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018C0F4; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018C118[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018C12C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018C140; +extern void (*D_8018C168[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018C148; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018C1B4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018C1B8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018C61C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018C62C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B84D0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018C654[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018C634; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018C644; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018C694[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018C69C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018C668; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018C6A8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018C678; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B84D8; +extern s32 D_801B84E4; +extern s32 D_801B84E8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018C6E4[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018C6B8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B84E0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018C934[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018C754[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018C9D8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018CB2C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018C948; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018CB34[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018C958; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018C978; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018CB3C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018CB64[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018C9E4[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018CB70[])(void); + +void func_8015C714(void *a0) { + D_8018CB70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018C9E4[])(void*); + extern int D_8018C988; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018C988); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018C9E4[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018C9E4[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018C9E4[])(void*); + extern int D_8018C988; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018C988); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018CB80[])(void); + D_8018CB80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018C9E4[])(struct Ent_8015CD20 *); + extern u8 D_8018C998; + extern u8 D_8018CB88; + extern u8 D_8018CB98; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018C9E4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C998); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CB88); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018CB98); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018C9E4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018CBB8[])(void); + D_8018CBB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018CBA8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018CBA8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018C9E4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018CC14; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018CC14, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018BCF8[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018BCF8; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018CC1C[])(void); + D_8018CC1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018CC28[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018CC28[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018CC28[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018CC28[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018C9E4[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018CC28[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018C9A8[]; + extern u8 D_8018C9B8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018C9A8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018C9B8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018CC28[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018CC28[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018CC28[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018CC5C[])(void); + D_8018CC5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018C9E4[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018CC64[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018CC7C[])(void); + D_8018CC7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018C9E4[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018CC64[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018CC64[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018CC9C[])(void); + D_8018CC9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018C9E4[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018C9E4)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018CCAC; +extern u16 D_8018CCAE; +extern u16 D_8018CCB0; +extern s32 D_8018CCB4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018CCAC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018CCAE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018CCB0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018CCB4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018CCBC; + +void func_8015E588(void) { + func_8013C9C4(&D_8018CCBC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018C9E4[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018C9E4)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018CCD0[])(void); + D_8018CCD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018C9E4[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018C9E4[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018CCD8[])(void); + D_8018CCD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018C9C8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018C9C8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018C9E4[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018CCE0[])(void); + D_8018CCE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018C9E4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018C9E4[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018CCE8[])(void); + D_8018CCE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018C9E4[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018CCF0; + extern s32 D_8018CD00; + extern s32 D_8018CD10; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CCF0); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CD00); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018C9E4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018CD10); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018CD20[])(void); + D_8018CD20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018C9E4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018C9E4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018C9E4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018C9E4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018CD2C[])(void); + D_8018CD2C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018C9E4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018C9E4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018C9E4[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018C9E4[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018CD40[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018CD40[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018C9E4[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018C9E4)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018C9E4[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018C9E4[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018CDBC[])(void); + D_8018CDBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018C9E4[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018C9E4)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018CDCC[])(void); + D_8018CDCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018C9E4[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018C9E4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018C9E4[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018C9E4[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018C9E4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018C9E4[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018C9E4[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018CDD4[])(void); + D_8018CDD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018C9E4[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018C9E4)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018C9E4[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018C9E4)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018CDE0[])(void); + D_8018CDE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018C9E4 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018C9E4[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018C9E4[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018C9E4[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018CDF0[])(void); + +void func_80160EA4(void *a0) { + D_8018CDF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018C9E4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018C9E4[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018CE20[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018CE20[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018CE84; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018CE84); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B84F0[]; + extern u8 D_8018CE50[]; + extern u8 D_8018CE70[]; + extern u8 D_801B84FC[]; + extern u8 D_801B8524[]; + extern u8 D_801B853C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B84F0[0] = p; + func_80024054(&D_8018CE50, &D_801B84FC); + func_8001CE28(p, &D_801B84FC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B84F0[1] = p; + func_80024054(&D_8018CE70, &D_801B8524); + func_8001CE28(p, &D_801B8524); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B84F0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B853C, 0x84); + func_8001CE68(p, &D_801B853C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B853C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B84F0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B84F0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018CE84; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018CE84; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018CE84; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018CE84; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B84F0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B84F0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018CEA8[])(void); + +void func_80162330(void *a0) { + D_8018CEA8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B8548[i] via `extern int D_801B8548[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018CEB4[]; + extern s32 D_8018CECC; + extern u8 D_801B8554[]; + extern u8 D_801B857C[]; + extern u8 D_801B8598[]; + extern int D_801B8548[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B8548[0] = (s32)item; + func_80024054(D_8018CEB4, D_801B8554); + func_8001CE28(item, D_801B8554); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B8548[1] = (s32)item; + func_80024054(((u8 *)&D_8018CECC), D_801B857C); + func_8001CE28(item, D_801B857C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B8548[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B8598, 0x84); + func_8001CE68(item, D_801B8598); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B8598, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B8548[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B8548; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_801627E8); + + +extern void (*D_8018CEF0[])(void); + +void func_80162834(void *a0) { + D_8018CEF0[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018CEE0; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018CEE0, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B7AA8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B7AA8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B7AA8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B7AA8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018CEF8[])(void); + +void func_80163A58(void *a0) { + D_8018CEF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B7AB0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B7AB0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018CF4C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018CF4C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018CF14; +extern s16 D_8018CF48; +extern s16 D_8018CF46; +extern s16 D_8018CF44; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018CF14; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018CF48 = 0x80; + D_8018CF46 = 0x80; + D_8018CF44 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018CF48 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018CF48` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018CF48 - 8; + D_8018CF48 = nv; + D_8018CF46 = nv; + D_8018CF44 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018CF58[])(void); + +void func_80164BA0(void *a0) { + D_8018CF58[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B85A8; +extern u8 D_801B85A9; +extern u8 D_801B85AA; +extern u8 D_801B85AB; +extern u8 D_801B85AC; +extern u8 D_801B85AD; +extern u8 D_801B85AE; +extern u8 D_801B85AF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B85A8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B85A9 = 0xf0; + *(u8 *)base = 0xf0; + D_801B85AA = 0xc0; + D_801B85AE = 0; + D_801B85AD = 0; + D_801B85AC = 0; + D_801B85AF = 0; + D_801B85AB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B85A8; +extern u8 D_801B85A9; +extern u8 D_801B85AA; + +s32 func_80164E40(void) { + u8 *p = &D_801B85A8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B85A9 != 0) { + D_801B85A9 -= 0x10; + } + if (D_801B85AA != 0) { + D_801B85AA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018CF68[])(void); + +void func_80164EA4(void *a0) { + D_8018CF68[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B85F4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B85F4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B85E8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B85E8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B85E8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B85E8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B85E8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018CF7C[]; + extern u32 D_8018CF9C, D_8018CFA0, D_8018CFA4, D_8018CFA8; + extern u32 D_8018CF9C, D_8018CFA0, D_8018CFA4, D_8018CFA8; + extern u32 D_8018CF9C, D_8018CFA0, D_8018CFA4, D_8018CFA8; + extern u32 D_8018CF9C, D_8018CFA0, D_8018CFA4, D_8018CFA8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018CF7C[0x00], p); + ApplyMatrixSV(mat, &D_8018CF7C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018CF7C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018CF7C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018CFA4; + *(u32 *)(prim + 0x24) = D_8018CF9C; + *(u32 *)(prim + 0x28) = D_8018CFA8; + *(u32 *)(prim + 0x2c) = D_8018CFA0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018CFAC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018CFAC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018CFAC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018CFAC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018D028[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018D028[a1 & 0x7F]; +} + + + +extern s32 D_8018D048[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018D048[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018D0C4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018D0C4[a1 & 0x7F]; +} + + + +extern u8 D_8018D0E4[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018D0E4[a1 & 0x7F]; +} + + + +extern u8 D_8018D104[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018D104[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018D124[])(void); + D_8018D124[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018D1A0[])(void); + +void func_80165AC8(void) { + D_8018D1A0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018D21C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018D21C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B7AB8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B7AB8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018D228[])(void); + +void func_80166018(void *a0) { + D_8018D228[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018D230[])(void); + +void func_801663FC(void *a0) { + D_8018D230[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018D2F8[])(void); + +void func_80166618(void *a0) { + D_8018D2F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018D308[])(void); + +void func_80166654(void *a0) { + D_8018D308[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B8668[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B8668[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B8668). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B8668[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B8668)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B8668[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B8668[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018D24C[]; + extern u8 D_8018D238[]; + extern u8 D_8018D260[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018D24C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018D238; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018D260; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80167714); + + +extern void (*D_8018D318[])(void); + +void func_801678B4(void *a0) { + D_8018D318[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018D324[])(void); + +void func_80167A9C(void *a0) { + D_8018D324[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018D430; + extern u8 D_8018D444[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018D430); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018D444; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018D284[]; +extern u8 D_8018D298[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018D284; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018D298; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018D33C[])(void); + +void func_80168744(void *a0) { + D_8018D33C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018D32C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018D32C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018D32C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018D344[])(void); + +void func_801689D8(void *a0) { + D_8018D344[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018D34C[])(void); + +void func_80168AA8(void *a0) { + D_8018D34C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018D354[])(void); + +void func_80168D58(void *a0) { + D_8018D354[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018D35C[])(void); + +void func_8016901C(void *a0) { + D_8018D35C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_105/nonmatchings/ov_SC03_105_jr_8015C32C", func_80169228); + + +extern void (*D_8018D364[])(void); + +void func_801693CC(void *a0) { + D_8018D364[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018D36C[])(void); + +void func_80169830(void *a0) { + D_8018D36C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018D420[])(void); + +void func_80169B80(void *a0) { + D_8018D420[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018D374[]; + extern u8 D_8018D3E4[]; + extern u8 D_8018D414[]; + extern u8 D_801BCBD8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018D414, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018D374[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801BCBD8; + RotMatrixYXZ(rot, D_801BCBD8); + func_80048D9C(D_801BCBD8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018D3E4); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018D428[])(void); + +void func_80169F00(void *a0) { + D_8018D428[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018D3D8[]; +extern char D_8018D398[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018D3D8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018D398); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018D460[])(void); + +void func_8016A020(void *a0) { + D_8018D460[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018D430; + extern u8 D_8018D444[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -((s32(*)(s32, s32))ratan2)(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018D430); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018D444; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018D46C[])(void); + +void func_8016A700(void *a0) { + D_8018D46C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018D4B4[])(void); + +void func_8016AB30(void *a0) { + D_8018D4B4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_108/ov_SC03_108_jr_8015AE2C.c b/src/ov_SC03_108/ov_SC03_108_jr_8015AE2C.c index 5353ef766..066cfbe91 100644 --- a/src/ov_SC03_108/ov_SC03_108_jr_8015AE2C.c +++ b/src/ov_SC03_108/ov_SC03_108_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801834C8[])(void); - -void func_8015C714(void *a0) { - D_801834C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018333C[])(void*); - extern int D_801832E0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018333C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018333C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801832E0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018333C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018333C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018333C[])(void*); - extern int D_801832E0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018333C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801832E0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018333C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801834D8[])(void); - D_801834D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018333C[])(struct Ent_8015CD20 *); - extern u8 D_801832F0; - extern u8 D_801834E0; - extern u8 D_801834F0; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018333C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801832F0); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801834E0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801834F0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018333C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80183510[])(void); - D_80183510[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80183500; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80183500 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018333C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018356C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018356C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80182650[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80182650; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80183574[])(void); - D_80183574[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80183580[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80183580[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80183580[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80183580[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018333C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80183580[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80183300[]; - extern u8 D_80183310[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183300); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183310); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80183580[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183580[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183580[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801835B4[])(void); - D_801835B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018333C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801835BC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801835D4[])(void); - D_801835D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018333C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801835BC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801835F4[])(void); - D_801835F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018333C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018333C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80183604; -extern u16 D_80183606; -extern u16 D_80183608; -extern s32 D_8018360C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80183604 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80183606 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80183608 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018360C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80183614; - -void func_8015E588(void) { - func_8013C9C4(&D_80183614); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018333C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018333C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80183628[])(void); - D_80183628[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018333C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018333C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80183630[])(void); - D_80183630[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80183320; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80183320); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018333C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80183638[])(void); - D_80183638[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018333C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018333C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80183640[])(void); - D_80183640[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018333C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80183648; - extern s32 D_80183658; - extern s32 D_80183668; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018333C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183648); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183658); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018333C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183668); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80183678[])(void); - D_80183678[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018333C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018333C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018333C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018333C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80183684[])(void); - D_80183684[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018333C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018333C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018333C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018333C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80183698[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80183698[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018333C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018333C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018333C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018333C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80183714[])(void); - D_80183714[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018333C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018333C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80183724[])(void); - D_80183724[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018333C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018333C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018333C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018333C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018333C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018333C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018333C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018372C[])(void); - D_8018372C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018333C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018333C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018333C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018333C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80183738[])(void); - D_80183738[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018333C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018333C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018333C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018333C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80183748[])(void); - -void func_80160EA4(void *a0) { - D_80183748[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018333C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018333C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80183778[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80183778[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801837DC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801837DC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A07E0[]; - extern u8 D_801837A8[]; - extern u8 D_801837C8[]; - extern u8 D_801A07EC[]; - extern u8 D_801A0814[]; - extern u8 D_801A082C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A07E0[0] = p; - func_80024054(&D_801837A8, &D_801A07EC); - func_8001CE28(p, &D_801A07EC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A07E0[1] = p; - func_80024054(&D_801837C8, &D_801A0814); - func_8001CE28(p, &D_801A0814); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A07E0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A082C, 0x84); - func_8001CE68(p, &D_801A082C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A082C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A07E0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A07E0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801837DC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801837DC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801837DC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801837DC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A07E0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A07E0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80183800[])(void); - -void func_80162330(void *a0) { - D_80183800[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A0838[i] via `extern int D_801A0838[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018380C[]; - extern s32 D_80183824; - extern u8 D_801A0844[]; - extern u8 D_801A086C[]; - extern u8 D_801A0888[]; - extern int D_801A0838[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A0838[0] = (s32)item; - func_80024054(D_8018380C, D_801A0844); - func_8001CE28(item, D_801A0844); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A0838[1] = (s32)item; - func_80024054(((u8 *)&D_80183824), D_801A086C); - func_8001CE28(item, D_801A086C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A0838[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A0888, 0x84); - func_8001CE68(item, D_801A0888); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A0888, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A0838[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A0838; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_801627E8); - - -extern void (*D_80183848[])(void); - -void func_80162834(void *a0) { - D_80183848[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80183838; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80183838, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019FFB0[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019FFB0, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019FFB0[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019FFB0, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80183850[])(void); - -void func_80163A58(void *a0) { - D_80183850[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019FFB8; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019FFB8; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801838A4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801838A4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018386C; -extern s16 D_801838A0; -extern s16 D_8018389E; -extern s16 D_8018389C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018386C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801838A0 = 0x80; - D_8018389E = 0x80; - D_8018389C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801838A0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801838A0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801838A0 - 8; - D_801838A0 = nv; - D_8018389E = nv; - D_8018389C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801838B0[])(void); - -void func_80164BA0(void *a0) { - D_801838B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A0898; -extern u8 D_801A0899; -extern u8 D_801A089A; -extern u8 D_801A089B; -extern u8 D_801A089C; -extern u8 D_801A089D; -extern u8 D_801A089E; -extern u8 D_801A089F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A0898; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A0899 = 0xf0; - *(u8 *)base = 0xf0; - D_801A089A = 0xc0; - D_801A089E = 0; - D_801A089D = 0; - D_801A089C = 0; - D_801A089F = 0; - D_801A089B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A0898; -extern u8 D_801A0899; -extern u8 D_801A089A; - -s32 func_80164E40(void) { - u8 *p = &D_801A0898; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A0899 != 0) { - D_801A0899 -= 0x10; - } - if (D_801A089A != 0) { - D_801A089A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801838C0[])(void); - -void func_80164EA4(void *a0) { - D_801838C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A08E4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A08E4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A08D8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A08D8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A08D8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A08D8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A08D8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801838D4[]; - extern u32 D_801838F4, D_801838F8, D_801838FC, D_80183900; - extern u32 D_801838F4, D_801838F8, D_801838FC, D_80183900; - extern u32 D_801838F4, D_801838F8, D_801838FC, D_80183900; - extern u32 D_801838F4, D_801838F8, D_801838FC, D_80183900; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801838D4[0x00], p); - ApplyMatrixSV(mat, &D_801838D4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801838D4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801838D4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801838FC; - *(u32 *)(prim + 0x24) = D_801838F4; - *(u32 *)(prim + 0x28) = D_80183900; - *(u32 *)(prim + 0x2c) = D_801838F8; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80183904[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80183904[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80183904[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80183904[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80183980[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80183980[a1 & 0x7F]; -} - - - -extern s32 D_801839A0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801839A0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80183A1C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80183A1C[a1 & 0x7F]; -} - - - -extern u8 D_80183A3C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80183A3C[a1 & 0x7F]; -} - - - -extern u8 D_80183A5C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80183A5C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80183A7C[])(void); - D_80183A7C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80183AF8[])(void); - -void func_80165AC8(void) { - D_80183AF8[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80183B74[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80183B74[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019FFC0; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019FFC0, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80183B80[])(void); - -void func_80166018(void *a0) { - D_80183B80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80183B88[])(void); - -void func_801663FC(void *a0) { - D_80183B88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80183C50[])(void); - -void func_80166618(void *a0) { - D_80183C50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80183C60[])(void); - -void func_80166654(void *a0) { - D_80183C60[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A0958[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A0958[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A0958). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A0958[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A0958)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A0958[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A0958[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80183BA4[]; - extern u8 D_80183B90[]; - extern u8 D_80183BB8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80183BA4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80183B90; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80183BB8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80167714); - - -extern void (*D_80183C70[])(void); - -void func_801678B4(void *a0) { - D_80183C70[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80183C7C[])(void); - -void func_80167A9C(void *a0) { - D_80183C7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80183D88; - extern u8 D_80183D9C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80183D88); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80183D9C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80183BDC[]; -extern u8 D_80183BF0[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80183BDC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80183BF0; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80183C94[])(void); - -void func_80168744(void *a0) { - D_80183C94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80183C84 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80183C84[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80183C84; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80183C9C[])(void); - -void func_801689D8(void *a0) { - D_80183C9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80183CA4[])(void); - -void func_80168AA8(void *a0) { - D_80183CA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80183CAC[])(void); - -void func_80168D58(void *a0) { - D_80183CAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80183CB4[])(void); - -void func_8016901C(void *a0) { - D_80183CB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015AE2C", func_80169228); - - -extern void (*D_80183CBC[])(void); - -void func_801693CC(void *a0) { - D_80183CBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80183CC4[])(void); - -void func_80169830(void *a0) { - D_80183CC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80183D78[])(void); - -void func_80169B80(void *a0) { - D_80183D78[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80183CCC[]; - extern u8 D_80183D3C[]; - extern u8 D_80183D6C[]; - extern u8 D_801A1960[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80183D6C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80183CCC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A1960; - RotMatrixYXZ(rot, D_801A1960); - func_80048D9C(D_801A1960, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80183D3C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80183D80[])(void); - -void func_80169F00(void *a0) { - D_80183D80[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80183D30[]; -extern char D_80183CF0[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80183D30, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183CF0); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80183DB8[])(void); - -void func_8016A020(void *a0) { - D_80183DB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80183D88; - extern u8 D_80183D9C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80183D88); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80183D9C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80183DC4[])(void); - -void func_8016A700(void *a0) { - D_80183DC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80183E0C[])(void); - -void func_8016AB30(void *a0) { - D_80183E0C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c b/src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c new file mode 100644 index 000000000..714c4fdc4 --- /dev/null +++ b/src/ov_SC03_108/ov_SC03_108_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801831D8; +extern u8 D_80183148; +extern u8 D_80183124; +extern u8 D_80183100; +extern u8 D_801831B4; +extern u8 D_80183190; +extern u8 D_8018316C; +extern u8 D_801830DC; +extern void func_80145934(void); +extern u8 D_80183268; +extern u8 D_80183244; +extern u8 D_80183220; +extern u8 D_801831FC; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80182660[]; +extern unsigned char D_80182690[]; +extern unsigned char D_801826E0[]; +extern unsigned char D_80182710[]; +extern unsigned char D_80182740[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80182790[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80182858[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801828E0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801828E8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A0788; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A078C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80182918; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801829C0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801829E4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801829D4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801829F8[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80182A04[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80182A14[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80182A2C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80182A1C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80182A40[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80182A5C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80182A4C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80182A70[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80182A84[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80182A98; +extern void (*D_80182AC0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80182AA0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80182B0C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80182B10[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80182F74[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80182F84[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A07C0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80182FAC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80182F8C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80182F9C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80182FEC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80182FF4[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80182FC0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80183000[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80182FD0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A07C8; +extern s32 D_801A07D4; +extern s32 D_801A07D8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018303C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80183010[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A07D0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018328C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801830AC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80183330[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80183484[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801832A0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018348C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801832B0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801832D0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80183494[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801834BC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018333C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801834C8[])(void); + +void func_8015C714(void *a0) { + D_801834C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018333C[])(void*); + extern int D_801832E0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018333C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018333C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801832E0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018333C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018333C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018333C[])(void*); + extern int D_801832E0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018333C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801832E0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018333C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801834D8[])(void); + D_801834D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018333C[])(struct Ent_8015CD20 *); + extern u8 D_801832F0; + extern u8 D_801834E0; + extern u8 D_801834F0; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018333C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801832F0); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801834E0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801834F0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018333C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80183510[])(void); + D_80183510[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80183500; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80183500 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018333C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018356C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018356C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80182650[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80182650; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80183574[])(void); + D_80183574[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80183580[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80183580[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80183580[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80183580[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018333C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80183580[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80183300[]; + extern u8 D_80183310[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183300); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183310); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80183580[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183580[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183580[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801835B4[])(void); + D_801835B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018333C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801835BC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801835D4[])(void); + D_801835D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018333C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801835BC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801835BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801835F4[])(void); + D_801835F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018333C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018333C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80183604; +extern u16 D_80183606; +extern u16 D_80183608; +extern s32 D_8018360C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80183604 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80183606 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80183608 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018360C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80183614; + +void func_8015E588(void) { + func_8013C9C4(&D_80183614); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018333C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018333C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80183628[])(void); + D_80183628[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018333C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018333C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80183630[])(void); + D_80183630[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80183320; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80183320); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018333C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80183638[])(void); + D_80183638[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018333C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018333C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80183640[])(void); + D_80183640[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018333C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80183648; + extern s32 D_80183658; + extern s32 D_80183668; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183648); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183658); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018333C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183668); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80183678[])(void); + D_80183678[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018333C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018333C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018333C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018333C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80183684[])(void); + D_80183684[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018333C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018333C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018333C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018333C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80183698[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80183698[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018333C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018333C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018333C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018333C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80183714[])(void); + D_80183714[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018333C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018333C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80183724[])(void); + D_80183724[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018333C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018333C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018333C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018333C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018333C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018333C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018333C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018372C[])(void); + D_8018372C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018333C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018333C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018333C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018333C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80183738[])(void); + D_80183738[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018333C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018333C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018333C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018333C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80183748[])(void); + +void func_80160EA4(void *a0) { + D_80183748[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018333C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018333C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80183778[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80183778[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801837DC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801837DC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A07E0[]; + extern u8 D_801837A8[]; + extern u8 D_801837C8[]; + extern u8 D_801A07EC[]; + extern u8 D_801A0814[]; + extern u8 D_801A082C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A07E0[0] = p; + func_80024054(&D_801837A8, &D_801A07EC); + func_8001CE28(p, &D_801A07EC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A07E0[1] = p; + func_80024054(&D_801837C8, &D_801A0814); + func_8001CE28(p, &D_801A0814); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A07E0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A082C, 0x84); + func_8001CE68(p, &D_801A082C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A082C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A07E0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A07E0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801837DC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801837DC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801837DC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801837DC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A07E0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A07E0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80183800[])(void); + +void func_80162330(void *a0) { + D_80183800[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A0838[i] via `extern int D_801A0838[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018380C[]; + extern s32 D_80183824; + extern u8 D_801A0844[]; + extern u8 D_801A086C[]; + extern u8 D_801A0888[]; + extern int D_801A0838[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A0838[0] = (s32)item; + func_80024054(D_8018380C, D_801A0844); + func_8001CE28(item, D_801A0844); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A0838[1] = (s32)item; + func_80024054(((u8 *)&D_80183824), D_801A086C); + func_8001CE28(item, D_801A086C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A0838[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A0888, 0x84); + func_8001CE68(item, D_801A0888); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A0888, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A0838[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A0838; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_801627E8); + + +extern void (*D_80183848[])(void); + +void func_80162834(void *a0) { + D_80183848[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80183838; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80183838, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019FFB0[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019FFB0, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019FFB0[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019FFB0, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80183850[])(void); + +void func_80163A58(void *a0) { + D_80183850[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019FFB8; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019FFB8; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801838A4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801838A4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018386C; +extern s16 D_801838A0; +extern s16 D_8018389E; +extern s16 D_8018389C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018386C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801838A0 = 0x80; + D_8018389E = 0x80; + D_8018389C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801838A0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801838A0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801838A0 - 8; + D_801838A0 = nv; + D_8018389E = nv; + D_8018389C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801838B0[])(void); + +void func_80164BA0(void *a0) { + D_801838B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A0898; +extern u8 D_801A0899; +extern u8 D_801A089A; +extern u8 D_801A089B; +extern u8 D_801A089C; +extern u8 D_801A089D; +extern u8 D_801A089E; +extern u8 D_801A089F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A0898; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A0899 = 0xf0; + *(u8 *)base = 0xf0; + D_801A089A = 0xc0; + D_801A089E = 0; + D_801A089D = 0; + D_801A089C = 0; + D_801A089F = 0; + D_801A089B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A0898; +extern u8 D_801A0899; +extern u8 D_801A089A; + +s32 func_80164E40(void) { + u8 *p = &D_801A0898; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A0899 != 0) { + D_801A0899 -= 0x10; + } + if (D_801A089A != 0) { + D_801A089A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801838C0[])(void); + +void func_80164EA4(void *a0) { + D_801838C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A08E4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A08E4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A08D8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A08D8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A08D8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A08D8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A08D8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801838D4[]; + extern u32 D_801838F4, D_801838F8, D_801838FC, D_80183900; + extern u32 D_801838F4, D_801838F8, D_801838FC, D_80183900; + extern u32 D_801838F4, D_801838F8, D_801838FC, D_80183900; + extern u32 D_801838F4, D_801838F8, D_801838FC, D_80183900; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801838D4[0x00], p); + ApplyMatrixSV(mat, &D_801838D4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801838D4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801838D4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801838FC; + *(u32 *)(prim + 0x24) = D_801838F4; + *(u32 *)(prim + 0x28) = D_80183900; + *(u32 *)(prim + 0x2c) = D_801838F8; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80183904[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80183904[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80183904[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80183904[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80183980[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80183980[a1 & 0x7F]; +} + + + +extern s32 D_801839A0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801839A0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80183A1C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80183A1C[a1 & 0x7F]; +} + + + +extern u8 D_80183A3C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80183A3C[a1 & 0x7F]; +} + + + +extern u8 D_80183A5C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80183A5C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80183A7C[])(void); + D_80183A7C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80183AF8[])(void); + +void func_80165AC8(void) { + D_80183AF8[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80183B74[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80183B74[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019FFC0; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019FFC0, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80183B80[])(void); + +void func_80166018(void *a0) { + D_80183B80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80183B88[])(void); + +void func_801663FC(void *a0) { + D_80183B88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80183C50[])(void); + +void func_80166618(void *a0) { + D_80183C50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80183C60[])(void); + +void func_80166654(void *a0) { + D_80183C60[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A0958[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A0958[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A0958). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A0958[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A0958)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A0958[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A0958[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80183BA4[]; + extern u8 D_80183B90[]; + extern u8 D_80183BB8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80183BA4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80183B90; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80183BB8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80167714); + + +extern void (*D_80183C70[])(void); + +void func_801678B4(void *a0) { + D_80183C70[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80183C7C[])(void); + +void func_80167A9C(void *a0) { + D_80183C7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80183D88; + extern u8 D_80183D9C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80183D88); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80183D9C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80183BDC[]; +extern u8 D_80183BF0[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80183BDC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80183BF0; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80183C94[])(void); + +void func_80168744(void *a0) { + D_80183C94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80183C84 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80183C84[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80183C84; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80183C9C[])(void); + +void func_801689D8(void *a0) { + D_80183C9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80183CA4[])(void); + +void func_80168AA8(void *a0) { + D_80183CA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80183CAC[])(void); + +void func_80168D58(void *a0) { + D_80183CAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80183CB4[])(void); + +void func_8016901C(void *a0) { + D_80183CB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_108/nonmatchings/ov_SC03_108_jr_8015C32C", func_80169228); + + +extern void (*D_80183CBC[])(void); + +void func_801693CC(void *a0) { + D_80183CBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80183CC4[])(void); + +void func_80169830(void *a0) { + D_80183CC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80183D78[])(void); + +void func_80169B80(void *a0) { + D_80183D78[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80183CCC[]; + extern u8 D_80183D3C[]; + extern u8 D_80183D6C[]; + extern u8 D_801A1960[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80183D6C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80183CCC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A1960; + RotMatrixYXZ(rot, D_801A1960); + func_80048D9C(D_801A1960, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80183D3C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80183D80[])(void); + +void func_80169F00(void *a0) { + D_80183D80[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80183D30[]; +extern char D_80183CF0[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80183D30, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183CF0); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80183DB8[])(void); + +void func_8016A020(void *a0) { + D_80183DB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80183D88; + extern u8 D_80183D9C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80183D88); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80183D9C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80183DC4[])(void); + +void func_8016A700(void *a0) { + D_80183DC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80183E0C[])(void); + +void func_8016AB30(void *a0) { + D_80183E0C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_109/ov_SC03_109_jr_8015AE2C.c b/src/ov_SC03_109/ov_SC03_109_jr_8015AE2C.c index d9307e103..79b391a40 100644 --- a/src/ov_SC03_109/ov_SC03_109_jr_8015AE2C.c +++ b/src/ov_SC03_109/ov_SC03_109_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80180B74[])(void); - -void func_8015C714(void *a0) { - D_80180B74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801809E8[])(void*); - extern int D_8018098C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801809E8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801809E8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018098C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801809E8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801809E8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801809E8[])(void*); - extern int D_8018098C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801809E8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018098C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801809E8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80180B84[])(void); - D_80180B84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801809E8[])(struct Ent_8015CD20 *); - extern u8 D_8018099C; - extern u8 D_80180B8C; - extern u8 D_80180B9C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801809E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018099C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180B8C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180B9C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801809E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80180BBC[])(void); - D_80180BBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80180BAC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80180BAC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801809E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80180C18; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80180C18, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8017FCFC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8017FCFC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80180C20[])(void); - D_80180C20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80180C2C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80180C2C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80180C2C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80180C2C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801809E8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80180C2C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801809AC[]; - extern u8 D_801809BC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801809AC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801809BC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80180C2C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180C2C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180C2C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80180C60[])(void); - D_80180C60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801809E8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180C68[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80180C80[])(void); - D_80180C80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801809E8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180C68[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80180CA0[])(void); - D_80180CA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801809E8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801809E8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80180CB0; -extern u16 D_80180CB2; -extern u16 D_80180CB4; -extern s32 D_80180CB8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80180CB0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80180CB2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80180CB4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180CB8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80180CC0; - -void func_8015E588(void) { - func_8013C9C4(&D_80180CC0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801809E8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801809E8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80180CD4[])(void); - D_80180CD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801809E8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801809E8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80180CDC[])(void); - D_80180CDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801809CC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801809CC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801809E8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80180CE4[])(void); - D_80180CE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801809E8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801809E8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80180CEC[])(void); - D_80180CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801809E8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80180CF4; - extern s32 D_80180D04; - extern s32 D_80180D14; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801809E8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180CF4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180D04); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801809E8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180D14); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80180D24[])(void); - D_80180D24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801809E8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801809E8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801809E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801809E8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80180D30[])(void); - D_80180D30[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801809E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801809E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801809E8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801809E8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80180D44[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80180D44[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801809E8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801809E8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801809E8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801809E8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80180DC0[])(void); - D_80180DC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801809E8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801809E8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80180DD0[])(void); - D_80180DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801809E8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801809E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801809E8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801809E8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801809E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801809E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801809E8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80180DD8[])(void); - D_80180DD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801809E8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801809E8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801809E8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801809E8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80180DE4[])(void); - D_80180DE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801809E8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801809E8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801809E8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801809E8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80180DF4[])(void); - -void func_80160EA4(void *a0) { - D_80180DF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801809E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801809E8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80180E24[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80180E24[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80180E88; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80180E88); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801991F0[]; - extern u8 D_80180E54[]; - extern u8 D_80180E74[]; - extern u8 D_801991FC[]; - extern u8 D_80199224[]; - extern u8 D_8019923C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801991F0[0] = p; - func_80024054(&D_80180E54, &D_801991FC); - func_8001CE28(p, &D_801991FC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801991F0[1] = p; - func_80024054(&D_80180E74, &D_80199224); - func_8001CE28(p, &D_80199224); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801991F0[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019923C, 0x84); - func_8001CE68(p, &D_8019923C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019923C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801991F0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801991F0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80180E88; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80180E88; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80180E88; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80180E88; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801991F0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801991F0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80180EAC[])(void); - -void func_80162330(void *a0) { - D_80180EAC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80199248[i] via `extern int D_80199248[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80180EB8[]; - extern s32 D_80180ED0; - extern u8 D_80199254[]; - extern u8 D_8019927C[]; - extern u8 D_80199298[]; - extern int D_80199248[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80199248[0] = (s32)item; - func_80024054(D_80180EB8, D_80199254); - func_8001CE28(item, D_80199254); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80199248[1] = (s32)item; - func_80024054(((u8 *)&D_80180ED0), D_8019927C); - func_8001CE28(item, D_8019927C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80199248[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80199298, 0x84); - func_8001CE68(item, D_80199298); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80199298, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80199248[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80199248; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_801627E8); - - -extern void (*D_80180EF4[])(void); - -void func_80162834(void *a0) { - D_80180EF4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80180EE4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80180EE4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80198AC0[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80198AC0, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80198AC0[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80198AC0, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80180EFC[])(void); - -void func_80163A58(void *a0) { - D_80180EFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80198AC8; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80198AC8; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80180F50[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80180F50[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80180F18; -extern s16 D_80180F4C; -extern s16 D_80180F4A; -extern s16 D_80180F48; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80180F18; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80180F4C = 0x80; - D_80180F4A = 0x80; - D_80180F48 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80180F4C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180F4C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80180F4C - 8; - D_80180F4C = nv; - D_80180F4A = nv; - D_80180F48 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80180F5C[])(void); - -void func_80164BA0(void *a0) { - D_80180F5C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801992A8; -extern u8 D_801992A9; -extern u8 D_801992AA; -extern u8 D_801992AB; -extern u8 D_801992AC; -extern u8 D_801992AD; -extern u8 D_801992AE; -extern u8 D_801992AF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801992A8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801992A9 = 0xf0; - *(u8 *)base = 0xf0; - D_801992AA = 0xc0; - D_801992AE = 0; - D_801992AD = 0; - D_801992AC = 0; - D_801992AF = 0; - D_801992AB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801992A8; -extern u8 D_801992A9; -extern u8 D_801992AA; - -s32 func_80164E40(void) { - u8 *p = &D_801992A8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801992A9 != 0) { - D_801992A9 -= 0x10; - } - if (D_801992AA != 0) { - D_801992AA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80180F6C[])(void); - -void func_80164EA4(void *a0) { - D_80180F6C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801992F4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801992F4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801992E8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801992E8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801992E8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801992E8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801992E8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80180F80[]; - extern u32 D_80180FA0, D_80180FA4, D_80180FA8, D_80180FAC; - extern u32 D_80180FA0, D_80180FA4, D_80180FA8, D_80180FAC; - extern u32 D_80180FA0, D_80180FA4, D_80180FA8, D_80180FAC; - extern u32 D_80180FA0, D_80180FA4, D_80180FA8, D_80180FAC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80180F80[0x00], p); - ApplyMatrixSV(mat, &D_80180F80[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80180F80[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80180F80[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80180FA8; - *(u32 *)(prim + 0x24) = D_80180FA0; - *(u32 *)(prim + 0x28) = D_80180FAC; - *(u32 *)(prim + 0x2c) = D_80180FA4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80180FB0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80180FB0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80180FB0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80180FB0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018102C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018102C[a1 & 0x7F]; -} - - - -extern s32 D_8018104C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018104C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801810C8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801810C8[a1 & 0x7F]; -} - - - -extern u8 D_801810E8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801810E8[a1 & 0x7F]; -} - - - -extern u8 D_80181108[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181108[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80181128[])(void); - D_80181128[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801811A4[])(void); - -void func_80165AC8(void) { - D_801811A4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181220[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181220[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80198AD0; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80198AD0, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018122C[])(void); - -void func_80166018(void *a0) { - D_8018122C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181234[])(void); - -void func_801663FC(void *a0) { - D_80181234[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801812FC[])(void); - -void func_80166618(void *a0) { - D_801812FC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018130C[])(void); - -void func_80166654(void *a0) { - D_8018130C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80199368[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80199368[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80199368). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80199368[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80199368)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80199368[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80199368[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80181250[]; - extern u8 D_8018123C[]; - extern u8 D_80181264[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80181250; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018123C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80181264; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80167714); - - -extern void (*D_8018131C[])(void); - -void func_801678B4(void *a0) { - D_8018131C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181328[])(void); - -void func_80167A9C(void *a0) { - D_80181328[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181434; - extern u8 D_80181448[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181434); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181448; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80181288[]; -extern u8 D_8018129C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80181288; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018129C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181340[])(void); - -void func_80168744(void *a0) { - D_80181340[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181330 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181330[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181330; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181348[])(void); - -void func_801689D8(void *a0) { - D_80181348[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181350[])(void); - -void func_80168AA8(void *a0) { - D_80181350[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181358[])(void); - -void func_80168D58(void *a0) { - D_80181358[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181360[])(void); - -void func_8016901C(void *a0) { - D_80181360[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015AE2C", func_80169228); - - -extern void (*D_80181368[])(void); - -void func_801693CC(void *a0) { - D_80181368[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181370[])(void); - -void func_80169830(void *a0) { - D_80181370[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181424[])(void); - -void func_80169B80(void *a0) { - D_80181424[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181378[]; - extern u8 D_801813E8[]; - extern u8 D_80181418[]; - extern u8 D_8019A368[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181418, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181378[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019A368; - RotMatrixYXZ(rot, D_8019A368); - func_80048D9C(D_8019A368, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801813E8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018142C[])(void); - -void func_80169F00(void *a0) { - D_8018142C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801813DC[]; -extern char D_8018139C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801813DC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018139C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181464[])(void); - -void func_8016A020(void *a0) { - D_80181464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181434; - extern u8 D_80181448[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181434); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181448; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181470[])(void); - -void func_8016A700(void *a0) { - D_80181470[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801814B8[])(void); - -void func_8016AB30(void *a0) { - D_801814B8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c b/src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c new file mode 100644 index 000000000..fb50385c5 --- /dev/null +++ b/src/ov_SC03_109/ov_SC03_109_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180884; +extern u8 D_801807F4; +extern u8 D_801807D0; +extern u8 D_801807AC; +extern u8 D_80180860; +extern u8 D_8018083C; +extern u8 D_80180818; +extern u8 D_80180788; +extern void func_80145934(void); +extern u8 D_80180914; +extern u8 D_801808F0; +extern u8 D_801808CC; +extern u8 D_801808A8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8017FD0C[]; +extern unsigned char D_8017FD3C[]; +extern unsigned char D_8017FD8C[]; +extern unsigned char D_8017FDBC[]; +extern unsigned char D_8017FDEC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8017FE3C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8017FF04[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8017FF8C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8017FF94; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80199198; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019919C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8017FFC4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018006C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180090[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180080; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801800A4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801800B0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801800C0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801800D8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801800C8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801800EC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80180108[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801800F8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018011C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80180130[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80180144; +extern void (*D_8018016C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018014C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801801B8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801801BC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180620[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180630[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801991D0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180658[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180638; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180648; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180698[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801806A0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018066C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801806AC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018067C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801991D8; +extern s32 D_801991E4; +extern s32 D_801991E8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801806E8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801806BC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801991E0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80180938[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180758[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801809DC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80180B30[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018094C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80180B38[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018095C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018097C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80180B40[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80180B68[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801809E8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80180B74[])(void); + +void func_8015C714(void *a0) { + D_80180B74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801809E8[])(void*); + extern int D_8018098C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801809E8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801809E8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018098C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801809E8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801809E8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801809E8[])(void*); + extern int D_8018098C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801809E8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018098C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801809E8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80180B84[])(void); + D_80180B84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801809E8[])(struct Ent_8015CD20 *); + extern u8 D_8018099C; + extern u8 D_80180B8C; + extern u8 D_80180B9C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801809E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018099C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180B8C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180B9C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801809E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80180BBC[])(void); + D_80180BBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80180BAC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80180BAC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801809E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80180C18; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80180C18, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8017FCFC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8017FCFC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80180C20[])(void); + D_80180C20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80180C2C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80180C2C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80180C2C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80180C2C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801809E8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80180C2C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801809AC[]; + extern u8 D_801809BC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801809AC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801809BC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80180C2C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180C2C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180C2C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80180C60[])(void); + D_80180C60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801809E8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180C68[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80180C80[])(void); + D_80180C80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801809E8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180C68[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80180CA0[])(void); + D_80180CA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801809E8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801809E8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80180CB0; +extern u16 D_80180CB2; +extern u16 D_80180CB4; +extern s32 D_80180CB8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80180CB0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80180CB2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80180CB4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180CB8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80180CC0; + +void func_8015E588(void) { + func_8013C9C4(&D_80180CC0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801809E8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801809E8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80180CD4[])(void); + D_80180CD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801809E8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801809E8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80180CDC[])(void); + D_80180CDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801809CC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801809CC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801809E8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80180CE4[])(void); + D_80180CE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801809E8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801809E8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80180CEC[])(void); + D_80180CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801809E8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80180CF4; + extern s32 D_80180D04; + extern s32 D_80180D14; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180CF4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180D04); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801809E8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180D14); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80180D24[])(void); + D_80180D24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801809E8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801809E8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801809E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801809E8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80180D30[])(void); + D_80180D30[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801809E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801809E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801809E8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801809E8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80180D44[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80180D44[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801809E8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801809E8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801809E8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801809E8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80180DC0[])(void); + D_80180DC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801809E8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801809E8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80180DD0[])(void); + D_80180DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801809E8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801809E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801809E8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801809E8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801809E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801809E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801809E8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80180DD8[])(void); + D_80180DD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801809E8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801809E8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801809E8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801809E8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80180DE4[])(void); + D_80180DE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801809E8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801809E8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801809E8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801809E8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80180DF4[])(void); + +void func_80160EA4(void *a0) { + D_80180DF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801809E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801809E8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80180E24[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80180E24[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80180E88; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80180E88); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801991F0[]; + extern u8 D_80180E54[]; + extern u8 D_80180E74[]; + extern u8 D_801991FC[]; + extern u8 D_80199224[]; + extern u8 D_8019923C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801991F0[0] = p; + func_80024054(&D_80180E54, &D_801991FC); + func_8001CE28(p, &D_801991FC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801991F0[1] = p; + func_80024054(&D_80180E74, &D_80199224); + func_8001CE28(p, &D_80199224); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801991F0[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019923C, 0x84); + func_8001CE68(p, &D_8019923C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019923C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801991F0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801991F0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80180E88; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80180E88; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80180E88; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80180E88; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801991F0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801991F0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80180EAC[])(void); + +void func_80162330(void *a0) { + D_80180EAC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80199248[i] via `extern int D_80199248[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80180EB8[]; + extern s32 D_80180ED0; + extern u8 D_80199254[]; + extern u8 D_8019927C[]; + extern u8 D_80199298[]; + extern int D_80199248[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80199248[0] = (s32)item; + func_80024054(D_80180EB8, D_80199254); + func_8001CE28(item, D_80199254); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80199248[1] = (s32)item; + func_80024054(((u8 *)&D_80180ED0), D_8019927C); + func_8001CE28(item, D_8019927C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80199248[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80199298, 0x84); + func_8001CE68(item, D_80199298); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80199298, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80199248[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80199248; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_801627E8); + + +extern void (*D_80180EF4[])(void); + +void func_80162834(void *a0) { + D_80180EF4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80180EE4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80180EE4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80198AC0[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80198AC0, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80198AC0[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80198AC0, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80180EFC[])(void); + +void func_80163A58(void *a0) { + D_80180EFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80198AC8; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80198AC8; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80180F50[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80180F50[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80180F18; +extern s16 D_80180F4C; +extern s16 D_80180F4A; +extern s16 D_80180F48; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80180F18; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80180F4C = 0x80; + D_80180F4A = 0x80; + D_80180F48 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80180F4C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180F4C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80180F4C - 8; + D_80180F4C = nv; + D_80180F4A = nv; + D_80180F48 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80180F5C[])(void); + +void func_80164BA0(void *a0) { + D_80180F5C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801992A8; +extern u8 D_801992A9; +extern u8 D_801992AA; +extern u8 D_801992AB; +extern u8 D_801992AC; +extern u8 D_801992AD; +extern u8 D_801992AE; +extern u8 D_801992AF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801992A8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801992A9 = 0xf0; + *(u8 *)base = 0xf0; + D_801992AA = 0xc0; + D_801992AE = 0; + D_801992AD = 0; + D_801992AC = 0; + D_801992AF = 0; + D_801992AB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801992A8; +extern u8 D_801992A9; +extern u8 D_801992AA; + +s32 func_80164E40(void) { + u8 *p = &D_801992A8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801992A9 != 0) { + D_801992A9 -= 0x10; + } + if (D_801992AA != 0) { + D_801992AA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80180F6C[])(void); + +void func_80164EA4(void *a0) { + D_80180F6C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801992F4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801992F4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801992E8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801992E8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801992E8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801992E8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801992E8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80180F80[]; + extern u32 D_80180FA0, D_80180FA4, D_80180FA8, D_80180FAC; + extern u32 D_80180FA0, D_80180FA4, D_80180FA8, D_80180FAC; + extern u32 D_80180FA0, D_80180FA4, D_80180FA8, D_80180FAC; + extern u32 D_80180FA0, D_80180FA4, D_80180FA8, D_80180FAC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80180F80[0x00], p); + ApplyMatrixSV(mat, &D_80180F80[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80180F80[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80180F80[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80180FA8; + *(u32 *)(prim + 0x24) = D_80180FA0; + *(u32 *)(prim + 0x28) = D_80180FAC; + *(u32 *)(prim + 0x2c) = D_80180FA4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80180FB0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80180FB0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80180FB0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80180FB0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018102C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018102C[a1 & 0x7F]; +} + + + +extern s32 D_8018104C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018104C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801810C8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801810C8[a1 & 0x7F]; +} + + + +extern u8 D_801810E8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801810E8[a1 & 0x7F]; +} + + + +extern u8 D_80181108[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181108[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80181128[])(void); + D_80181128[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801811A4[])(void); + +void func_80165AC8(void) { + D_801811A4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181220[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181220[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80198AD0; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80198AD0, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018122C[])(void); + +void func_80166018(void *a0) { + D_8018122C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181234[])(void); + +void func_801663FC(void *a0) { + D_80181234[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801812FC[])(void); + +void func_80166618(void *a0) { + D_801812FC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018130C[])(void); + +void func_80166654(void *a0) { + D_8018130C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80199368[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80199368[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80199368). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80199368[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80199368)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80199368[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80199368[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80181250[]; + extern u8 D_8018123C[]; + extern u8 D_80181264[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80181250; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018123C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80181264; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80167714); + + +extern void (*D_8018131C[])(void); + +void func_801678B4(void *a0) { + D_8018131C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181328[])(void); + +void func_80167A9C(void *a0) { + D_80181328[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181434; + extern u8 D_80181448[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181434); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181448; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80181288[]; +extern u8 D_8018129C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80181288; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018129C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181340[])(void); + +void func_80168744(void *a0) { + D_80181340[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181330 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181330[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181330; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181348[])(void); + +void func_801689D8(void *a0) { + D_80181348[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181350[])(void); + +void func_80168AA8(void *a0) { + D_80181350[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181358[])(void); + +void func_80168D58(void *a0) { + D_80181358[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181360[])(void); + +void func_8016901C(void *a0) { + D_80181360[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_109/nonmatchings/ov_SC03_109_jr_8015C32C", func_80169228); + + +extern void (*D_80181368[])(void); + +void func_801693CC(void *a0) { + D_80181368[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181370[])(void); + +void func_80169830(void *a0) { + D_80181370[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181424[])(void); + +void func_80169B80(void *a0) { + D_80181424[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181378[]; + extern u8 D_801813E8[]; + extern u8 D_80181418[]; + extern u8 D_8019A368[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181418, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181378[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019A368; + RotMatrixYXZ(rot, D_8019A368); + func_80048D9C(D_8019A368, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801813E8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018142C[])(void); + +void func_80169F00(void *a0) { + D_8018142C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801813DC[]; +extern char D_8018139C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801813DC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018139C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181464[])(void); + +void func_8016A020(void *a0) { + D_80181464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181434; + extern u8 D_80181448[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181434); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181448; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181470[])(void); + +void func_8016A700(void *a0) { + D_80181470[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801814B8[])(void); + +void func_8016AB30(void *a0) { + D_801814B8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_110/ov_SC03_110_jr_8015AE2C.c b/src/ov_SC03_110/ov_SC03_110_jr_8015AE2C.c index 50460f8bd..93d9a3ac5 100644 --- a/src/ov_SC03_110/ov_SC03_110_jr_8015AE2C.c +++ b/src/ov_SC03_110/ov_SC03_110_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80184594[])(void); - -void func_8015C714(void *a0) { - D_80184594[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80184408[])(void*); - extern int D_801843AC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80184408)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80184408)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801843AC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80184408[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80184408[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80184408[])(void*); - extern int D_801843AC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80184408)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801843AC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80184408)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801845A4[])(void); - D_801845A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80184408[])(struct Ent_8015CD20 *); - extern u8 D_801843BC; - extern u8 D_801845AC; - extern u8 D_801845BC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80184408[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801843BC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801845AC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801845BC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80184408[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801845DC[])(void); - D_801845DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801845CC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801845CC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80184408[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80184638; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80184638, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018371C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018371C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80184640[])(void); - D_80184640[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018464C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018464C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018464C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018464C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80184408[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018464C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801843CC[]; - extern u8 D_801843DC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801843CC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801843DC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018464C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018464C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018464C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80184680[])(void); - D_80184680[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184408[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184688[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801846A0[])(void); - D_801846A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184408[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184688[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801846C0[])(void); - D_801846C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80184408[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184408)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801846D0; -extern u16 D_801846D2; -extern u16 D_801846D4; -extern s32 D_801846D8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801846D0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801846D2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801846D4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801846D8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801846E0; - -void func_8015E588(void) { - func_8013C9C4(&D_801846E0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80184408[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184408)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801846F4[])(void); - D_801846F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80184408[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80184408[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801846FC[])(void); - D_801846FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801843EC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801843EC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80184408[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80184704[])(void); - D_80184704[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80184408[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80184408[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018470C[])(void); - D_8018470C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80184408[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80184714; - extern s32 D_80184724; - extern s32 D_80184734; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80184408[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184714); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184724); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80184408[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184734); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184744[])(void); - D_80184744[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80184408[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80184408[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80184408[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184408[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184750[])(void); - D_80184750[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80184408[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184408[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80184408[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184408[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80184764[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80184764[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80184408[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80184408)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80184408[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184408[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801847E0[])(void); - D_801847E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80184408[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80184408)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801847F0[])(void); - D_801847F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80184408[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80184408[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80184408[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80184408[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80184408[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80184408[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80184408[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801847F8[])(void); - D_801847F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80184408[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80184408)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80184408[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80184408)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80184804[])(void); - D_80184804[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184408 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80184408[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80184408[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80184408[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80184814[])(void); - -void func_80160EA4(void *a0) { - D_80184814[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80184408[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80184408[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80184844[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80184844[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801848A8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801848A8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A0F98[]; - extern u8 D_80184874[]; - extern u8 D_80184894[]; - extern u8 D_801A0FA4[]; - extern u8 D_801A0FCC[]; - extern u8 D_801A0FE4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A0F98[0] = p; - func_80024054(&D_80184874, &D_801A0FA4); - func_8001CE28(p, &D_801A0FA4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A0F98[1] = p; - func_80024054(&D_80184894, &D_801A0FCC); - func_8001CE28(p, &D_801A0FCC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A0F98[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A0FE4, 0x84); - func_8001CE68(p, &D_801A0FE4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A0FE4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A0F98[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A0F98; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801848A8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801848A8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801848A8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801848A8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A0F98[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A0F98; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801848CC[])(void); - -void func_80162330(void *a0) { - D_801848CC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A0FF0[i] via `extern int D_801A0FF0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801848D8[]; - extern s32 D_801848F0; - extern u8 D_801A0FFC[]; - extern u8 D_801A1024[]; - extern u8 D_801A1040[]; - extern int D_801A0FF0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A0FF0[0] = (s32)item; - func_80024054(D_801848D8, D_801A0FFC); - func_8001CE28(item, D_801A0FFC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A0FF0[1] = (s32)item; - func_80024054(((u8 *)&D_801848F0), D_801A1024); - func_8001CE28(item, D_801A1024); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A0FF0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A1040, 0x84); - func_8001CE68(item, D_801A1040); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A1040, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A0FF0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A0FF0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_801627E8); - - -extern void (*D_80184914[])(void); - -void func_80162834(void *a0) { - D_80184914[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80184904; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80184904, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801A075C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801A075C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801A075C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801A075C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018491C[])(void); - -void func_80163A58(void *a0) { - D_8018491C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801A0764; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801A0764; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80184970[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80184970[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80184938; -extern s16 D_8018496C; -extern s16 D_8018496A; -extern s16 D_80184968; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80184938; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018496C = 0x80; - D_8018496A = 0x80; - D_80184968 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018496C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018496C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018496C - 8; - D_8018496C = nv; - D_8018496A = nv; - D_80184968 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018497C[])(void); - -void func_80164BA0(void *a0) { - D_8018497C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A1050; -extern u8 D_801A1051; -extern u8 D_801A1052; -extern u8 D_801A1053; -extern u8 D_801A1054; -extern u8 D_801A1055; -extern u8 D_801A1056; -extern u8 D_801A1057; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A1050; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A1051 = 0xf0; - *(u8 *)base = 0xf0; - D_801A1052 = 0xc0; - D_801A1056 = 0; - D_801A1055 = 0; - D_801A1054 = 0; - D_801A1057 = 0; - D_801A1053 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A1050; -extern u8 D_801A1051; -extern u8 D_801A1052; - -s32 func_80164E40(void) { - u8 *p = &D_801A1050; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A1051 != 0) { - D_801A1051 -= 0x10; - } - if (D_801A1052 != 0) { - D_801A1052 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018498C[])(void); - -void func_80164EA4(void *a0) { - D_8018498C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A109C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A109C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A1090[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A1090[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A1090[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A1090; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A1090; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801849A0[]; - extern u32 D_801849C0, D_801849C4, D_801849C8, D_801849CC; - extern u32 D_801849C0, D_801849C4, D_801849C8, D_801849CC; - extern u32 D_801849C0, D_801849C4, D_801849C8, D_801849CC; - extern u32 D_801849C0, D_801849C4, D_801849C8, D_801849CC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801849A0[0x00], p); - ApplyMatrixSV(mat, &D_801849A0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801849A0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801849A0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801849C8; - *(u32 *)(prim + 0x24) = D_801849C0; - *(u32 *)(prim + 0x28) = D_801849CC; - *(u32 *)(prim + 0x2c) = D_801849C4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801849D0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801849D0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801849D0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801849D0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80184A4C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80184A4C[a1 & 0x7F]; -} - - - -extern s32 D_80184A6C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80184A6C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80184AE8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80184AE8[a1 & 0x7F]; -} - - - -extern u8 D_80184B08[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80184B08[a1 & 0x7F]; -} - - - -extern u8 D_80184B28[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80184B28[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80184B48[])(void); - D_80184B48[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80184BC4[])(void); - -void func_80165AC8(void) { - D_80184BC4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80184C40[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80184C40[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801A076C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801A076C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80184C4C[])(void); - -void func_80166018(void *a0) { - D_80184C4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80184C54[])(void); - -void func_801663FC(void *a0) { - D_80184C54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80184D1C[])(void); - -void func_80166618(void *a0) { - D_80184D1C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80184D2C[])(void); - -void func_80166654(void *a0) { - D_80184D2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A1110[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A1110[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A1110). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A1110[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A1110)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A1110[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A1110[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80184C70[]; - extern u8 D_80184C5C[]; - extern u8 D_80184C84[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80184C70; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80184C5C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80184C84; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80167714); - - -extern void (*D_80184D3C[])(void); - -void func_801678B4(void *a0) { - D_80184D3C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80184D48[])(void); - -void func_80167A9C(void *a0) { - D_80184D48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80184E54; - extern u8 D_80184E68[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80184E54); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184E68; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80184CA8[]; -extern u8 D_80184CBC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80184CA8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80184CBC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80184D60[])(void); - -void func_80168744(void *a0) { - D_80184D60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80184D50 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80184D50[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80184D50; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80184D68[])(void); - -void func_801689D8(void *a0) { - D_80184D68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80184D70[])(void); - -void func_80168AA8(void *a0) { - D_80184D70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80184D78[])(void); - -void func_80168D58(void *a0) { - D_80184D78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80184D80[])(void); - -void func_8016901C(void *a0) { - D_80184D80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015AE2C", func_80169228); - - -extern void (*D_80184D88[])(void); - -void func_801693CC(void *a0) { - D_80184D88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80184D90[])(void); - -void func_80169830(void *a0) { - D_80184D90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80184E44[])(void); - -void func_80169B80(void *a0) { - D_80184E44[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80184D98[]; - extern u8 D_80184E08[]; - extern u8 D_80184E38[]; - extern u8 D_801A2398[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80184E38, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80184D98[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A2398; - RotMatrixYXZ(rot, D_801A2398); - func_80048D9C(D_801A2398, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80184E08); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80184E4C[])(void); - -void func_80169F00(void *a0) { - D_80184E4C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80184DFC[]; -extern char D_80184DBC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80184DFC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80184DBC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80184E84[])(void); - -void func_8016A020(void *a0) { - D_80184E84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80184E54; - extern u8 D_80184E68[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80184E54); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184E68; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80184E90[])(void); - -void func_8016A700(void *a0) { - D_80184E90[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80184ED8[])(void); - -void func_8016AB30(void *a0) { - D_80184ED8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c b/src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c new file mode 100644 index 000000000..e0b117982 --- /dev/null +++ b/src/ov_SC03_110/ov_SC03_110_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801842A4; +extern u8 D_80184214; +extern u8 D_801841F0; +extern u8 D_801841CC; +extern u8 D_80184280; +extern u8 D_8018425C; +extern u8 D_80184238; +extern u8 D_801841A8; +extern void func_80145934(void); +extern u8 D_80184334; +extern u8 D_80184310; +extern u8 D_801842EC; +extern u8 D_801842C8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018372C[]; +extern unsigned char D_8018375C[]; +extern unsigned char D_801837AC[]; +extern unsigned char D_801837DC[]; +extern unsigned char D_8018380C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018385C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80183924[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801839AC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801839B4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A0F40; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A0F44; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801839E4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80183A8C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80183AB0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80183AA0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80183AC4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80183AD0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80183AE0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80183AF8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80183AE8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80183B0C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80183B28[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80183B18; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80183B3C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80183B50[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80183B64; +extern void (*D_80183B8C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80183B6C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80183BD8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80183BDC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184040[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184050[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A0F78; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80184078[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80184058; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80184068; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801840B8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801840C0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018408C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801840CC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018409C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A0F80; +extern s32 D_801A0F8C; +extern s32 D_801A0F90; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80184108[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801840DC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A0F88; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184358[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80184178[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801843FC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80184550[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018436C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80184558[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018437C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018439C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80184560[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80184588[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80184408[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80184408[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80184408[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80184408[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80184408[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80184408[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80184408[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80184408[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80184594[])(void); + +void func_8015C714(void *a0) { + D_80184594[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80184408[])(void*); + extern int D_801843AC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80184408)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80184408)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801843AC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80184408[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80184408[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80184408[])(void*); + extern int D_801843AC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80184408)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801843AC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80184408)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801845A4[])(void); + D_801845A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80184408[])(struct Ent_8015CD20 *); + extern u8 D_801843BC; + extern u8 D_801845AC; + extern u8 D_801845BC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80184408[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801843BC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801845AC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801845BC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80184408[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801845DC[])(void); + D_801845DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801845CC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801845CC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80184408[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80184638; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80184638, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018371C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018371C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80184640[])(void); + D_80184640[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018464C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018464C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018464C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018464C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80184408[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018464C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801843CC[]; + extern u8 D_801843DC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801843CC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801843DC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018464C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018464C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018464C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80184680[])(void); + D_80184680[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184408[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184688[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801846A0[])(void); + D_801846A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184408[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184688[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184688[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801846C0[])(void); + D_801846C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80184408[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184408)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801846D0; +extern u16 D_801846D2; +extern u16 D_801846D4; +extern s32 D_801846D8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801846D0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801846D2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801846D4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801846D8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801846E0; + +void func_8015E588(void) { + func_8013C9C4(&D_801846E0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80184408[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184408)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801846F4[])(void); + D_801846F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80184408[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80184408[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801846FC[])(void); + D_801846FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801843EC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801843EC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80184408[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80184704[])(void); + D_80184704[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80184408[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80184408[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018470C[])(void); + D_8018470C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80184408[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80184714; + extern s32 D_80184724; + extern s32 D_80184734; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80184408[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184714); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184724); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80184408[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184734); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184744[])(void); + D_80184744[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80184408[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80184408[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80184408[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184408[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184750[])(void); + D_80184750[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80184408[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184408[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80184408[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184408[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80184764[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80184764[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80184408[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80184408)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80184408[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184408[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801847E0[])(void); + D_801847E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80184408[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80184408)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801847F0[])(void); + D_801847F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80184408[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80184408[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80184408[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80184408[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80184408[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80184408[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80184408[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801847F8[])(void); + D_801847F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80184408[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80184408)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80184408[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80184408)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80184804[])(void); + D_80184804[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184408 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80184408[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80184408[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80184408[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80184814[])(void); + +void func_80160EA4(void *a0) { + D_80184814[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80184408[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80184408[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80184844[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80184844[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801848A8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801848A8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A0F98[]; + extern u8 D_80184874[]; + extern u8 D_80184894[]; + extern u8 D_801A0FA4[]; + extern u8 D_801A0FCC[]; + extern u8 D_801A0FE4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A0F98[0] = p; + func_80024054(&D_80184874, &D_801A0FA4); + func_8001CE28(p, &D_801A0FA4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A0F98[1] = p; + func_80024054(&D_80184894, &D_801A0FCC); + func_8001CE28(p, &D_801A0FCC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A0F98[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A0FE4, 0x84); + func_8001CE68(p, &D_801A0FE4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A0FE4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A0F98[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A0F98; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801848A8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801848A8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801848A8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801848A8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A0F98[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A0F98; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801848CC[])(void); + +void func_80162330(void *a0) { + D_801848CC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A0FF0[i] via `extern int D_801A0FF0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801848D8[]; + extern s32 D_801848F0; + extern u8 D_801A0FFC[]; + extern u8 D_801A1024[]; + extern u8 D_801A1040[]; + extern int D_801A0FF0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A0FF0[0] = (s32)item; + func_80024054(D_801848D8, D_801A0FFC); + func_8001CE28(item, D_801A0FFC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A0FF0[1] = (s32)item; + func_80024054(((u8 *)&D_801848F0), D_801A1024); + func_8001CE28(item, D_801A1024); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A0FF0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A1040, 0x84); + func_8001CE68(item, D_801A1040); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A1040, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A0FF0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A0FF0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_801627E8); + + +extern void (*D_80184914[])(void); + +void func_80162834(void *a0) { + D_80184914[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80184904; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80184904, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801A075C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801A075C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801A075C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801A075C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018491C[])(void); + +void func_80163A58(void *a0) { + D_8018491C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801A0764; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801A0764; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80184970[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80184970[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80184938; +extern s16 D_8018496C; +extern s16 D_8018496A; +extern s16 D_80184968; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80184938; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018496C = 0x80; + D_8018496A = 0x80; + D_80184968 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018496C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018496C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018496C - 8; + D_8018496C = nv; + D_8018496A = nv; + D_80184968 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018497C[])(void); + +void func_80164BA0(void *a0) { + D_8018497C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A1050; +extern u8 D_801A1051; +extern u8 D_801A1052; +extern u8 D_801A1053; +extern u8 D_801A1054; +extern u8 D_801A1055; +extern u8 D_801A1056; +extern u8 D_801A1057; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A1050; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A1051 = 0xf0; + *(u8 *)base = 0xf0; + D_801A1052 = 0xc0; + D_801A1056 = 0; + D_801A1055 = 0; + D_801A1054 = 0; + D_801A1057 = 0; + D_801A1053 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A1050; +extern u8 D_801A1051; +extern u8 D_801A1052; + +s32 func_80164E40(void) { + u8 *p = &D_801A1050; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A1051 != 0) { + D_801A1051 -= 0x10; + } + if (D_801A1052 != 0) { + D_801A1052 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018498C[])(void); + +void func_80164EA4(void *a0) { + D_8018498C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A109C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A109C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A1090[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A1090[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A1090[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A1090; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A1090; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801849A0[]; + extern u32 D_801849C0, D_801849C4, D_801849C8, D_801849CC; + extern u32 D_801849C0, D_801849C4, D_801849C8, D_801849CC; + extern u32 D_801849C0, D_801849C4, D_801849C8, D_801849CC; + extern u32 D_801849C0, D_801849C4, D_801849C8, D_801849CC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801849A0[0x00], p); + ApplyMatrixSV(mat, &D_801849A0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801849A0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801849A0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801849C8; + *(u32 *)(prim + 0x24) = D_801849C0; + *(u32 *)(prim + 0x28) = D_801849CC; + *(u32 *)(prim + 0x2c) = D_801849C4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801849D0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801849D0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801849D0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801849D0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80184A4C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80184A4C[a1 & 0x7F]; +} + + + +extern s32 D_80184A6C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80184A6C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80184AE8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80184AE8[a1 & 0x7F]; +} + + + +extern u8 D_80184B08[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80184B08[a1 & 0x7F]; +} + + + +extern u8 D_80184B28[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80184B28[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80184B48[])(void); + D_80184B48[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80184BC4[])(void); + +void func_80165AC8(void) { + D_80184BC4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80184C40[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80184C40[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801A076C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801A076C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80184C4C[])(void); + +void func_80166018(void *a0) { + D_80184C4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80184C54[])(void); + +void func_801663FC(void *a0) { + D_80184C54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80184D1C[])(void); + +void func_80166618(void *a0) { + D_80184D1C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80184D2C[])(void); + +void func_80166654(void *a0) { + D_80184D2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A1110[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A1110[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A1110). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A1110[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A1110)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A1110[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A1110[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80184C70[]; + extern u8 D_80184C5C[]; + extern u8 D_80184C84[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80184C70; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80184C5C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80184C84; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80167714); + + +extern void (*D_80184D3C[])(void); + +void func_801678B4(void *a0) { + D_80184D3C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80184D48[])(void); + +void func_80167A9C(void *a0) { + D_80184D48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80184E54; + extern u8 D_80184E68[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80184E54); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184E68; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80184CA8[]; +extern u8 D_80184CBC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80184CA8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80184CBC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80184D60[])(void); + +void func_80168744(void *a0) { + D_80184D60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80184D50 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80184D50[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80184D50; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80184D68[])(void); + +void func_801689D8(void *a0) { + D_80184D68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80184D70[])(void); + +void func_80168AA8(void *a0) { + D_80184D70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80184D78[])(void); + +void func_80168D58(void *a0) { + D_80184D78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80184D80[])(void); + +void func_8016901C(void *a0) { + D_80184D80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_110/nonmatchings/ov_SC03_110_jr_8015C32C", func_80169228); + + +extern void (*D_80184D88[])(void); + +void func_801693CC(void *a0) { + D_80184D88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80184D90[])(void); + +void func_80169830(void *a0) { + D_80184D90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80184E44[])(void); + +void func_80169B80(void *a0) { + D_80184E44[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80184D98[]; + extern u8 D_80184E08[]; + extern u8 D_80184E38[]; + extern u8 D_801A2398[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80184E38, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80184D98[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A2398; + RotMatrixYXZ(rot, D_801A2398); + func_80048D9C(D_801A2398, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80184E08); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80184E4C[])(void); + +void func_80169F00(void *a0) { + D_80184E4C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80184DFC[]; +extern char D_80184DBC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80184DFC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80184DBC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80184E84[])(void); + +void func_8016A020(void *a0) { + D_80184E84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80184E54; + extern u8 D_80184E68[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80184E54); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184E68; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80184E90[])(void); + +void func_8016A700(void *a0) { + D_80184E90[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80184ED8[])(void); + +void func_8016AB30(void *a0) { + D_80184ED8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_111/ov_SC03_111_jr_8015AE2C.c b/src/ov_SC03_111/ov_SC03_111_jr_8015AE2C.c index 51428461a..4762b9600 100644 --- a/src/ov_SC03_111/ov_SC03_111_jr_8015AE2C.c +++ b/src/ov_SC03_111/ov_SC03_111_jr_8015AE2C.c @@ -1642,4590 +1642,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80187148[])(void); - -void func_8015C714(void *a0) { - D_80187148[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80186FBC[])(void*); - extern int D_80186F60; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80186FBC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80186FBC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186F60); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80186FBC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80186FBC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80186FBC[])(void*); - extern int D_80186F60; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80186FBC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186F60); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80186FBC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80187158[])(void); - D_80187158[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80186FBC[])(struct Ent_8015CD20 *); - extern u8 D_80186F70; - extern u8 D_80187160; - extern u8 D_80187170; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80186FBC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F70); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187160); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187170); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80186FBC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80187190[])(void); - D_80187190[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80187180; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80187180 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80186FBC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801871EC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801871EC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801862D0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801862D0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801871F4[])(void); - D_801871F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80187200[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80187200[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80187200[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80187200[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80186FBC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80187200[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80186F80[]; - extern u8 D_80186F90[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F80); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F90); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80187200[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187200[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187200[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80187234[])(void); - D_80187234[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186FBC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018723C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80187254[])(void); - D_80187254[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186FBC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018723C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80187274[])(void); - D_80187274[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80186FBC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186FBC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80187284; -extern u16 D_80187286; -extern u16 D_80187288; -extern s32 D_8018728C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80187284 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80187286 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187288 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018728C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80187294; - -void func_8015E588(void) { - func_8013C9C4(&D_80187294); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80186FBC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186FBC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801872A8[])(void); - D_801872A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80186FBC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80186FBC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801872B0[])(void); - D_801872B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80186FA0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186FA0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80186FBC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801872B8[])(void); - D_801872B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80186FBC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80186FBC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801872C0[])(void); - D_801872C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80186FBC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801872C8; - extern s32 D_801872D8; - extern s32 D_801872E8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80186FBC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872C8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872D8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80186FBC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872E8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801872F8[])(void); - D_801872F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80186FBC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80186FBC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80186FBC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186FBC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80187304[])(void); - D_80187304[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80186FBC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186FBC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80186FBC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186FBC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80187318[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80187318[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80186FBC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80186FBC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80186FBC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186FBC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80187394[])(void); - D_80187394[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80186FBC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80186FBC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801873A4[])(void); - D_801873A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80186FBC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80186FBC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80186FBC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80186FBC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80186FBC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80186FBC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80186FBC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801873AC[])(void); - D_801873AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80186FBC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80186FBC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80186FBC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80186FBC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801873B8[])(void); - D_801873B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186FBC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80186FBC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80186FBC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80186FBC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801873C8[])(void); - -void func_80160EA4(void *a0) { - D_801873C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80186FBC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80186FBC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801873F8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801873F8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018745C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018745C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B84A0[]; - extern u8 D_80187428[]; - extern u8 D_80187448[]; - extern u8 D_801B84AC[]; - extern u8 D_801B84D4[]; - extern u8 D_801B84EC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B84A0[0] = p; - func_80024054(&D_80187428, &D_801B84AC); - func_8001CE28(p, &D_801B84AC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B84A0[1] = p; - func_80024054(&D_80187448, &D_801B84D4); - func_8001CE28(p, &D_801B84D4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B84A0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B84EC, 0x84); - func_8001CE68(p, &D_801B84EC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B84EC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B84A0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B84A0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018745C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018745C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018745C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018745C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B84A0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B84A0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80187480[])(void); - -void func_80162330(void *a0) { - D_80187480[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B84F8[i] via `extern int D_801B84F8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018748C[]; - extern s32 D_801874A4; - extern u8 D_801B8504[]; - extern u8 D_801B852C[]; - extern u8 D_801B8548[]; - extern int D_801B84F8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B84F8[0] = (s32)item; - func_80024054(D_8018748C, D_801B8504); - func_8001CE28(item, D_801B8504); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B84F8[1] = (s32)item; - func_80024054(((u8 *)&D_801874A4), D_801B852C); - func_8001CE28(item, D_801B852C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B84F8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B8548, 0x84); - func_8001CE68(item, D_801B8548); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B8548, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B84F8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B84F8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_801627E8); - - -extern void (*D_801874C8[])(void); - -void func_80162834(void *a0) { - D_801874C8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801874B8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801874B8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B7CDC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B7CDC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B7CDC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B7CDC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801874D0[])(void); - -void func_80163A58(void *a0) { - D_801874D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B7CE4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B7CE4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80187524[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80187524[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801874EC; -extern s16 D_80187520; -extern s16 D_8018751E; -extern s16 D_8018751C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801874EC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80187520 = 0x80; - D_8018751E = 0x80; - D_8018751C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80187520 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187520` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80187520 - 8; - D_80187520 = nv; - D_8018751E = nv; - D_8018751C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80187530[])(void); - -void func_80164BA0(void *a0) { - D_80187530[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B8558; -extern u8 D_801B8559; -extern u8 D_801B855A; -extern u8 D_801B855B; -extern u8 D_801B855C; -extern u8 D_801B855D; -extern u8 D_801B855E; -extern u8 D_801B855F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B8558; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B8559 = 0xf0; - *(u8 *)base = 0xf0; - D_801B855A = 0xc0; - D_801B855E = 0; - D_801B855D = 0; - D_801B855C = 0; - D_801B855F = 0; - D_801B855B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B8558; -extern u8 D_801B8559; -extern u8 D_801B855A; - -s32 func_80164E40(void) { - u8 *p = &D_801B8558; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B8559 != 0) { - D_801B8559 -= 0x10; - } - if (D_801B855A != 0) { - D_801B855A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80187540[])(void); - -void func_80164EA4(void *a0) { - D_80187540[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B85A4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B85A4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B8598[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B8598[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B8598[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B8598; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B8598; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80187554[]; - extern u32 D_80187574, D_80187578, D_8018757C, D_80187580; - extern u32 D_80187574, D_80187578, D_8018757C, D_80187580; - extern u32 D_80187574, D_80187578, D_8018757C, D_80187580; - extern u32 D_80187574, D_80187578, D_8018757C, D_80187580; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80187554[0x00], p); - ApplyMatrixSV(mat, &D_80187554[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80187554[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80187554[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018757C; - *(u32 *)(prim + 0x24) = D_80187574; - *(u32 *)(prim + 0x28) = D_80187580; - *(u32 *)(prim + 0x2c) = D_80187578; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187584[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187584[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187584[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187584[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80187600[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80187600[a1 & 0x7F]; -} - - - -extern s32 D_80187620[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80187620[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018769C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018769C[a1 & 0x7F]; -} - - - -extern u8 D_801876BC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801876BC[a1 & 0x7F]; -} - - - -extern u8 D_801876DC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801876DC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801876FC[])(void); - D_801876FC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187778[])(void); - -void func_80165AC8(void) { - D_80187778[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801877F4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801877F4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B7CEC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B7CEC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80187800[])(void); - -void func_80166018(void *a0) { - D_80187800[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80187808[])(void); - -void func_801663FC(void *a0) { - D_80187808[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801878D0[])(void); - -void func_80166618(void *a0) { - D_801878D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801878E0[])(void); - -void func_80166654(void *a0) { - D_801878E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B8618[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B8618[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B8618). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B8618[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B8618)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B8618[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B8618[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80187824[]; - extern u8 D_80187810[]; - extern u8 D_80187838[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80187824; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80187810; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187838; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80167714); - - -extern void (*D_801878F0[])(void); - -void func_801678B4(void *a0) { - D_801878F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801878FC[])(void); - -void func_80167A9C(void *a0) { - D_801878FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80187A08; - extern u8 D_80187A1C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80187A08); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187A1C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018785C[]; -extern u8 D_80187870[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018785C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187870; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80187914[])(void); - -void func_80168744(void *a0) { - D_80187914[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80187904 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80187904[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80187904; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018791C[])(void); - -void func_801689D8(void *a0) { - D_8018791C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80187924[])(void); - -void func_80168AA8(void *a0) { - D_80187924[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018792C[])(void); - -void func_80168D58(void *a0) { - D_8018792C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80187934[])(void); - -void func_8016901C(void *a0) { - D_80187934[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015AE2C", func_80169228); - - -extern void (*D_8018793C[])(void); - -void func_801693CC(void *a0) { - D_8018793C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80187944[])(void); - -void func_80169830(void *a0) { - D_80187944[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801879F8[])(void); - -void func_80169B80(void *a0) { - D_801879F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018794C[]; - extern u8 D_801879BC[]; - extern u8 D_801879EC[]; - extern u8 D_801B9A40[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801879EC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018794C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B9A40; - RotMatrixYXZ(rot, D_801B9A40); - func_80048D9C(D_801B9A40, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801879BC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80187A00[])(void); - -void func_80169F00(void *a0) { - D_80187A00[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801879B0[]; -extern char D_80187970[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801879B0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187970); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187A38[])(void); - -void func_8016A020(void *a0) { - D_80187A38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80187A08; - extern u8 D_80187A1C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80187A08); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187A1C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80187A44[])(void); - -void func_8016A700(void *a0) { - D_80187A44[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80187A8C[])(void); - -void func_8016AB30(void *a0) { - D_80187A8C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c b/src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c new file mode 100644 index 000000000..0b3e3815f --- /dev/null +++ b/src/ov_SC03_111/ov_SC03_111_jr_8015C32C.c @@ -0,0 +1,5947 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +typedef struct { + u8 pad00[0x12]; + u16 unk12; /* 0x12 */ +} Sub_80155800_80155800; +typedef struct { + u8 pad00[0x20]; + Sub_80155800_80155800 *unk20; /* 0x20 */ + u8 pad24[0x44 - 0x24]; + s32 unk44; /* 0x44 */ + u8 pad48[0xB8 - 0x48]; + u16 unkB8; /* 0xB8 */ + u8 padBA[0x1A8 - 0xBA]; + u8 unk1A8; /* 0x1A8 */ + u8 unk1A9; /* 0x1A9 */ + u8 unk1AA; /* 0x1AA */ + u8 pad1AB[0x1C0 - 0x1AB]; + u8 unk1C0; /* 0x1C0 */ + u8 pad1C1[0x234 - 0x1C1]; + u8 unk234; /* 0x234 */ +} Ent_80155800_80155800; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80186E58; +extern u8 D_80186DC8; +extern u8 D_80186DA4; +extern u8 D_80186D80; +extern u8 D_80186E34; +extern u8 D_80186E10; +extern u8 D_80186DEC; +extern u8 D_80186D5C; +extern void func_80145934(void); +extern u8 D_80186EE8; +extern u8 D_80186EC4; +extern u8 D_80186EA0; +extern u8 D_80186E7C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801862E0[]; +extern unsigned char D_80186310[]; +extern unsigned char D_80186360[]; +extern unsigned char D_80186390[]; +extern unsigned char D_801863C0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80186410[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801864D8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80186560[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186568; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B8448; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B844C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186598; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80186640[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80186664[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80186654; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186678[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80186684[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80186694[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801866AC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018669C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801866C0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801866DC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801866CC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801866F0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80186704[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80186718; +extern void (*D_80186740[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80186720; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018678C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80186790[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern s32 func_80155800(s32 arg0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186BF4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80186C04[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B8480; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80186C2C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80186C0C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80186C1C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80186C6C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80186C74[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80186C40; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80186C80[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80186C50; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B8488; +extern s32 D_801B8494; +extern s32 D_801B8498; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80186CBC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80186C90[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B8490; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80186F0C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80186D2C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80186FB0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80187104[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186F20; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018710C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186F30; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80186F50; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80187114[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018713C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80186FBC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80187148[])(void); + +void func_8015C714(void *a0) { + D_80187148[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80186FBC[])(void*); + extern int D_80186F60; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80186FBC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80186FBC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186F60); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80186FBC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80186FBC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80186FBC[])(void*); + extern int D_80186F60; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80186FBC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186F60); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80186FBC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80187158[])(void); + D_80187158[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80186FBC[])(struct Ent_8015CD20 *); + extern u8 D_80186F70; + extern u8 D_80187160; + extern u8 D_80187170; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80186FBC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F70); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187160); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187170); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80186FBC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80187190[])(void); + D_80187190[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80187180; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80187180 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80186FBC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801871EC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801871EC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801862D0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801862D0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801871F4[])(void); + D_801871F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80187200[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80187200[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80187200[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80187200[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80186FBC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80187200[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80186F80[]; + extern u8 D_80186F90[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F80); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F90); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80187200[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187200[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187200[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80187234[])(void); + D_80187234[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186FBC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018723C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80187254[])(void); + D_80187254[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186FBC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018723C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018723C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80187274[])(void); + D_80187274[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80186FBC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186FBC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80187284; +extern u16 D_80187286; +extern u16 D_80187288; +extern s32 D_8018728C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80187284 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80187286 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187288 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018728C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80187294; + +void func_8015E588(void) { + func_8013C9C4(&D_80187294); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80186FBC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186FBC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801872A8[])(void); + D_801872A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80186FBC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80186FBC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801872B0[])(void); + D_801872B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80186FA0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186FA0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80186FBC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801872B8[])(void); + D_801872B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80186FBC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80186FBC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801872C0[])(void); + D_801872C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80186FBC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801872C8; + extern s32 D_801872D8; + extern s32 D_801872E8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872C8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872D8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80186FBC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801872E8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801872F8[])(void); + D_801872F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80186FBC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80186FBC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80186FBC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186FBC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80187304[])(void); + D_80187304[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80186FBC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186FBC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80186FBC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186FBC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80187318[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80187318[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80186FBC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80186FBC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80186FBC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186FBC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80187394[])(void); + D_80187394[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80186FBC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80186FBC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801873A4[])(void); + D_801873A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80186FBC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80186FBC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80186FBC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80186FBC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80186FBC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80186FBC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80186FBC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801873AC[])(void); + D_801873AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80186FBC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80186FBC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80186FBC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80186FBC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801873B8[])(void); + D_801873B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186FBC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80186FBC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80186FBC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80186FBC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801873C8[])(void); + +void func_80160EA4(void *a0) { + D_801873C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80186FBC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80186FBC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801873F8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801873F8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018745C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018745C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B84A0[]; + extern u8 D_80187428[]; + extern u8 D_80187448[]; + extern u8 D_801B84AC[]; + extern u8 D_801B84D4[]; + extern u8 D_801B84EC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B84A0[0] = p; + func_80024054(&D_80187428, &D_801B84AC); + func_8001CE28(p, &D_801B84AC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B84A0[1] = p; + func_80024054(&D_80187448, &D_801B84D4); + func_8001CE28(p, &D_801B84D4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B84A0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B84EC, 0x84); + func_8001CE68(p, &D_801B84EC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B84EC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B84A0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B84A0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018745C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018745C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018745C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018745C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B84A0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B84A0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80187480[])(void); + +void func_80162330(void *a0) { + D_80187480[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B84F8[i] via `extern int D_801B84F8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018748C[]; + extern s32 D_801874A4; + extern u8 D_801B8504[]; + extern u8 D_801B852C[]; + extern u8 D_801B8548[]; + extern int D_801B84F8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B84F8[0] = (s32)item; + func_80024054(D_8018748C, D_801B8504); + func_8001CE28(item, D_801B8504); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B84F8[1] = (s32)item; + func_80024054(((u8 *)&D_801874A4), D_801B852C); + func_8001CE28(item, D_801B852C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B84F8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B8548, 0x84); + func_8001CE68(item, D_801B8548); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B8548, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B84F8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B84F8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_801627E8); + + +extern void (*D_801874C8[])(void); + +void func_80162834(void *a0) { + D_801874C8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801874B8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801874B8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B7CDC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B7CDC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B7CDC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B7CDC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801874D0[])(void); + +void func_80163A58(void *a0) { + D_801874D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B7CE4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B7CE4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80187524[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80187524[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801874EC; +extern s16 D_80187520; +extern s16 D_8018751E; +extern s16 D_8018751C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801874EC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80187520 = 0x80; + D_8018751E = 0x80; + D_8018751C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80187520 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187520` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80187520 - 8; + D_80187520 = nv; + D_8018751E = nv; + D_8018751C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80187530[])(void); + +void func_80164BA0(void *a0) { + D_80187530[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B8558; +extern u8 D_801B8559; +extern u8 D_801B855A; +extern u8 D_801B855B; +extern u8 D_801B855C; +extern u8 D_801B855D; +extern u8 D_801B855E; +extern u8 D_801B855F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B8558; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B8559 = 0xf0; + *(u8 *)base = 0xf0; + D_801B855A = 0xc0; + D_801B855E = 0; + D_801B855D = 0; + D_801B855C = 0; + D_801B855F = 0; + D_801B855B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B8558; +extern u8 D_801B8559; +extern u8 D_801B855A; + +s32 func_80164E40(void) { + u8 *p = &D_801B8558; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B8559 != 0) { + D_801B8559 -= 0x10; + } + if (D_801B855A != 0) { + D_801B855A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80187540[])(void); + +void func_80164EA4(void *a0) { + D_80187540[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B85A4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B85A4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B8598[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B8598[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B8598[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B8598; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B8598; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80187554[]; + extern u32 D_80187574, D_80187578, D_8018757C, D_80187580; + extern u32 D_80187574, D_80187578, D_8018757C, D_80187580; + extern u32 D_80187574, D_80187578, D_8018757C, D_80187580; + extern u32 D_80187574, D_80187578, D_8018757C, D_80187580; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80187554[0x00], p); + ApplyMatrixSV(mat, &D_80187554[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80187554[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80187554[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018757C; + *(u32 *)(prim + 0x24) = D_80187574; + *(u32 *)(prim + 0x28) = D_80187580; + *(u32 *)(prim + 0x2c) = D_80187578; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187584[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187584[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187584[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187584[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80187600[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80187600[a1 & 0x7F]; +} + + + +extern s32 D_80187620[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80187620[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018769C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018769C[a1 & 0x7F]; +} + + + +extern u8 D_801876BC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801876BC[a1 & 0x7F]; +} + + + +extern u8 D_801876DC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801876DC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801876FC[])(void); + D_801876FC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187778[])(void); + +void func_80165AC8(void) { + D_80187778[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801877F4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801877F4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B7CEC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B7CEC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80187800[])(void); + +void func_80166018(void *a0) { + D_80187800[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80187808[])(void); + +void func_801663FC(void *a0) { + D_80187808[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801878D0[])(void); + +void func_80166618(void *a0) { + D_801878D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801878E0[])(void); + +void func_80166654(void *a0) { + D_801878E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B8618[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B8618[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B8618). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B8618[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B8618)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B8618[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B8618[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80187824[]; + extern u8 D_80187810[]; + extern u8 D_80187838[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80187824; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80187810; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187838; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80167714); + + +extern void (*D_801878F0[])(void); + +void func_801678B4(void *a0) { + D_801878F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801878FC[])(void); + +void func_80167A9C(void *a0) { + D_801878FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80187A08; + extern u8 D_80187A1C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80187A08); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187A1C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018785C[]; +extern u8 D_80187870[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018785C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187870; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80187914[])(void); + +void func_80168744(void *a0) { + D_80187914[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80187904 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80187904[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80187904; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018791C[])(void); + +void func_801689D8(void *a0) { + D_8018791C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80187924[])(void); + +void func_80168AA8(void *a0) { + D_80187924[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018792C[])(void); + +void func_80168D58(void *a0) { + D_8018792C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80187934[])(void); + +void func_8016901C(void *a0) { + D_80187934[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_111/nonmatchings/ov_SC03_111_jr_8015C32C", func_80169228); + + +extern void (*D_8018793C[])(void); + +void func_801693CC(void *a0) { + D_8018793C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80187944[])(void); + +void func_80169830(void *a0) { + D_80187944[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801879F8[])(void); + +void func_80169B80(void *a0) { + D_801879F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018794C[]; + extern u8 D_801879BC[]; + extern u8 D_801879EC[]; + extern u8 D_801B9A40[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801879EC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018794C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B9A40; + RotMatrixYXZ(rot, D_801B9A40); + func_80048D9C(D_801B9A40, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801879BC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80187A00[])(void); + +void func_80169F00(void *a0) { + D_80187A00[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801879B0[]; +extern char D_80187970[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801879B0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187970); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187A38[])(void); + +void func_8016A020(void *a0) { + D_80187A38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80187A08; + extern u8 D_80187A1C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80187A08); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187A1C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80187A44[])(void); + +void func_8016A700(void *a0) { + D_80187A44[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80187A8C[])(void); + +void func_8016AB30(void *a0) { + D_80187A8C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_112/ov_SC03_112_jr_8015AE2C.c b/src/ov_SC03_112/ov_SC03_112_jr_8015AE2C.c index 7c9c3285e..d578d42b1 100644 --- a/src/ov_SC03_112/ov_SC03_112_jr_8015AE2C.c +++ b/src/ov_SC03_112/ov_SC03_112_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80187F50[])(void); - -void func_8015C714(void *a0) { - D_80187F50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80187DC4[])(void*); - extern int D_80187D68; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80187DC4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80187DC4)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187D68); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80187DC4[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80187DC4[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80187DC4[])(void*); - extern int D_80187D68; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80187DC4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187D68); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80187DC4)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80187F60[])(void); - D_80187F60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80187DC4[])(struct Ent_8015CD20 *); - extern u8 D_80187D78; - extern u8 D_80187F68; - extern u8 D_80187F78; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80187DC4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187D78); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187F68); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187F78); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80187DC4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80187F98[])(void); - D_80187F98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80187F88; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80187F88 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80187DC4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80187FF4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80187FF4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801870D8[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801870D8; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80187FFC[])(void); - D_80187FFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80188008[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80188008[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80188008[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80188008[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80187DC4[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80188008[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80187D88[]; - extern u8 D_80187D98[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187D88); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187D98); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80188008[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80188008[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80188008[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018803C[])(void); - D_8018803C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187DC4[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188044[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018805C[])(void); - D_8018805C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187DC4[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188044[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018807C[])(void); - D_8018807C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80187DC4[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187DC4)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018808C; -extern u16 D_8018808E; -extern u16 D_80188090; -extern s32 D_80188094; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018808C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018808E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80188090 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188094, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018809C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018809C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80187DC4[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187DC4)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801880B0[])(void); - D_801880B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80187DC4[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80187DC4[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801880B8[])(void); - D_801880B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80187DA8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187DA8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80187DC4[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801880C0[])(void); - D_801880C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80187DC4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80187DC4[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801880C8[])(void); - D_801880C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80187DC4[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801880D0; - extern s32 D_801880E0; - extern s32 D_801880F0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80187DC4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801880D0); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801880E0); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80187DC4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801880F0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80188100[])(void); - D_80188100[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80187DC4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80187DC4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80187DC4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187DC4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018810C[])(void); - D_8018810C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80187DC4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187DC4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80187DC4[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187DC4[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80188120[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80188120[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80187DC4[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80187DC4)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80187DC4[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187DC4[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018819C[])(void); - D_8018819C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80187DC4[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80187DC4)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801881AC[])(void); - D_801881AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80187DC4[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80187DC4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80187DC4[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80187DC4[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80187DC4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80187DC4[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80187DC4[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801881B4[])(void); - D_801881B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80187DC4[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80187DC4)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80187DC4[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80187DC4)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801881C0[])(void); - D_801881C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187DC4 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80187DC4[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80187DC4[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80187DC4[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801881D0[])(void); - -void func_80160EA4(void *a0) { - D_801881D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80187DC4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80187DC4[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80188200[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80188200[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80188264; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80188264); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801ABD00[]; - extern u8 D_80188230[]; - extern u8 D_80188250[]; - extern u8 D_801ABD0C[]; - extern u8 D_801ABD34[]; - extern u8 D_801ABD4C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801ABD00[0] = p; - func_80024054(&D_80188230, &D_801ABD0C); - func_8001CE28(p, &D_801ABD0C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801ABD00[1] = p; - func_80024054(&D_80188250, &D_801ABD34); - func_8001CE28(p, &D_801ABD34); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801ABD00[2] = p; - func_800242D0((s16)func_801620C4(), &D_801ABD4C, 0x84); - func_8001CE68(p, &D_801ABD4C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801ABD4C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801ABD00[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801ABD00; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80188264; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80188264; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80188264; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80188264; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801ABD00[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801ABD00; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80188288[])(void); - -void func_80162330(void *a0) { - D_80188288[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801ABD58[i] via `extern int D_801ABD58[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80188294[]; - extern s32 D_801882AC; - extern u8 D_801ABD64[]; - extern u8 D_801ABD8C[]; - extern u8 D_801ABDA8[]; - extern int D_801ABD58[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801ABD58[0] = (s32)item; - func_80024054(D_80188294, D_801ABD64); - func_8001CE28(item, D_801ABD64); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801ABD58[1] = (s32)item; - func_80024054(((u8 *)&D_801882AC), D_801ABD8C); - func_8001CE28(item, D_801ABD8C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801ABD58[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801ABDA8, 0x84); - func_8001CE68(item, D_801ABDA8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801ABDA8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801ABD58[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801ABD58; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_801627E8); - - -extern void (*D_801882D0[])(void); - -void func_80162834(void *a0) { - D_801882D0[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801882C0; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801882C0, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801AB444[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801AB444, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801AB444[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801AB444, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801882D8[])(void); - -void func_80163A58(void *a0) { - D_801882D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801AB44C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801AB44C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018832C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018832C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801882F4; -extern s16 D_80188328; -extern s16 D_80188326; -extern s16 D_80188324; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801882F4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80188328 = 0x80; - D_80188326 = 0x80; - D_80188324 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80188328 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188328` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80188328 - 8; - D_80188328 = nv; - D_80188326 = nv; - D_80188324 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80188338[])(void); - -void func_80164BA0(void *a0) { - D_80188338[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801ABDB8; -extern u8 D_801ABDB9; -extern u8 D_801ABDBA; -extern u8 D_801ABDBB; -extern u8 D_801ABDBC; -extern u8 D_801ABDBD; -extern u8 D_801ABDBE; -extern u8 D_801ABDBF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801ABDB8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801ABDB9 = 0xf0; - *(u8 *)base = 0xf0; - D_801ABDBA = 0xc0; - D_801ABDBE = 0; - D_801ABDBD = 0; - D_801ABDBC = 0; - D_801ABDBF = 0; - D_801ABDBB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801ABDB8; -extern u8 D_801ABDB9; -extern u8 D_801ABDBA; - -s32 func_80164E40(void) { - u8 *p = &D_801ABDB8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801ABDB9 != 0) { - D_801ABDB9 -= 0x10; - } - if (D_801ABDBA != 0) { - D_801ABDBA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80188348[])(void); - -void func_80164EA4(void *a0) { - D_80188348[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801ABE04[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801ABE04[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801ABDF8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801ABDF8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801ABDF8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801ABDF8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801ABDF8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018835C[]; - extern u32 D_8018837C, D_80188380, D_80188384, D_80188388; - extern u32 D_8018837C, D_80188380, D_80188384, D_80188388; - extern u32 D_8018837C, D_80188380, D_80188384, D_80188388; - extern u32 D_8018837C, D_80188380, D_80188384, D_80188388; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018835C[0x00], p); - ApplyMatrixSV(mat, &D_8018835C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018835C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018835C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80188384; - *(u32 *)(prim + 0x24) = D_8018837C; - *(u32 *)(prim + 0x28) = D_80188388; - *(u32 *)(prim + 0x2c) = D_80188380; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018838C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018838C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018838C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018838C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80188408[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80188408[a1 & 0x7F]; -} - - - -extern s32 D_80188428[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80188428[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801884A4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801884A4[a1 & 0x7F]; -} - - - -extern u8 D_801884C4[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801884C4[a1 & 0x7F]; -} - - - -extern u8 D_801884E4[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801884E4[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80188504[])(void); - D_80188504[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80188580[])(void); - -void func_80165AC8(void) { - D_80188580[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801885FC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801885FC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801AB454; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801AB454, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80188608[])(void); - -void func_80166018(void *a0) { - D_80188608[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80188610[])(void); - -void func_801663FC(void *a0) { - D_80188610[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801886D8[])(void); - -void func_80166618(void *a0) { - D_801886D8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801886E8[])(void); - -void func_80166654(void *a0) { - D_801886E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801ABE78[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801ABE78[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801ABE78). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801ABE78[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801ABE78)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801ABE78[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801ABE78[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018862C[]; - extern u8 D_80188618[]; - extern u8 D_80188640[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018862C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80188618; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80188640; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80167714); - - -extern void (*D_801886F8[])(void); - -void func_801678B4(void *a0) { - D_801886F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80188704[])(void); - -void func_80167A9C(void *a0) { - D_80188704[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80188810; - extern u8 D_80188824[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80188810); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188824; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80188664[]; -extern u8 D_80188678[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80188664; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80188678; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018871C[])(void); - -void func_80168744(void *a0) { - D_8018871C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018870C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018870C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018870C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80188724[])(void); - -void func_801689D8(void *a0) { - D_80188724[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018872C[])(void); - -void func_80168AA8(void *a0) { - D_8018872C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80188734[])(void); - -void func_80168D58(void *a0) { - D_80188734[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018873C[])(void); - -void func_8016901C(void *a0) { - D_8018873C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015AE2C", func_80169228); - - -extern void (*D_80188744[])(void); - -void func_801693CC(void *a0) { - D_80188744[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018874C[])(void); - -void func_80169830(void *a0) { - D_8018874C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80188800[])(void); - -void func_80169B80(void *a0) { - D_80188800[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80188754[]; - extern u8 D_801887C4[]; - extern u8 D_801887F4[]; - extern u8 D_801AD008[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801887F4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80188754[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801AD008; - RotMatrixYXZ(rot, D_801AD008); - func_80048D9C(D_801AD008, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801887C4); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80188808[])(void); - -void func_80169F00(void *a0) { - D_80188808[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801887B8[]; -extern char D_80188778[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801887B8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188778); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80188840[])(void); - -void func_8016A020(void *a0) { - D_80188840[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80188810; - extern u8 D_80188824[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80188810); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188824; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018884C[])(void); - -void func_8016A700(void *a0) { - D_8018884C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80188894[])(void); - -void func_8016AB30(void *a0) { - D_80188894[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c b/src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c new file mode 100644 index 000000000..b12e2bc5e --- /dev/null +++ b/src/ov_SC03_112/ov_SC03_112_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80187C60; +extern u8 D_80187BD0; +extern u8 D_80187BAC; +extern u8 D_80187B88; +extern u8 D_80187C3C; +extern u8 D_80187C18; +extern u8 D_80187BF4; +extern u8 D_80187B64; +extern void func_80145934(void); +extern u8 D_80187CF0; +extern u8 D_80187CCC; +extern u8 D_80187CA8; +extern u8 D_80187C84; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801870E8[]; +extern unsigned char D_80187118[]; +extern unsigned char D_80187168[]; +extern unsigned char D_80187198[]; +extern unsigned char D_801871C8[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80187218[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801872E0[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80187368[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80187370; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801ABCA8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801ABCAC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801873A0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80187448[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018746C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018745C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80187480[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018748C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018749C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801874B4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801874A4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801874C8[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801874E4[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801874D4; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801874F8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018750C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80187520; +extern void (*D_80187548[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80187528; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80187594[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80187598[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801879FC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80187A0C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801ABCE0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80187A34[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80187A14; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80187A24; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80187A74[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80187A7C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80187A48; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80187A88[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80187A58; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801ABCE8; +extern s32 D_801ABCF4; +extern s32 D_801ABCF8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80187AC4[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80187A98[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801ABCF0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80187D14[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80187B34[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80187DB8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80187F0C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80187D28; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80187F14[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80187D38; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80187D58; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80187F1C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80187F44[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80187DC4[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80187F50[])(void); + +void func_8015C714(void *a0) { + D_80187F50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80187DC4[])(void*); + extern int D_80187D68; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80187DC4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80187DC4)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187D68); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80187DC4[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80187DC4[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80187DC4[])(void*); + extern int D_80187D68; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80187DC4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187D68); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80187DC4)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80187F60[])(void); + D_80187F60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80187DC4[])(struct Ent_8015CD20 *); + extern u8 D_80187D78; + extern u8 D_80187F68; + extern u8 D_80187F78; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80187DC4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187D78); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187F68); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187F78); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80187DC4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80187F98[])(void); + D_80187F98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80187F88; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80187F88 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80187DC4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80187FF4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80187FF4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801870D8[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801870D8; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80187FFC[])(void); + D_80187FFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80188008[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80188008[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80188008[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80188008[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80187DC4[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80188008[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80187D88[]; + extern u8 D_80187D98[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187D88); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187D98); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80188008[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80188008[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80188008[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018803C[])(void); + D_8018803C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187DC4[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188044[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018805C[])(void); + D_8018805C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187DC4[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188044[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188044[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018807C[])(void); + D_8018807C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80187DC4[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187DC4)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018808C; +extern u16 D_8018808E; +extern u16 D_80188090; +extern s32 D_80188094; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018808C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018808E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80188090 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188094, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018809C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018809C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80187DC4[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187DC4)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801880B0[])(void); + D_801880B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80187DC4[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80187DC4[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801880B8[])(void); + D_801880B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80187DA8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187DA8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80187DC4[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801880C0[])(void); + D_801880C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80187DC4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80187DC4[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801880C8[])(void); + D_801880C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80187DC4[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801880D0; + extern s32 D_801880E0; + extern s32 D_801880F0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801880D0); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801880E0); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80187DC4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801880F0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80188100[])(void); + D_80188100[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80187DC4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80187DC4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80187DC4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187DC4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018810C[])(void); + D_8018810C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80187DC4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187DC4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80187DC4[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187DC4[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80188120[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80188120[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80187DC4[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80187DC4)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80187DC4[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187DC4[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018819C[])(void); + D_8018819C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80187DC4[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80187DC4)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801881AC[])(void); + D_801881AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80187DC4[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80187DC4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80187DC4[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80187DC4[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80187DC4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80187DC4[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80187DC4[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801881B4[])(void); + D_801881B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80187DC4[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80187DC4)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80187DC4[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80187DC4)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801881C0[])(void); + D_801881C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187DC4 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80187DC4[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80187DC4[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80187DC4[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801881D0[])(void); + +void func_80160EA4(void *a0) { + D_801881D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80187DC4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80187DC4[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80188200[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80188200[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80188264; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80188264); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801ABD00[]; + extern u8 D_80188230[]; + extern u8 D_80188250[]; + extern u8 D_801ABD0C[]; + extern u8 D_801ABD34[]; + extern u8 D_801ABD4C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801ABD00[0] = p; + func_80024054(&D_80188230, &D_801ABD0C); + func_8001CE28(p, &D_801ABD0C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801ABD00[1] = p; + func_80024054(&D_80188250, &D_801ABD34); + func_8001CE28(p, &D_801ABD34); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801ABD00[2] = p; + func_800242D0((s16)func_801620C4(), &D_801ABD4C, 0x84); + func_8001CE68(p, &D_801ABD4C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801ABD4C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801ABD00[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801ABD00; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80188264; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80188264; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80188264; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80188264; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801ABD00[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801ABD00; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80188288[])(void); + +void func_80162330(void *a0) { + D_80188288[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801ABD58[i] via `extern int D_801ABD58[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80188294[]; + extern s32 D_801882AC; + extern u8 D_801ABD64[]; + extern u8 D_801ABD8C[]; + extern u8 D_801ABDA8[]; + extern int D_801ABD58[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801ABD58[0] = (s32)item; + func_80024054(D_80188294, D_801ABD64); + func_8001CE28(item, D_801ABD64); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801ABD58[1] = (s32)item; + func_80024054(((u8 *)&D_801882AC), D_801ABD8C); + func_8001CE28(item, D_801ABD8C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801ABD58[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801ABDA8, 0x84); + func_8001CE68(item, D_801ABDA8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801ABDA8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801ABD58[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801ABD58; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_801627E8); + + +extern void (*D_801882D0[])(void); + +void func_80162834(void *a0) { + D_801882D0[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801882C0; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801882C0, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801AB444[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801AB444, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801AB444[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801AB444, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801882D8[])(void); + +void func_80163A58(void *a0) { + D_801882D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801AB44C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801AB44C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018832C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018832C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801882F4; +extern s16 D_80188328; +extern s16 D_80188326; +extern s16 D_80188324; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801882F4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80188328 = 0x80; + D_80188326 = 0x80; + D_80188324 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80188328 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188328` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80188328 - 8; + D_80188328 = nv; + D_80188326 = nv; + D_80188324 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80188338[])(void); + +void func_80164BA0(void *a0) { + D_80188338[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801ABDB8; +extern u8 D_801ABDB9; +extern u8 D_801ABDBA; +extern u8 D_801ABDBB; +extern u8 D_801ABDBC; +extern u8 D_801ABDBD; +extern u8 D_801ABDBE; +extern u8 D_801ABDBF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801ABDB8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801ABDB9 = 0xf0; + *(u8 *)base = 0xf0; + D_801ABDBA = 0xc0; + D_801ABDBE = 0; + D_801ABDBD = 0; + D_801ABDBC = 0; + D_801ABDBF = 0; + D_801ABDBB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801ABDB8; +extern u8 D_801ABDB9; +extern u8 D_801ABDBA; + +s32 func_80164E40(void) { + u8 *p = &D_801ABDB8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801ABDB9 != 0) { + D_801ABDB9 -= 0x10; + } + if (D_801ABDBA != 0) { + D_801ABDBA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80188348[])(void); + +void func_80164EA4(void *a0) { + D_80188348[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801ABE04[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801ABE04[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801ABDF8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801ABDF8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801ABDF8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801ABDF8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801ABDF8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018835C[]; + extern u32 D_8018837C, D_80188380, D_80188384, D_80188388; + extern u32 D_8018837C, D_80188380, D_80188384, D_80188388; + extern u32 D_8018837C, D_80188380, D_80188384, D_80188388; + extern u32 D_8018837C, D_80188380, D_80188384, D_80188388; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018835C[0x00], p); + ApplyMatrixSV(mat, &D_8018835C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018835C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018835C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80188384; + *(u32 *)(prim + 0x24) = D_8018837C; + *(u32 *)(prim + 0x28) = D_80188388; + *(u32 *)(prim + 0x2c) = D_80188380; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018838C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018838C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018838C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018838C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80188408[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80188408[a1 & 0x7F]; +} + + + +extern s32 D_80188428[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80188428[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801884A4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801884A4[a1 & 0x7F]; +} + + + +extern u8 D_801884C4[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801884C4[a1 & 0x7F]; +} + + + +extern u8 D_801884E4[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801884E4[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80188504[])(void); + D_80188504[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80188580[])(void); + +void func_80165AC8(void) { + D_80188580[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801885FC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801885FC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801AB454; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801AB454, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80188608[])(void); + +void func_80166018(void *a0) { + D_80188608[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80188610[])(void); + +void func_801663FC(void *a0) { + D_80188610[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801886D8[])(void); + +void func_80166618(void *a0) { + D_801886D8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801886E8[])(void); + +void func_80166654(void *a0) { + D_801886E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801ABE78[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801ABE78[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801ABE78). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801ABE78[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801ABE78)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801ABE78[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801ABE78[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018862C[]; + extern u8 D_80188618[]; + extern u8 D_80188640[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018862C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80188618; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80188640; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80167714); + + +extern void (*D_801886F8[])(void); + +void func_801678B4(void *a0) { + D_801886F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80188704[])(void); + +void func_80167A9C(void *a0) { + D_80188704[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80188810; + extern u8 D_80188824[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80188810); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188824; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80188664[]; +extern u8 D_80188678[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80188664; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80188678; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018871C[])(void); + +void func_80168744(void *a0) { + D_8018871C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018870C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018870C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018870C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80188724[])(void); + +void func_801689D8(void *a0) { + D_80188724[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018872C[])(void); + +void func_80168AA8(void *a0) { + D_8018872C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80188734[])(void); + +void func_80168D58(void *a0) { + D_80188734[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018873C[])(void); + +void func_8016901C(void *a0) { + D_8018873C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_112/nonmatchings/ov_SC03_112_jr_8015C32C", func_80169228); + + +extern void (*D_80188744[])(void); + +void func_801693CC(void *a0) { + D_80188744[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018874C[])(void); + +void func_80169830(void *a0) { + D_8018874C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80188800[])(void); + +void func_80169B80(void *a0) { + D_80188800[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80188754[]; + extern u8 D_801887C4[]; + extern u8 D_801887F4[]; + extern u8 D_801AD008[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801887F4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80188754[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801AD008; + RotMatrixYXZ(rot, D_801AD008); + func_80048D9C(D_801AD008, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801887C4); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80188808[])(void); + +void func_80169F00(void *a0) { + D_80188808[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801887B8[]; +extern char D_80188778[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801887B8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188778); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80188840[])(void); + +void func_8016A020(void *a0) { + D_80188840[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80188810; + extern u8 D_80188824[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80188810); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188824; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018884C[])(void); + +void func_8016A700(void *a0) { + D_8018884C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80188894[])(void); + +void func_8016AB30(void *a0) { + D_80188894[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_113/ov_SC03_113_jr_8015AE2C.c b/src/ov_SC03_113/ov_SC03_113_jr_8015AE2C.c index 2e93fa555..a3e970af4 100644 --- a/src/ov_SC03_113/ov_SC03_113_jr_8015AE2C.c +++ b/src/ov_SC03_113/ov_SC03_113_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80185600[])(void); - -void func_8015C714(void *a0) { - D_80185600[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80185474[])(void*); - extern int D_80185418; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80185474)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80185474)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185418); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80185474[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80185474[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80185474[])(void*); - extern int D_80185418; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80185474)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185418); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80185474)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80185610[])(void); - D_80185610[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80185474[])(struct Ent_8015CD20 *); - extern u8 D_80185428; - extern u8 D_80185618; - extern u8 D_80185628; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80185474[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185428); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185618); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185628); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80185474[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80185648[])(void); - D_80185648[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80185638; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80185638 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80185474[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801856A4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801856A4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80184788[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80184788; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801856AC[])(void); - D_801856AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801856B8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801856B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801856B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801856B8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80185474[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801856B8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80185438[]; - extern u8 D_80185448[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185438); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185448); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801856B8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801856B8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801856B8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801856EC[])(void); - D_801856EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185474[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801856F4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018570C[])(void); - D_8018570C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185474[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801856F4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018572C[])(void); - D_8018572C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80185474[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185474)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018573C; -extern u16 D_8018573E; -extern u16 D_80185740; -extern s32 D_80185744; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018573C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018573E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80185740 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185744, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018574C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018574C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80185474[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185474)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80185760[])(void); - D_80185760[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80185474[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80185474[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80185768[])(void); - D_80185768[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80185458; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185458); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80185474[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80185770[])(void); - D_80185770[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80185474[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80185474[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80185778[])(void); - D_80185778[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80185474[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80185780; - extern s32 D_80185790; - extern s32 D_801857A0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80185474[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185780); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185790); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80185474[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801857A0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801857B0[])(void); - D_801857B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80185474[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80185474[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80185474[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185474[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801857BC[])(void); - D_801857BC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80185474[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185474[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80185474[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185474[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801857D0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801857D0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80185474[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80185474)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80185474[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185474[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018584C[])(void); - D_8018584C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80185474[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80185474)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018585C[])(void); - D_8018585C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80185474[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80185474[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80185474[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80185474[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80185474[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80185474[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80185474[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80185864[])(void); - D_80185864[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80185474[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80185474)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80185474[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80185474)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80185870[])(void); - D_80185870[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185474 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80185474[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80185474[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80185474[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80185880[])(void); - -void func_80160EA4(void *a0) { - D_80185880[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80185474[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80185474[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801858B0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801858B0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80185914; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80185914); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A4890[]; - extern u8 D_801858E0[]; - extern u8 D_80185900[]; - extern u8 D_801A489C[]; - extern u8 D_801A48C4[]; - extern u8 D_801A48DC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A4890[0] = p; - func_80024054(&D_801858E0, &D_801A489C); - func_8001CE28(p, &D_801A489C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A4890[1] = p; - func_80024054(&D_80185900, &D_801A48C4); - func_8001CE28(p, &D_801A48C4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A4890[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A48DC, 0x84); - func_8001CE68(p, &D_801A48DC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A48DC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A4890[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A4890; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80185914; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80185914; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80185914; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80185914; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A4890[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A4890; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80185938[])(void); - -void func_80162330(void *a0) { - D_80185938[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A48E8[i] via `extern int D_801A48E8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80185944[]; - extern s32 D_8018595C; - extern u8 D_801A48F4[]; - extern u8 D_801A491C[]; - extern u8 D_801A4938[]; - extern int D_801A48E8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A48E8[0] = (s32)item; - func_80024054(D_80185944, D_801A48F4); - func_8001CE28(item, D_801A48F4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A48E8[1] = (s32)item; - func_80024054(((u8 *)&D_8018595C), D_801A491C); - func_8001CE28(item, D_801A491C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A48E8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A4938, 0x84); - func_8001CE68(item, D_801A4938); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A4938, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A48E8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A48E8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_801627E8); - - -extern void (*D_80185980[])(void); - -void func_80162834(void *a0) { - D_80185980[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80185970; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80185970, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801A40CC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801A40CC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801A40CC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801A40CC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80185988[])(void); - -void func_80163A58(void *a0) { - D_80185988[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801A40D4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801A40D4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801859DC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801859DC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801859A4; -extern s16 D_801859D8; -extern s16 D_801859D6; -extern s16 D_801859D4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801859A4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801859D8 = 0x80; - D_801859D6 = 0x80; - D_801859D4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801859D8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801859D8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801859D8 - 8; - D_801859D8 = nv; - D_801859D6 = nv; - D_801859D4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801859E8[])(void); - -void func_80164BA0(void *a0) { - D_801859E8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A4948; -extern u8 D_801A4949; -extern u8 D_801A494A; -extern u8 D_801A494B; -extern u8 D_801A494C; -extern u8 D_801A494D; -extern u8 D_801A494E; -extern u8 D_801A494F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A4948; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A4949 = 0xf0; - *(u8 *)base = 0xf0; - D_801A494A = 0xc0; - D_801A494E = 0; - D_801A494D = 0; - D_801A494C = 0; - D_801A494F = 0; - D_801A494B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A4948; -extern u8 D_801A4949; -extern u8 D_801A494A; - -s32 func_80164E40(void) { - u8 *p = &D_801A4948; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A4949 != 0) { - D_801A4949 -= 0x10; - } - if (D_801A494A != 0) { - D_801A494A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801859F8[])(void); - -void func_80164EA4(void *a0) { - D_801859F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A4994[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A4994[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A4988[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A4988[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A4988[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A4988; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A4988; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80185A0C[]; - extern u32 D_80185A2C, D_80185A30, D_80185A34, D_80185A38; - extern u32 D_80185A2C, D_80185A30, D_80185A34, D_80185A38; - extern u32 D_80185A2C, D_80185A30, D_80185A34, D_80185A38; - extern u32 D_80185A2C, D_80185A30, D_80185A34, D_80185A38; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80185A0C[0x00], p); - ApplyMatrixSV(mat, &D_80185A0C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80185A0C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80185A0C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80185A34; - *(u32 *)(prim + 0x24) = D_80185A2C; - *(u32 *)(prim + 0x28) = D_80185A38; - *(u32 *)(prim + 0x2c) = D_80185A30; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80185A3C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80185A3C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80185A3C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80185A3C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80185AB8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80185AB8[a1 & 0x7F]; -} - - - -extern s32 D_80185AD8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80185AD8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80185B54[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80185B54[a1 & 0x7F]; -} - - - -extern u8 D_80185B74[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80185B74[a1 & 0x7F]; -} - - - -extern u8 D_80185B94[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80185B94[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80185BB4[])(void); - D_80185BB4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80185C30[])(void); - -void func_80165AC8(void) { - D_80185C30[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80185CAC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80185CAC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801A40DC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801A40DC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80185CB8[])(void); - -void func_80166018(void *a0) { - D_80185CB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80185CC0[])(void); - -void func_801663FC(void *a0) { - D_80185CC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80185D88[])(void); - -void func_80166618(void *a0) { - D_80185D88[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80185D98[])(void); - -void func_80166654(void *a0) { - D_80185D98[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A4A08[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A4A08[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A4A08). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A4A08[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A4A08)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A4A08[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A4A08[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80185CDC[]; - extern u8 D_80185CC8[]; - extern u8 D_80185CF0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80185CDC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80185CC8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80185CF0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80167714); - - -extern void (*D_80185DA8[])(void); - -void func_801678B4(void *a0) { - D_80185DA8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80185DB4[])(void); - -void func_80167A9C(void *a0) { - D_80185DB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80185EC0; - extern u8 D_80185ED4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80185EC0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185ED4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80185D14[]; -extern u8 D_80185D28[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80185D14; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80185D28; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80185DCC[])(void); - -void func_80168744(void *a0) { - D_80185DCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80185DBC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80185DBC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80185DBC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80185DD4[])(void); - -void func_801689D8(void *a0) { - D_80185DD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80185DDC[])(void); - -void func_80168AA8(void *a0) { - D_80185DDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80185DE4[])(void); - -void func_80168D58(void *a0) { - D_80185DE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80185DEC[])(void); - -void func_8016901C(void *a0) { - D_80185DEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015AE2C", func_80169228); - - -extern void (*D_80185DF4[])(void); - -void func_801693CC(void *a0) { - D_80185DF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80185DFC[])(void); - -void func_80169830(void *a0) { - D_80185DFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80185EB0[])(void); - -void func_80169B80(void *a0) { - D_80185EB0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80185E04[]; - extern u8 D_80185E74[]; - extern u8 D_80185EA4[]; - extern u8 D_801A5BA8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80185EA4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80185E04[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A5BA8; - RotMatrixYXZ(rot, D_801A5BA8); - func_80048D9C(D_801A5BA8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80185E74); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80185EB8[])(void); - -void func_80169F00(void *a0) { - D_80185EB8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80185E68[]; -extern char D_80185E28[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80185E68, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80185E28); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80185EF0[])(void); - -void func_8016A020(void *a0) { - D_80185EF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80185EC0; - extern u8 D_80185ED4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80185EC0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185ED4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80185EFC[])(void); - -void func_8016A700(void *a0) { - D_80185EFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80185F44[])(void); - -void func_8016AB30(void *a0) { - D_80185F44[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c b/src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c new file mode 100644 index 000000000..b5e520907 --- /dev/null +++ b/src/ov_SC03_113/ov_SC03_113_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80185310; +extern u8 D_80185280; +extern u8 D_8018525C; +extern u8 D_80185238; +extern u8 D_801852EC; +extern u8 D_801852C8; +extern u8 D_801852A4; +extern u8 D_80185214; +extern void func_80145934(void); +extern u8 D_801853A0; +extern u8 D_8018537C; +extern u8 D_80185358; +extern u8 D_80185334; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80184798[]; +extern unsigned char D_801847C8[]; +extern unsigned char D_80184818[]; +extern unsigned char D_80184848[]; +extern unsigned char D_80184878[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801848C8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80184990[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80184A18[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80184A20; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A4838; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A483C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80184A50; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80184AF8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80184B1C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80184B0C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80184B30[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80184B3C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80184B4C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80184B64[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80184B54; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80184B78[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80184B94[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80184B84; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80184BA8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80184BBC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80184BD0; +extern void (*D_80184BF8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80184BD8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80184C44[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80184C48[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801850AC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801850BC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A4870; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801850E4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801850C4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801850D4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80185124[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018512C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801850F8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80185138[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80185108; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A4878; +extern s32 D_801A4884; +extern s32 D_801A4888; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80185174[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80185148[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A4880; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801853C4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801851E4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80185468[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801855BC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801853D8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801855C4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801853E8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80185408; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801855CC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801855F4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80185474[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80185474[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80185474[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80185474[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80185474[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80185474[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80185474[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80185474[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80185600[])(void); + +void func_8015C714(void *a0) { + D_80185600[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80185474[])(void*); + extern int D_80185418; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80185474)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80185474)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185418); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80185474[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80185474[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80185474[])(void*); + extern int D_80185418; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80185474)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80185418); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80185474)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80185610[])(void); + D_80185610[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80185474[])(struct Ent_8015CD20 *); + extern u8 D_80185428; + extern u8 D_80185618; + extern u8 D_80185628; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80185474[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185428); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185618); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185628); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80185474[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80185648[])(void); + D_80185648[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80185638; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80185638 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80185474[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801856A4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801856A4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80184788[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80184788; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801856AC[])(void); + D_801856AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801856B8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801856B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801856B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801856B8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80185474[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801856B8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80185438[]; + extern u8 D_80185448[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185438); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185448); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801856B8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801856B8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801856B8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801856EC[])(void); + D_801856EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185474[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801856F4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018570C[])(void); + D_8018570C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185474[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801856F4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801856F4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018572C[])(void); + D_8018572C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80185474[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185474)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018573C; +extern u16 D_8018573E; +extern u16 D_80185740; +extern s32 D_80185744; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018573C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018573E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80185740 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185744, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018574C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018574C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80185474[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185474)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80185760[])(void); + D_80185760[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80185474[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80185474[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80185768[])(void); + D_80185768[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80185458; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185458); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80185474[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80185770[])(void); + D_80185770[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80185474[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80185474[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80185778[])(void); + D_80185778[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80185474[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80185780; + extern s32 D_80185790; + extern s32 D_801857A0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80185474[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185780); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185790); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80185474[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801857A0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801857B0[])(void); + D_801857B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80185474[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80185474[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80185474[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185474[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801857BC[])(void); + D_801857BC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80185474[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185474[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80185474[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185474[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801857D0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801857D0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80185474[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80185474)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80185474[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185474[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018584C[])(void); + D_8018584C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80185474[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80185474)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018585C[])(void); + D_8018585C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80185474[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80185474[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80185474[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80185474[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80185474[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80185474[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80185474[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80185864[])(void); + D_80185864[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80185474[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80185474)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80185474[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80185474)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80185870[])(void); + D_80185870[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185474 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80185474[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80185474[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80185474[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80185880[])(void); + +void func_80160EA4(void *a0) { + D_80185880[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80185474[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80185474[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801858B0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801858B0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80185914; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80185914); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A4890[]; + extern u8 D_801858E0[]; + extern u8 D_80185900[]; + extern u8 D_801A489C[]; + extern u8 D_801A48C4[]; + extern u8 D_801A48DC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A4890[0] = p; + func_80024054(&D_801858E0, &D_801A489C); + func_8001CE28(p, &D_801A489C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A4890[1] = p; + func_80024054(&D_80185900, &D_801A48C4); + func_8001CE28(p, &D_801A48C4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A4890[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A48DC, 0x84); + func_8001CE68(p, &D_801A48DC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A48DC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A4890[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A4890; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80185914; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80185914; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80185914; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80185914; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A4890[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A4890; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80185938[])(void); + +void func_80162330(void *a0) { + D_80185938[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A48E8[i] via `extern int D_801A48E8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80185944[]; + extern s32 D_8018595C; + extern u8 D_801A48F4[]; + extern u8 D_801A491C[]; + extern u8 D_801A4938[]; + extern int D_801A48E8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A48E8[0] = (s32)item; + func_80024054(D_80185944, D_801A48F4); + func_8001CE28(item, D_801A48F4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A48E8[1] = (s32)item; + func_80024054(((u8 *)&D_8018595C), D_801A491C); + func_8001CE28(item, D_801A491C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A48E8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A4938, 0x84); + func_8001CE68(item, D_801A4938); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A4938, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A48E8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A48E8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_801627E8); + + +extern void (*D_80185980[])(void); + +void func_80162834(void *a0) { + D_80185980[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80185970; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80185970, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801A40CC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801A40CC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801A40CC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801A40CC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80185988[])(void); + +void func_80163A58(void *a0) { + D_80185988[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801A40D4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801A40D4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801859DC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801859DC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801859A4; +extern s16 D_801859D8; +extern s16 D_801859D6; +extern s16 D_801859D4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801859A4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801859D8 = 0x80; + D_801859D6 = 0x80; + D_801859D4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801859D8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801859D8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801859D8 - 8; + D_801859D8 = nv; + D_801859D6 = nv; + D_801859D4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801859E8[])(void); + +void func_80164BA0(void *a0) { + D_801859E8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A4948; +extern u8 D_801A4949; +extern u8 D_801A494A; +extern u8 D_801A494B; +extern u8 D_801A494C; +extern u8 D_801A494D; +extern u8 D_801A494E; +extern u8 D_801A494F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A4948; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A4949 = 0xf0; + *(u8 *)base = 0xf0; + D_801A494A = 0xc0; + D_801A494E = 0; + D_801A494D = 0; + D_801A494C = 0; + D_801A494F = 0; + D_801A494B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A4948; +extern u8 D_801A4949; +extern u8 D_801A494A; + +s32 func_80164E40(void) { + u8 *p = &D_801A4948; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A4949 != 0) { + D_801A4949 -= 0x10; + } + if (D_801A494A != 0) { + D_801A494A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801859F8[])(void); + +void func_80164EA4(void *a0) { + D_801859F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A4994[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A4994[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A4988[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A4988[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A4988[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A4988; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A4988; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80185A0C[]; + extern u32 D_80185A2C, D_80185A30, D_80185A34, D_80185A38; + extern u32 D_80185A2C, D_80185A30, D_80185A34, D_80185A38; + extern u32 D_80185A2C, D_80185A30, D_80185A34, D_80185A38; + extern u32 D_80185A2C, D_80185A30, D_80185A34, D_80185A38; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80185A0C[0x00], p); + ApplyMatrixSV(mat, &D_80185A0C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80185A0C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80185A0C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80185A34; + *(u32 *)(prim + 0x24) = D_80185A2C; + *(u32 *)(prim + 0x28) = D_80185A38; + *(u32 *)(prim + 0x2c) = D_80185A30; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80185A3C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80185A3C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80185A3C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80185A3C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80185AB8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80185AB8[a1 & 0x7F]; +} + + + +extern s32 D_80185AD8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80185AD8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80185B54[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80185B54[a1 & 0x7F]; +} + + + +extern u8 D_80185B74[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80185B74[a1 & 0x7F]; +} + + + +extern u8 D_80185B94[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80185B94[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80185BB4[])(void); + D_80185BB4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80185C30[])(void); + +void func_80165AC8(void) { + D_80185C30[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80185CAC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80185CAC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801A40DC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801A40DC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80185CB8[])(void); + +void func_80166018(void *a0) { + D_80185CB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80185CC0[])(void); + +void func_801663FC(void *a0) { + D_80185CC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80185D88[])(void); + +void func_80166618(void *a0) { + D_80185D88[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80185D98[])(void); + +void func_80166654(void *a0) { + D_80185D98[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A4A08[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A4A08[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A4A08). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A4A08[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A4A08)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A4A08[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A4A08[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80185CDC[]; + extern u8 D_80185CC8[]; + extern u8 D_80185CF0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80185CDC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80185CC8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80185CF0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80167714); + + +extern void (*D_80185DA8[])(void); + +void func_801678B4(void *a0) { + D_80185DA8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80185DB4[])(void); + +void func_80167A9C(void *a0) { + D_80185DB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80185EC0; + extern u8 D_80185ED4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80185EC0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185ED4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80185D14[]; +extern u8 D_80185D28[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80185D14; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80185D28; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80185DCC[])(void); + +void func_80168744(void *a0) { + D_80185DCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80185DBC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80185DBC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80185DBC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80185DD4[])(void); + +void func_801689D8(void *a0) { + D_80185DD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80185DDC[])(void); + +void func_80168AA8(void *a0) { + D_80185DDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80185DE4[])(void); + +void func_80168D58(void *a0) { + D_80185DE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80185DEC[])(void); + +void func_8016901C(void *a0) { + D_80185DEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_113/nonmatchings/ov_SC03_113_jr_8015C32C", func_80169228); + + +extern void (*D_80185DF4[])(void); + +void func_801693CC(void *a0) { + D_80185DF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80185DFC[])(void); + +void func_80169830(void *a0) { + D_80185DFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80185EB0[])(void); + +void func_80169B80(void *a0) { + D_80185EB0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80185E04[]; + extern u8 D_80185E74[]; + extern u8 D_80185EA4[]; + extern u8 D_801A5BA8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80185EA4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80185E04[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A5BA8; + RotMatrixYXZ(rot, D_801A5BA8); + func_80048D9C(D_801A5BA8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80185E74); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80185EB8[])(void); + +void func_80169F00(void *a0) { + D_80185EB8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80185E68[]; +extern char D_80185E28[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80185E68, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80185E28); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80185EF0[])(void); + +void func_8016A020(void *a0) { + D_80185EF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80185EC0; + extern u8 D_80185ED4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80185EC0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185ED4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80185EFC[])(void); + +void func_8016A700(void *a0) { + D_80185EFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80185F44[])(void); + +void func_8016AB30(void *a0) { + D_80185F44[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_114/ov_SC03_114_jr_8015AE2C.c b/src/ov_SC03_114/ov_SC03_114_jr_8015AE2C.c index 523807471..557291bb1 100644 --- a/src/ov_SC03_114/ov_SC03_114_jr_8015AE2C.c +++ b/src/ov_SC03_114/ov_SC03_114_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181268[])(void); - -void func_8015C714(void *a0) { - D_80181268[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801810DC[])(void*); - extern int D_80181080; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801810DC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801810DC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181080); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801810DC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801810DC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801810DC[])(void*); - extern int D_80181080; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801810DC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181080); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801810DC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181278[])(void); - D_80181278[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801810DC[])(struct Ent_8015CD20 *); - extern u8 D_80181090; - extern u8 D_80181280; - extern u8 D_80181290; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801810DC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181090); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181280); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181290); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801810DC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801812B0[])(void); - D_801812B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801812A0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801812A0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801810DC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018130C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018130C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801803F0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801803F0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80181314[])(void); - D_80181314[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80181320[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80181320[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80181320[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80181320[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801810DC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80181320[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801810A0[]; - extern u8 D_801810B0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801810A0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801810B0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80181320[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181320[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181320[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80181354[])(void); - D_80181354[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801810DC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018135C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181374[])(void); - D_80181374[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801810DC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018135C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181394[])(void); - D_80181394[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801810DC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801810DC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801813A4; -extern u16 D_801813A6; -extern u16 D_801813A8; -extern s32 D_801813AC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801813A4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801813A6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801813A8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801813AC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801813B4; - -void func_8015E588(void) { - func_8013C9C4(&D_801813B4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801810DC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801810DC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801813C8[])(void); - D_801813C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801810DC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801810DC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801813D0[])(void); - D_801813D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801810C0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801810C0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801810DC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801813D8[])(void); - D_801813D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801810DC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801810DC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801813E0[])(void); - D_801813E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801810DC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801813E8; - extern s32 D_801813F8; - extern s32 D_80181408; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801810DC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801813E8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801813F8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801810DC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181408); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80181418[])(void); - D_80181418[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801810DC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801810DC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801810DC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801810DC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80181424[])(void); - D_80181424[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801810DC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801810DC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801810DC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801810DC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80181438[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80181438[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801810DC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801810DC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801810DC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801810DC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801814B4[])(void); - D_801814B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801810DC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801810DC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801814C4[])(void); - D_801814C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801810DC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801810DC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801810DC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801810DC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801810DC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801810DC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801810DC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801814CC[])(void); - D_801814CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801810DC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801810DC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801810DC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801810DC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801814D8[])(void); - D_801814D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801810DC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801810DC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801810DC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801810DC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801814E8[])(void); - -void func_80160EA4(void *a0) { - D_801814E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801810DC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801810DC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80181518[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80181518[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018157C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018157C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A8528[]; - extern u8 D_80181548[]; - extern u8 D_80181568[]; - extern u8 D_801A8534[]; - extern u8 D_801A855C[]; - extern u8 D_801A8574[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A8528[0] = p; - func_80024054(&D_80181548, &D_801A8534); - func_8001CE28(p, &D_801A8534); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A8528[1] = p; - func_80024054(&D_80181568, &D_801A855C); - func_8001CE28(p, &D_801A855C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A8528[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A8574, 0x84); - func_8001CE68(p, &D_801A8574); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A8574, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A8528[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A8528; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018157C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018157C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018157C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018157C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A8528[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A8528; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801815A0[])(void); - -void func_80162330(void *a0) { - D_801815A0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A8580[i] via `extern int D_801A8580[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801815AC[]; - extern s32 D_801815C4; - extern u8 D_801A858C[]; - extern u8 D_801A85B4[]; - extern u8 D_801A85D0[]; - extern int D_801A8580[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A8580[0] = (s32)item; - func_80024054(D_801815AC, D_801A858C); - func_8001CE28(item, D_801A858C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A8580[1] = (s32)item; - func_80024054(((u8 *)&D_801815C4), D_801A85B4); - func_8001CE28(item, D_801A85B4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A8580[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A85D0, 0x84); - func_8001CE68(item, D_801A85D0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A85D0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A8580[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A8580; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_801627E8); - - -extern void (*D_801815E8[])(void); - -void func_80162834(void *a0) { - D_801815E8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801815D8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801815D8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801A7DD8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801A7DD8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801A7DD8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801A7DD8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801815F0[])(void); - -void func_80163A58(void *a0) { - D_801815F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801A7DE0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801A7DE0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80181644[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80181644[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018160C; -extern s16 D_80181640; -extern s16 D_8018163E; -extern s16 D_8018163C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018160C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181640 = 0x80; - D_8018163E = 0x80; - D_8018163C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181640 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181640` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181640 - 8; - D_80181640 = nv; - D_8018163E = nv; - D_8018163C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181650[])(void); - -void func_80164BA0(void *a0) { - D_80181650[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A85E0; -extern u8 D_801A85E1; -extern u8 D_801A85E2; -extern u8 D_801A85E3; -extern u8 D_801A85E4; -extern u8 D_801A85E5; -extern u8 D_801A85E6; -extern u8 D_801A85E7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A85E0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A85E1 = 0xf0; - *(u8 *)base = 0xf0; - D_801A85E2 = 0xc0; - D_801A85E6 = 0; - D_801A85E5 = 0; - D_801A85E4 = 0; - D_801A85E7 = 0; - D_801A85E3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A85E0; -extern u8 D_801A85E1; -extern u8 D_801A85E2; - -s32 func_80164E40(void) { - u8 *p = &D_801A85E0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A85E1 != 0) { - D_801A85E1 -= 0x10; - } - if (D_801A85E2 != 0) { - D_801A85E2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181660[])(void); - -void func_80164EA4(void *a0) { - D_80181660[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A862C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A862C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A8620[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A8620[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A8620[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A8620; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A8620; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181674[]; - extern u32 D_80181694, D_80181698, D_8018169C, D_801816A0; - extern u32 D_80181694, D_80181698, D_8018169C, D_801816A0; - extern u32 D_80181694, D_80181698, D_8018169C, D_801816A0; - extern u32 D_80181694, D_80181698, D_8018169C, D_801816A0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181674[0x00], p); - ApplyMatrixSV(mat, &D_80181674[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181674[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181674[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018169C; - *(u32 *)(prim + 0x24) = D_80181694; - *(u32 *)(prim + 0x28) = D_801816A0; - *(u32 *)(prim + 0x2c) = D_80181698; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801816A4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801816A4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801816A4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801816A4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80181720[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80181720[a1 & 0x7F]; -} - - - -extern s32 D_80181740[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181740[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801817BC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801817BC[a1 & 0x7F]; -} - - - -extern u8 D_801817DC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801817DC[a1 & 0x7F]; -} - - - -extern u8 D_801817FC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801817FC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018181C[])(void); - D_8018181C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80181898[])(void); - -void func_80165AC8(void) { - D_80181898[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181914[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181914[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801A7DE8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801A7DE8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80181920[])(void); - -void func_80166018(void *a0) { - D_80181920[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181928[])(void); - -void func_801663FC(void *a0) { - D_80181928[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801819F0[])(void); - -void func_80166618(void *a0) { - D_801819F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181A00[])(void); - -void func_80166654(void *a0) { - D_80181A00[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A86A0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A86A0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A86A0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A86A0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A86A0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A86A0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A86A0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80181944[]; - extern u8 D_80181930[]; - extern u8 D_80181958[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80181944; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80181930; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80181958; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80167714); - - -extern void (*D_80181A10[])(void); - -void func_801678B4(void *a0) { - D_80181A10[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181A1C[])(void); - -void func_80167A9C(void *a0) { - D_80181A1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181B28; - extern u8 D_80181B3C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181B28); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181B3C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018197C[]; -extern u8 D_80181990[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018197C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181990; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181A34[])(void); - -void func_80168744(void *a0) { - D_80181A34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181A24 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181A24[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181A24; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181A3C[])(void); - -void func_801689D8(void *a0) { - D_80181A3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181A44[])(void); - -void func_80168AA8(void *a0) { - D_80181A44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181A4C[])(void); - -void func_80168D58(void *a0) { - D_80181A4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181A54[])(void); - -void func_8016901C(void *a0) { - D_80181A54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015AE2C", func_80169228); - - -extern void (*D_80181A5C[])(void); - -void func_801693CC(void *a0) { - D_80181A5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181A64[])(void); - -void func_80169830(void *a0) { - D_80181A64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181B18[])(void); - -void func_80169B80(void *a0) { - D_80181B18[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181A6C[]; - extern u8 D_80181ADC[]; - extern u8 D_80181B0C[]; - extern u8 D_801A9720[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181B0C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181A6C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A9720; - RotMatrixYXZ(rot, D_801A9720); - func_80048D9C(D_801A9720, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181ADC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181B20[])(void); - -void func_80169F00(void *a0) { - D_80181B20[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80181AD0[]; -extern char D_80181A90[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80181AD0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181A90); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181B58[])(void); - -void func_8016A020(void *a0) { - D_80181B58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181B28; - extern u8 D_80181B3C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181B28); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181B3C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181B64[])(void); - -void func_8016A700(void *a0) { - D_80181B64[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80181BAC[])(void); - -void func_8016AB30(void *a0) { - D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c b/src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c new file mode 100644 index 000000000..bfb046993 --- /dev/null +++ b/src/ov_SC03_114/ov_SC03_114_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180F78; +extern u8 D_80180EE8; +extern u8 D_80180EC4; +extern u8 D_80180EA0; +extern u8 D_80180F54; +extern u8 D_80180F30; +extern u8 D_80180F0C; +extern u8 D_80180E7C; +extern void func_80145934(void); +extern u8 D_80181008; +extern u8 D_80180FE4; +extern u8 D_80180FC0; +extern u8 D_80180F9C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180400[]; +extern unsigned char D_80180430[]; +extern unsigned char D_80180480[]; +extern unsigned char D_801804B0[]; +extern unsigned char D_801804E0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80180530[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801805F8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180680[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180688; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A84D0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A84D4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801806B8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180760[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180784[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180774; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180798[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801807A4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801807B4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801807CC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801807BC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801807E0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801807FC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801807EC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80180810[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80180824[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80180838; +extern void (*D_80180860[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80180840; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801808AC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801808B0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180D14[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180D24[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A8508; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180D4C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180D2C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180D3C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180D8C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180D94[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180D60; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80180DA0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180D70; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A8510; +extern s32 D_801A851C; +extern s32 D_801A8520; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180DDC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80180DB0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A8518; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018102C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180E4C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801810D0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80181224[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80181040; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018122C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80181050; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80181070; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80181234[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018125C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801810DC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181268[])(void); + +void func_8015C714(void *a0) { + D_80181268[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801810DC[])(void*); + extern int D_80181080; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801810DC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801810DC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181080); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801810DC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801810DC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801810DC[])(void*); + extern int D_80181080; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801810DC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181080); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801810DC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181278[])(void); + D_80181278[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801810DC[])(struct Ent_8015CD20 *); + extern u8 D_80181090; + extern u8 D_80181280; + extern u8 D_80181290; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801810DC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181090); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181280); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181290); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801810DC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801812B0[])(void); + D_801812B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801812A0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801812A0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801810DC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018130C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018130C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801803F0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801803F0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80181314[])(void); + D_80181314[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80181320[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80181320[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80181320[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80181320[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801810DC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80181320[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801810A0[]; + extern u8 D_801810B0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801810A0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801810B0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80181320[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181320[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181320[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80181354[])(void); + D_80181354[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801810DC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018135C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181374[])(void); + D_80181374[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801810DC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018135C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018135C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181394[])(void); + D_80181394[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801810DC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801810DC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801813A4; +extern u16 D_801813A6; +extern u16 D_801813A8; +extern s32 D_801813AC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801813A4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801813A6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801813A8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801813AC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801813B4; + +void func_8015E588(void) { + func_8013C9C4(&D_801813B4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801810DC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801810DC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801813C8[])(void); + D_801813C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801810DC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801810DC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801813D0[])(void); + D_801813D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801810C0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801810C0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801810DC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801813D8[])(void); + D_801813D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801810DC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801810DC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801813E0[])(void); + D_801813E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801810DC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801813E8; + extern s32 D_801813F8; + extern s32 D_80181408; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801813E8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801813F8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801810DC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181408); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80181418[])(void); + D_80181418[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801810DC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801810DC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801810DC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801810DC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80181424[])(void); + D_80181424[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801810DC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801810DC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801810DC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801810DC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80181438[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80181438[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801810DC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801810DC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801810DC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801810DC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801814B4[])(void); + D_801814B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801810DC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801810DC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801814C4[])(void); + D_801814C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801810DC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801810DC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801810DC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801810DC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801810DC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801810DC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801810DC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801814CC[])(void); + D_801814CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801810DC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801810DC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801810DC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801810DC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801814D8[])(void); + D_801814D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801810DC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801810DC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801810DC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801810DC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801814E8[])(void); + +void func_80160EA4(void *a0) { + D_801814E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801810DC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801810DC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80181518[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80181518[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018157C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018157C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A8528[]; + extern u8 D_80181548[]; + extern u8 D_80181568[]; + extern u8 D_801A8534[]; + extern u8 D_801A855C[]; + extern u8 D_801A8574[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A8528[0] = p; + func_80024054(&D_80181548, &D_801A8534); + func_8001CE28(p, &D_801A8534); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A8528[1] = p; + func_80024054(&D_80181568, &D_801A855C); + func_8001CE28(p, &D_801A855C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A8528[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A8574, 0x84); + func_8001CE68(p, &D_801A8574); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A8574, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A8528[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A8528; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018157C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018157C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018157C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018157C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A8528[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A8528; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801815A0[])(void); + +void func_80162330(void *a0) { + D_801815A0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A8580[i] via `extern int D_801A8580[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801815AC[]; + extern s32 D_801815C4; + extern u8 D_801A858C[]; + extern u8 D_801A85B4[]; + extern u8 D_801A85D0[]; + extern int D_801A8580[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A8580[0] = (s32)item; + func_80024054(D_801815AC, D_801A858C); + func_8001CE28(item, D_801A858C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A8580[1] = (s32)item; + func_80024054(((u8 *)&D_801815C4), D_801A85B4); + func_8001CE28(item, D_801A85B4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A8580[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A85D0, 0x84); + func_8001CE68(item, D_801A85D0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A85D0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A8580[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A8580; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_801627E8); + + +extern void (*D_801815E8[])(void); + +void func_80162834(void *a0) { + D_801815E8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801815D8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801815D8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801A7DD8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801A7DD8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801A7DD8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801A7DD8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801815F0[])(void); + +void func_80163A58(void *a0) { + D_801815F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801A7DE0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801A7DE0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80181644[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80181644[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018160C; +extern s16 D_80181640; +extern s16 D_8018163E; +extern s16 D_8018163C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018160C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181640 = 0x80; + D_8018163E = 0x80; + D_8018163C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181640 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181640` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181640 - 8; + D_80181640 = nv; + D_8018163E = nv; + D_8018163C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181650[])(void); + +void func_80164BA0(void *a0) { + D_80181650[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A85E0; +extern u8 D_801A85E1; +extern u8 D_801A85E2; +extern u8 D_801A85E3; +extern u8 D_801A85E4; +extern u8 D_801A85E5; +extern u8 D_801A85E6; +extern u8 D_801A85E7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A85E0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A85E1 = 0xf0; + *(u8 *)base = 0xf0; + D_801A85E2 = 0xc0; + D_801A85E6 = 0; + D_801A85E5 = 0; + D_801A85E4 = 0; + D_801A85E7 = 0; + D_801A85E3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A85E0; +extern u8 D_801A85E1; +extern u8 D_801A85E2; + +s32 func_80164E40(void) { + u8 *p = &D_801A85E0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A85E1 != 0) { + D_801A85E1 -= 0x10; + } + if (D_801A85E2 != 0) { + D_801A85E2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181660[])(void); + +void func_80164EA4(void *a0) { + D_80181660[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A862C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A862C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A8620[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A8620[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A8620[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A8620; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A8620; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181674[]; + extern u32 D_80181694, D_80181698, D_8018169C, D_801816A0; + extern u32 D_80181694, D_80181698, D_8018169C, D_801816A0; + extern u32 D_80181694, D_80181698, D_8018169C, D_801816A0; + extern u32 D_80181694, D_80181698, D_8018169C, D_801816A0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181674[0x00], p); + ApplyMatrixSV(mat, &D_80181674[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181674[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181674[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018169C; + *(u32 *)(prim + 0x24) = D_80181694; + *(u32 *)(prim + 0x28) = D_801816A0; + *(u32 *)(prim + 0x2c) = D_80181698; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801816A4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801816A4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801816A4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801816A4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80181720[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80181720[a1 & 0x7F]; +} + + + +extern s32 D_80181740[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181740[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801817BC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801817BC[a1 & 0x7F]; +} + + + +extern u8 D_801817DC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801817DC[a1 & 0x7F]; +} + + + +extern u8 D_801817FC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801817FC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018181C[])(void); + D_8018181C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80181898[])(void); + +void func_80165AC8(void) { + D_80181898[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181914[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181914[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801A7DE8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801A7DE8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80181920[])(void); + +void func_80166018(void *a0) { + D_80181920[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181928[])(void); + +void func_801663FC(void *a0) { + D_80181928[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801819F0[])(void); + +void func_80166618(void *a0) { + D_801819F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181A00[])(void); + +void func_80166654(void *a0) { + D_80181A00[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A86A0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A86A0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A86A0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A86A0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A86A0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A86A0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A86A0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80181944[]; + extern u8 D_80181930[]; + extern u8 D_80181958[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80181944; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80181930; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80181958; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80167714); + + +extern void (*D_80181A10[])(void); + +void func_801678B4(void *a0) { + D_80181A10[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181A1C[])(void); + +void func_80167A9C(void *a0) { + D_80181A1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181B28; + extern u8 D_80181B3C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181B28); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181B3C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018197C[]; +extern u8 D_80181990[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018197C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181990; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181A34[])(void); + +void func_80168744(void *a0) { + D_80181A34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181A24 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181A24[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181A24; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181A3C[])(void); + +void func_801689D8(void *a0) { + D_80181A3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181A44[])(void); + +void func_80168AA8(void *a0) { + D_80181A44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181A4C[])(void); + +void func_80168D58(void *a0) { + D_80181A4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181A54[])(void); + +void func_8016901C(void *a0) { + D_80181A54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_114/nonmatchings/ov_SC03_114_jr_8015C32C", func_80169228); + + +extern void (*D_80181A5C[])(void); + +void func_801693CC(void *a0) { + D_80181A5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181A64[])(void); + +void func_80169830(void *a0) { + D_80181A64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181B18[])(void); + +void func_80169B80(void *a0) { + D_80181B18[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181A6C[]; + extern u8 D_80181ADC[]; + extern u8 D_80181B0C[]; + extern u8 D_801A9720[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181B0C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181A6C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A9720; + RotMatrixYXZ(rot, D_801A9720); + func_80048D9C(D_801A9720, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181ADC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181B20[])(void); + +void func_80169F00(void *a0) { + D_80181B20[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80181AD0[]; +extern char D_80181A90[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80181AD0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181A90); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181B58[])(void); + +void func_8016A020(void *a0) { + D_80181B58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181B28; + extern u8 D_80181B3C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181B28); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181B3C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181B64[])(void); + +void func_8016A700(void *a0) { + D_80181B64[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80181BAC[])(void); + +void func_8016AB30(void *a0) { + D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_115/ov_SC03_115_jr_8015AE2C.c b/src/ov_SC03_115/ov_SC03_115_jr_8015AE2C.c index b755ddae4..f055420fc 100644 --- a/src/ov_SC03_115/ov_SC03_115_jr_8015AE2C.c +++ b/src/ov_SC03_115/ov_SC03_115_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80182CD4[])(void); - -void func_8015C714(void *a0) { - D_80182CD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80182B48[])(void*); - extern int D_80182AEC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80182B48)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80182B48)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182AEC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80182B48[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80182B48[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80182B48[])(void*); - extern int D_80182AEC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80182B48)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182AEC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80182B48)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80182CE4[])(void); - D_80182CE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80182B48[])(struct Ent_8015CD20 *); - extern u8 D_80182AFC; - extern u8 D_80182CEC; - extern u8 D_80182CFC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80182B48[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182AFC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182CEC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182CFC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80182B48[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80182D1C[])(void); - D_80182D1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80182D0C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80182D0C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80182B48[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80182D78; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80182D78, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80181E5C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80181E5C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80182D80[])(void); - D_80182D80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80182D8C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80182D8C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80182D8C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80182D8C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80182B48[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80182D8C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80182B0C[]; - extern u8 D_80182B1C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182B0C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182B1C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80182D8C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80182D8C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80182D8C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80182DC0[])(void); - D_80182DC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182B48[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182DC8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80182DE0[])(void); - D_80182DE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182B48[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182DC8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80182E00[])(void); - D_80182E00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80182B48[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182B48)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80182E10; -extern u16 D_80182E12; -extern u16 D_80182E14; -extern s32 D_80182E18; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80182E10 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80182E12 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80182E14 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182E18, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80182E20; - -void func_8015E588(void) { - func_8013C9C4(&D_80182E20); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80182B48[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182B48)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80182E34[])(void); - D_80182E34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80182B48[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80182B48[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80182E3C[])(void); - D_80182E3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80182B2C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182B2C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80182B48[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80182E44[])(void); - D_80182E44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80182B48[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80182B48[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80182E4C[])(void); - D_80182E4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80182B48[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80182E54; - extern s32 D_80182E64; - extern s32 D_80182E74; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80182B48[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E54); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E64); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80182B48[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E74); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80182E84[])(void); - D_80182E84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80182B48[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80182B48[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80182B48[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182B48[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80182E90[])(void); - D_80182E90[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80182B48[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182B48[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80182B48[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182B48[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80182EA4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80182EA4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80182B48[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80182B48)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80182B48[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182B48[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80182F20[])(void); - D_80182F20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80182B48[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80182B48)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80182F30[])(void); - D_80182F30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80182B48[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80182B48[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80182B48[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80182B48[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80182B48[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80182B48[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80182B48[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80182F38[])(void); - D_80182F38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80182B48[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80182B48)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80182B48[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80182B48)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80182F44[])(void); - D_80182F44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182B48 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80182B48[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80182B48[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80182B48[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80182F54[])(void); - -void func_80160EA4(void *a0) { - D_80182F54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80182B48[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80182B48[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80182F84[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80182F84[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80182FE8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80182FE8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80193E80[]; - extern u8 D_80182FB4[]; - extern u8 D_80182FD4[]; - extern u8 D_80193E8C[]; - extern u8 D_80193EB4[]; - extern u8 D_80193ECC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80193E80[0] = p; - func_80024054(&D_80182FB4, &D_80193E8C); - func_8001CE28(p, &D_80193E8C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80193E80[1] = p; - func_80024054(&D_80182FD4, &D_80193EB4); - func_8001CE28(p, &D_80193EB4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80193E80[2] = p; - func_800242D0((s16)func_801620C4(), &D_80193ECC, 0x84); - func_8001CE68(p, &D_80193ECC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80193ECC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80193E80[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80193E80; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80182FE8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80182FE8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80182FE8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80182FE8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80193E80[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80193E80; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018300C[])(void); - -void func_80162330(void *a0) { - D_8018300C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80193ED8[i] via `extern int D_80193ED8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80183018[]; - extern s32 D_80183030; - extern u8 D_80193EE4[]; - extern u8 D_80193F0C[]; - extern u8 D_80193F28[]; - extern int D_80193ED8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80193ED8[0] = (s32)item; - func_80024054(D_80183018, D_80193EE4); - func_8001CE28(item, D_80193EE4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80193ED8[1] = (s32)item; - func_80024054(((u8 *)&D_80183030), D_80193F0C); - func_8001CE28(item, D_80193F0C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80193ED8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80193F28, 0x84); - func_8001CE68(item, D_80193F28); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80193F28, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80193ED8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80193ED8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_801627E8); - - -extern void (*D_80183054[])(void); - -void func_80162834(void *a0) { - D_80183054[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80183044; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80183044, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019374C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019374C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019374C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019374C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018305C[])(void); - -void func_80163A58(void *a0) { - D_8018305C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80193754; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80193754; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801830B0[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801830B0[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80183078; -extern s16 D_801830AC; -extern s16 D_801830AA; -extern s16 D_801830A8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80183078; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801830AC = 0x80; - D_801830AA = 0x80; - D_801830A8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801830AC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801830AC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801830AC - 8; - D_801830AC = nv; - D_801830AA = nv; - D_801830A8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801830BC[])(void); - -void func_80164BA0(void *a0) { - D_801830BC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80193F38; -extern u8 D_80193F39; -extern u8 D_80193F3A; -extern u8 D_80193F3B; -extern u8 D_80193F3C; -extern u8 D_80193F3D; -extern u8 D_80193F3E; -extern u8 D_80193F3F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80193F38; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80193F39 = 0xf0; - *(u8 *)base = 0xf0; - D_80193F3A = 0xc0; - D_80193F3E = 0; - D_80193F3D = 0; - D_80193F3C = 0; - D_80193F3F = 0; - D_80193F3B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80193F38; -extern u8 D_80193F39; -extern u8 D_80193F3A; - -s32 func_80164E40(void) { - u8 *p = &D_80193F38; - if (*p != 0) { - *p -= 0x10; - } - if (D_80193F39 != 0) { - D_80193F39 -= 0x10; - } - if (D_80193F3A != 0) { - D_80193F3A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801830CC[])(void); - -void func_80164EA4(void *a0) { - D_801830CC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80193F84[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80193F84[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80193F78[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80193F78[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80193F78[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80193F78; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80193F78; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801830E0[]; - extern u32 D_80183100, D_80183104, D_80183108, D_8018310C; - extern u32 D_80183100, D_80183104, D_80183108, D_8018310C; - extern u32 D_80183100, D_80183104, D_80183108, D_8018310C; - extern u32 D_80183100, D_80183104, D_80183108, D_8018310C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801830E0[0x00], p); - ApplyMatrixSV(mat, &D_801830E0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801830E0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801830E0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80183108; - *(u32 *)(prim + 0x24) = D_80183100; - *(u32 *)(prim + 0x28) = D_8018310C; - *(u32 *)(prim + 0x2c) = D_80183104; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80183110[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80183110[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80183110[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80183110[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018318C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018318C[a1 & 0x7F]; -} - - - -extern s32 D_801831AC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801831AC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80183228[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80183228[a1 & 0x7F]; -} - - - -extern u8 D_80183248[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80183248[a1 & 0x7F]; -} - - - -extern u8 D_80183268[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80183268[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80183288[])(void); - D_80183288[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80183304[])(void); - -void func_80165AC8(void) { - D_80183304[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80183380[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80183380[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019375C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019375C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018338C[])(void); - -void func_80166018(void *a0) { - D_8018338C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80183394[])(void); - -void func_801663FC(void *a0) { - D_80183394[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018345C[])(void); - -void func_80166618(void *a0) { - D_8018345C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018346C[])(void); - -void func_80166654(void *a0) { - D_8018346C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80193FF8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80193FF8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80193FF8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80193FF8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80193FF8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80193FF8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80193FF8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801833B0[]; - extern u8 D_8018339C[]; - extern u8 D_801833C4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801833B0; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018339C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801833C4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80167714); - - -extern void (*D_8018347C[])(void); - -void func_801678B4(void *a0) { - D_8018347C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80183488[])(void); - -void func_80167A9C(void *a0) { - D_80183488[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80183594; - extern u8 D_801835A8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80183594); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801835A8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801833E8[]; -extern u8 D_801833FC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801833E8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801833FC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801834A0[])(void); - -void func_80168744(void *a0) { - D_801834A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80183490 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80183490[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80183490; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801834A8[])(void); - -void func_801689D8(void *a0) { - D_801834A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801834B0[])(void); - -void func_80168AA8(void *a0) { - D_801834B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801834B8[])(void); - -void func_80168D58(void *a0) { - D_801834B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801834C0[])(void); - -void func_8016901C(void *a0) { - D_801834C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015AE2C", func_80169228); - - -extern void (*D_801834C8[])(void); - -void func_801693CC(void *a0) { - D_801834C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801834D0[])(void); - -void func_80169830(void *a0) { - D_801834D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80183584[])(void); - -void func_80169B80(void *a0) { - D_80183584[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801834D8[]; - extern u8 D_80183548[]; - extern u8 D_80183578[]; - extern u8 D_80194FF8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80183578, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801834D8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80194FF8; - RotMatrixYXZ(rot, D_80194FF8); - func_80048D9C(D_80194FF8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80183548); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018358C[])(void); - -void func_80169F00(void *a0) { - D_8018358C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018353C[]; -extern char D_801834FC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018353C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801834FC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801835C4[])(void); - -void func_8016A020(void *a0) { - D_801835C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80183594; - extern u8 D_801835A8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80183594); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801835A8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801835D0[])(void); - -void func_8016A700(void *a0) { - D_801835D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80183618[])(void); - -void func_8016AB30(void *a0) { - D_80183618[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c b/src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c new file mode 100644 index 000000000..d4c7c37df --- /dev/null +++ b/src/ov_SC03_115/ov_SC03_115_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801829E4; +extern u8 D_80182954; +extern u8 D_80182930; +extern u8 D_8018290C; +extern u8 D_801829C0; +extern u8 D_8018299C; +extern u8 D_80182978; +extern u8 D_801828E8; +extern void func_80145934(void); +extern u8 D_80182A74; +extern u8 D_80182A50; +extern u8 D_80182A2C; +extern u8 D_80182A08; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80181E6C[]; +extern unsigned char D_80181E9C[]; +extern unsigned char D_80181EEC[]; +extern unsigned char D_80181F1C[]; +extern unsigned char D_80181F4C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80181F9C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80182064[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801820EC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801820F4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80193E28; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_80193E2C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80182124; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801821CC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801821F0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801821E0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80182204[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80182210[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80182220[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80182238[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80182228; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018224C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80182268[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80182258; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018227C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80182290[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801822A4; +extern void (*D_801822CC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801822AC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80182318[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018231C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80182780[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80182790[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80193E60; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801827B8[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80182798; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801827A8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801827F8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80182800[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801827CC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018280C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801827DC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80193E68; +extern s32 D_80193E74; +extern s32 D_80193E78; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80182848[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018281C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80193E70; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80182A98[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801828B8[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80182B3C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80182C90[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80182AAC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80182C98[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80182ABC; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80182ADC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80182CA0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80182CC8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80182B48[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80182CD4[])(void); + +void func_8015C714(void *a0) { + D_80182CD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80182B48[])(void*); + extern int D_80182AEC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80182B48)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80182B48)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182AEC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80182B48[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80182B48[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80182B48[])(void*); + extern int D_80182AEC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80182B48)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182AEC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80182B48)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80182CE4[])(void); + D_80182CE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80182B48[])(struct Ent_8015CD20 *); + extern u8 D_80182AFC; + extern u8 D_80182CEC; + extern u8 D_80182CFC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80182B48[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182AFC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182CEC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182CFC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80182B48[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80182D1C[])(void); + D_80182D1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80182D0C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80182D0C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80182B48[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80182D78; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80182D78, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80181E5C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80181E5C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80182D80[])(void); + D_80182D80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80182D8C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80182D8C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80182D8C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80182D8C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80182B48[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80182D8C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80182B0C[]; + extern u8 D_80182B1C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182B0C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182B1C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80182D8C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80182D8C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80182D8C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80182DC0[])(void); + D_80182DC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182B48[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182DC8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80182DE0[])(void); + D_80182DE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182B48[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182DC8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182DC8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80182E00[])(void); + D_80182E00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80182B48[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182B48)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80182E10; +extern u16 D_80182E12; +extern u16 D_80182E14; +extern s32 D_80182E18; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80182E10 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80182E12 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80182E14 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182E18, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80182E20; + +void func_8015E588(void) { + func_8013C9C4(&D_80182E20); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80182B48[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182B48)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80182E34[])(void); + D_80182E34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80182B48[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80182B48[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80182E3C[])(void); + D_80182E3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80182B2C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182B2C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80182B48[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80182E44[])(void); + D_80182E44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80182B48[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80182B48[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80182E4C[])(void); + D_80182E4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80182B48[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80182E54; + extern s32 D_80182E64; + extern s32 D_80182E74; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E54); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E64); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80182B48[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E74); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80182E84[])(void); + D_80182E84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80182B48[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80182B48[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80182B48[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182B48[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80182E90[])(void); + D_80182E90[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80182B48[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182B48[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80182B48[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182B48[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80182EA4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80182EA4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80182B48[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80182B48)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80182B48[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182B48[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80182F20[])(void); + D_80182F20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80182B48[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80182B48)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80182F30[])(void); + D_80182F30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80182B48[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80182B48[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80182B48[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80182B48[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80182B48[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80182B48[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80182B48[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80182F38[])(void); + D_80182F38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80182B48[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80182B48)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80182B48[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80182B48)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80182F44[])(void); + D_80182F44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182B48 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80182B48[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80182B48[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80182B48[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80182F54[])(void); + +void func_80160EA4(void *a0) { + D_80182F54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80182B48[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80182B48[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80182F84[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80182F84[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80182FE8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80182FE8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80193E80[]; + extern u8 D_80182FB4[]; + extern u8 D_80182FD4[]; + extern u8 D_80193E8C[]; + extern u8 D_80193EB4[]; + extern u8 D_80193ECC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80193E80[0] = p; + func_80024054(&D_80182FB4, &D_80193E8C); + func_8001CE28(p, &D_80193E8C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80193E80[1] = p; + func_80024054(&D_80182FD4, &D_80193EB4); + func_8001CE28(p, &D_80193EB4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80193E80[2] = p; + func_800242D0((s16)func_801620C4(), &D_80193ECC, 0x84); + func_8001CE68(p, &D_80193ECC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80193ECC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80193E80[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80193E80; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80182FE8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80182FE8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80182FE8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80182FE8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80193E80[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80193E80; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018300C[])(void); + +void func_80162330(void *a0) { + D_8018300C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80193ED8[i] via `extern int D_80193ED8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80183018[]; + extern s32 D_80183030; + extern u8 D_80193EE4[]; + extern u8 D_80193F0C[]; + extern u8 D_80193F28[]; + extern int D_80193ED8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80193ED8[0] = (s32)item; + func_80024054(D_80183018, D_80193EE4); + func_8001CE28(item, D_80193EE4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80193ED8[1] = (s32)item; + func_80024054(((u8 *)&D_80183030), D_80193F0C); + func_8001CE28(item, D_80193F0C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80193ED8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80193F28, 0x84); + func_8001CE68(item, D_80193F28); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80193F28, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80193ED8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80193ED8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_801627E8); + + +extern void (*D_80183054[])(void); + +void func_80162834(void *a0) { + D_80183054[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80183044; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80183044, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019374C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019374C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019374C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019374C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018305C[])(void); + +void func_80163A58(void *a0) { + D_8018305C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80193754; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80193754; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801830B0[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801830B0[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80183078; +extern s16 D_801830AC; +extern s16 D_801830AA; +extern s16 D_801830A8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80183078; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801830AC = 0x80; + D_801830AA = 0x80; + D_801830A8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801830AC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801830AC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801830AC - 8; + D_801830AC = nv; + D_801830AA = nv; + D_801830A8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801830BC[])(void); + +void func_80164BA0(void *a0) { + D_801830BC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80193F38; +extern u8 D_80193F39; +extern u8 D_80193F3A; +extern u8 D_80193F3B; +extern u8 D_80193F3C; +extern u8 D_80193F3D; +extern u8 D_80193F3E; +extern u8 D_80193F3F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80193F38; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80193F39 = 0xf0; + *(u8 *)base = 0xf0; + D_80193F3A = 0xc0; + D_80193F3E = 0; + D_80193F3D = 0; + D_80193F3C = 0; + D_80193F3F = 0; + D_80193F3B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80193F38; +extern u8 D_80193F39; +extern u8 D_80193F3A; + +s32 func_80164E40(void) { + u8 *p = &D_80193F38; + if (*p != 0) { + *p -= 0x10; + } + if (D_80193F39 != 0) { + D_80193F39 -= 0x10; + } + if (D_80193F3A != 0) { + D_80193F3A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801830CC[])(void); + +void func_80164EA4(void *a0) { + D_801830CC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80193F84[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80193F84[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80193F78[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80193F78[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80193F78[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80193F78; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80193F78; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801830E0[]; + extern u32 D_80183100, D_80183104, D_80183108, D_8018310C; + extern u32 D_80183100, D_80183104, D_80183108, D_8018310C; + extern u32 D_80183100, D_80183104, D_80183108, D_8018310C; + extern u32 D_80183100, D_80183104, D_80183108, D_8018310C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801830E0[0x00], p); + ApplyMatrixSV(mat, &D_801830E0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801830E0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801830E0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80183108; + *(u32 *)(prim + 0x24) = D_80183100; + *(u32 *)(prim + 0x28) = D_8018310C; + *(u32 *)(prim + 0x2c) = D_80183104; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80183110[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80183110[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80183110[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80183110[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018318C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018318C[a1 & 0x7F]; +} + + + +extern s32 D_801831AC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801831AC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80183228[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80183228[a1 & 0x7F]; +} + + + +extern u8 D_80183248[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80183248[a1 & 0x7F]; +} + + + +extern u8 D_80183268[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80183268[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80183288[])(void); + D_80183288[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80183304[])(void); + +void func_80165AC8(void) { + D_80183304[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80183380[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80183380[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019375C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019375C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018338C[])(void); + +void func_80166018(void *a0) { + D_8018338C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80183394[])(void); + +void func_801663FC(void *a0) { + D_80183394[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018345C[])(void); + +void func_80166618(void *a0) { + D_8018345C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018346C[])(void); + +void func_80166654(void *a0) { + D_8018346C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80193FF8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80193FF8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80193FF8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80193FF8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80193FF8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80193FF8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80193FF8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801833B0[]; + extern u8 D_8018339C[]; + extern u8 D_801833C4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801833B0; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018339C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801833C4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80167714); + + +extern void (*D_8018347C[])(void); + +void func_801678B4(void *a0) { + D_8018347C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80183488[])(void); + +void func_80167A9C(void *a0) { + D_80183488[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80183594; + extern u8 D_801835A8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80183594); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801835A8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801833E8[]; +extern u8 D_801833FC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801833E8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801833FC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801834A0[])(void); + +void func_80168744(void *a0) { + D_801834A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80183490 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80183490[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80183490; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801834A8[])(void); + +void func_801689D8(void *a0) { + D_801834A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801834B0[])(void); + +void func_80168AA8(void *a0) { + D_801834B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801834B8[])(void); + +void func_80168D58(void *a0) { + D_801834B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801834C0[])(void); + +void func_8016901C(void *a0) { + D_801834C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_115/nonmatchings/ov_SC03_115_jr_8015C32C", func_80169228); + + +extern void (*D_801834C8[])(void); + +void func_801693CC(void *a0) { + D_801834C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801834D0[])(void); + +void func_80169830(void *a0) { + D_801834D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80183584[])(void); + +void func_80169B80(void *a0) { + D_80183584[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801834D8[]; + extern u8 D_80183548[]; + extern u8 D_80183578[]; + extern u8 D_80194FF8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80183578, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801834D8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80194FF8; + RotMatrixYXZ(rot, D_80194FF8); + func_80048D9C(D_80194FF8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80183548); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018358C[])(void); + +void func_80169F00(void *a0) { + D_8018358C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018353C[]; +extern char D_801834FC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018353C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801834FC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801835C4[])(void); + +void func_8016A020(void *a0) { + D_801835C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80183594; + extern u8 D_801835A8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80183594); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801835A8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801835D0[])(void); + +void func_8016A700(void *a0) { + D_801835D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80183618[])(void); + +void func_8016AB30(void *a0) { + D_80183618[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_116/ov_SC03_116_jr_8015AE2C.c b/src/ov_SC03_116/ov_SC03_116_jr_8015AE2C.c index 5a5b71dca..22abcde25 100644 --- a/src/ov_SC03_116/ov_SC03_116_jr_8015AE2C.c +++ b/src/ov_SC03_116/ov_SC03_116_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801850D8[])(void); - -void func_8015C714(void *a0) { - D_801850D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80184F4C[])(void*); - extern int D_80184EF0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80184F4C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80184F4C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184EF0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80184F4C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80184F4C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80184F4C[])(void*); - extern int D_80184EF0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80184F4C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184EF0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80184F4C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801850E8[])(void); - D_801850E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80184F4C[])(struct Ent_8015CD20 *); - extern u8 D_80184F00; - extern u8 D_801850F0; - extern u8 D_80185100; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80184F4C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184F00); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801850F0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185100); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80184F4C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80185120[])(void); - D_80185120[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80185110; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80185110 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80184F4C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018517C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018517C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80184260[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80184260; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80185184[])(void); - D_80185184[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80185190[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80185190[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80185190[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80185190[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80184F4C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80185190[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80184F10[]; - extern u8 D_80184F20[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184F10); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184F20); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80185190[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185190[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185190[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801851C4[])(void); - D_801851C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184F4C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801851CC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801851E4[])(void); - D_801851E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184F4C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801851CC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80185204[])(void); - D_80185204[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80184F4C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184F4C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80185214; -extern u16 D_80185216; -extern u16 D_80185218; -extern s32 D_8018521C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80185214 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80185216 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80185218 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018521C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80185224; - -void func_8015E588(void) { - func_8013C9C4(&D_80185224); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80184F4C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184F4C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80185238[])(void); - D_80185238[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80184F4C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80184F4C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80185240[])(void); - D_80185240[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80184F30; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80184F30); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80184F4C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80185248[])(void); - D_80185248[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80184F4C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80184F4C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80185250[])(void); - D_80185250[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80184F4C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80185258; - extern s32 D_80185268; - extern s32 D_80185278; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80184F4C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185258); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185268); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80184F4C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185278); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80185288[])(void); - D_80185288[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80184F4C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80184F4C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80184F4C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184F4C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80185294[])(void); - D_80185294[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80184F4C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184F4C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80184F4C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184F4C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801852A8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801852A8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80184F4C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80184F4C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80184F4C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184F4C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80185324[])(void); - D_80185324[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80184F4C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80184F4C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80185334[])(void); - D_80185334[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80184F4C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80184F4C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80184F4C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80184F4C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80184F4C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80184F4C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80184F4C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018533C[])(void); - D_8018533C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80184F4C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80184F4C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80184F4C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80184F4C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80185348[])(void); - D_80185348[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184F4C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80184F4C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80184F4C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80184F4C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80185358[])(void); - -void func_80160EA4(void *a0) { - D_80185358[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80184F4C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80184F4C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80185388[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80185388[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801853EC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801853EC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80196A10[]; - extern u8 D_801853B8[]; - extern u8 D_801853D8[]; - extern u8 D_80196A1C[]; - extern u8 D_80196A44[]; - extern u8 D_80196A5C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80196A10[0] = p; - func_80024054(&D_801853B8, &D_80196A1C); - func_8001CE28(p, &D_80196A1C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80196A10[1] = p; - func_80024054(&D_801853D8, &D_80196A44); - func_8001CE28(p, &D_80196A44); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80196A10[2] = p; - func_800242D0((s16)func_801620C4(), &D_80196A5C, 0x84); - func_8001CE68(p, &D_80196A5C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80196A5C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80196A10[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80196A10; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801853EC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801853EC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801853EC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801853EC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80196A10[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80196A10; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80185410[])(void); - -void func_80162330(void *a0) { - D_80185410[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80196A68[i] via `extern int D_80196A68[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018541C[]; - extern s32 D_80185434; - extern u8 D_80196A74[]; - extern u8 D_80196A9C[]; - extern u8 D_80196AB8[]; - extern int D_80196A68[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80196A68[0] = (s32)item; - func_80024054(D_8018541C, D_80196A74); - func_8001CE28(item, D_80196A74); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80196A68[1] = (s32)item; - func_80024054(((u8 *)&D_80185434), D_80196A9C); - func_8001CE28(item, D_80196A9C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80196A68[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80196AB8, 0x84); - func_8001CE68(item, D_80196AB8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80196AB8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80196A68[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80196A68; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_801627E8); - - -extern void (*D_80185458[])(void); - -void func_80162834(void *a0) { - D_80185458[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80185448; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80185448, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801962E8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801962E8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801962E8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801962E8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80185460[])(void); - -void func_80163A58(void *a0) { - D_80185460[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801962F0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801962F0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801854B4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801854B4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018547C; -extern s16 D_801854B0; -extern s16 D_801854AE; -extern s16 D_801854AC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018547C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801854B0 = 0x80; - D_801854AE = 0x80; - D_801854AC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801854B0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801854B0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801854B0 - 8; - D_801854B0 = nv; - D_801854AE = nv; - D_801854AC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801854C0[])(void); - -void func_80164BA0(void *a0) { - D_801854C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80196AC8; -extern u8 D_80196AC9; -extern u8 D_80196ACA; -extern u8 D_80196ACB; -extern u8 D_80196ACC; -extern u8 D_80196ACD; -extern u8 D_80196ACE; -extern u8 D_80196ACF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80196AC8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80196AC9 = 0xf0; - *(u8 *)base = 0xf0; - D_80196ACA = 0xc0; - D_80196ACE = 0; - D_80196ACD = 0; - D_80196ACC = 0; - D_80196ACF = 0; - D_80196ACB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80196AC8; -extern u8 D_80196AC9; -extern u8 D_80196ACA; - -s32 func_80164E40(void) { - u8 *p = &D_80196AC8; - if (*p != 0) { - *p -= 0x10; - } - if (D_80196AC9 != 0) { - D_80196AC9 -= 0x10; - } - if (D_80196ACA != 0) { - D_80196ACA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801854D0[])(void); - -void func_80164EA4(void *a0) { - D_801854D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80196B14[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80196B14[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80196B08[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80196B08[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80196B08[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80196B08; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80196B08; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801854E4[]; - extern u32 D_80185504, D_80185508, D_8018550C, D_80185510; - extern u32 D_80185504, D_80185508, D_8018550C, D_80185510; - extern u32 D_80185504, D_80185508, D_8018550C, D_80185510; - extern u32 D_80185504, D_80185508, D_8018550C, D_80185510; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801854E4[0x00], p); - ApplyMatrixSV(mat, &D_801854E4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801854E4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801854E4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018550C; - *(u32 *)(prim + 0x24) = D_80185504; - *(u32 *)(prim + 0x28) = D_80185510; - *(u32 *)(prim + 0x2c) = D_80185508; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80185514[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80185514[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80185514[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80185514[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80185590[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80185590[a1 & 0x7F]; -} - - - -extern s32 D_801855B0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801855B0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018562C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018562C[a1 & 0x7F]; -} - - - -extern u8 D_8018564C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018564C[a1 & 0x7F]; -} - - - -extern u8 D_8018566C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018566C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018568C[])(void); - D_8018568C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80185708[])(void); - -void func_80165AC8(void) { - D_80185708[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80185784[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80185784[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801962F8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801962F8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80185790[])(void); - -void func_80166018(void *a0) { - D_80185790[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80185798[])(void); - -void func_801663FC(void *a0) { - D_80185798[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80185860[])(void); - -void func_80166618(void *a0) { - D_80185860[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80185870[])(void); - -void func_80166654(void *a0) { - D_80185870[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80196B88[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80196B88[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80196B88). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80196B88[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80196B88)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80196B88[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80196B88[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801857B4[]; - extern u8 D_801857A0[]; - extern u8 D_801857C8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801857B4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801857A0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801857C8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80167714); - - -extern void (*D_80185880[])(void); - -void func_801678B4(void *a0) { - D_80185880[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018588C[])(void); - -void func_80167A9C(void *a0) { - D_8018588C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80185998; - extern u8 D_801859AC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80185998); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801859AC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801857EC[]; -extern u8 D_80185800[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801857EC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80185800; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801858A4[])(void); - -void func_80168744(void *a0) { - D_801858A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80185894 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80185894[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80185894; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801858AC[])(void); - -void func_801689D8(void *a0) { - D_801858AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801858B4[])(void); - -void func_80168AA8(void *a0) { - D_801858B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801858BC[])(void); - -void func_80168D58(void *a0) { - D_801858BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801858C4[])(void); - -void func_8016901C(void *a0) { - D_801858C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015AE2C", func_80169228); - - -extern void (*D_801858CC[])(void); - -void func_801693CC(void *a0) { - D_801858CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801858D4[])(void); - -void func_80169830(void *a0) { - D_801858D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80185988[])(void); - -void func_80169B80(void *a0) { - D_80185988[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801858DC[]; - extern u8 D_8018594C[]; - extern u8 D_8018597C[]; - extern u8 D_80197C08[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018597C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801858DC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80197C08; - RotMatrixYXZ(rot, D_80197C08); - func_80048D9C(D_80197C08, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018594C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80185990[])(void); - -void func_80169F00(void *a0) { - D_80185990[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80185940[]; -extern char D_80185900[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80185940, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80185900); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801859C8[])(void); - -void func_8016A020(void *a0) { - D_801859C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80185998; - extern u8 D_801859AC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80185998); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801859AC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801859D4[])(void); - -void func_8016A700(void *a0) { - D_801859D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80185A1C[])(void); - -void func_8016AB30(void *a0) { - D_80185A1C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c b/src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c new file mode 100644 index 000000000..72704f469 --- /dev/null +++ b/src/ov_SC03_116/ov_SC03_116_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80184DE8; +extern u8 D_80184D58; +extern u8 D_80184D34; +extern u8 D_80184D10; +extern u8 D_80184DC4; +extern u8 D_80184DA0; +extern u8 D_80184D7C; +extern u8 D_80184CEC; +extern void func_80145934(void); +extern u8 D_80184E78; +extern u8 D_80184E54; +extern u8 D_80184E30; +extern u8 D_80184E0C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80184270[]; +extern unsigned char D_801842A0[]; +extern unsigned char D_801842F0[]; +extern unsigned char D_80184320[]; +extern unsigned char D_80184350[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801843A0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80184468[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801844F0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801844F8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801969B8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801969BC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80184528; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801845D0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801845F4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801845E4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80184608[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80184614[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80184624[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018463C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018462C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80184650[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018466C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018465C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80184680[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80184694[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801846A8; +extern void (*D_801846D0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801846B0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018471C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80184720[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184B84[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184B94[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801969F0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80184BBC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80184B9C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80184BAC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80184BFC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80184C04[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80184BD0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80184C10[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80184BE0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801969F8; +extern s32 D_80196A04; +extern s32 D_80196A08; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80184C4C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80184C20[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80196A00; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184E9C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80184CBC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80184F40[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80185094[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80184EB0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018509C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80184EC0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80184EE0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801850A4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801850CC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80184F4C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801850D8[])(void); + +void func_8015C714(void *a0) { + D_801850D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80184F4C[])(void*); + extern int D_80184EF0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80184F4C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80184F4C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184EF0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80184F4C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80184F4C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80184F4C[])(void*); + extern int D_80184EF0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80184F4C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184EF0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80184F4C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801850E8[])(void); + D_801850E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80184F4C[])(struct Ent_8015CD20 *); + extern u8 D_80184F00; + extern u8 D_801850F0; + extern u8 D_80185100; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80184F4C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184F00); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801850F0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185100); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80184F4C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80185120[])(void); + D_80185120[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80185110; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80185110 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80184F4C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018517C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018517C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80184260[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80184260; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80185184[])(void); + D_80185184[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80185190[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80185190[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80185190[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80185190[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80184F4C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80185190[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80184F10[]; + extern u8 D_80184F20[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184F10); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184F20); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80185190[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185190[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185190[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801851C4[])(void); + D_801851C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184F4C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801851CC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801851E4[])(void); + D_801851E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184F4C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801851CC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801851CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80185204[])(void); + D_80185204[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80184F4C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184F4C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80185214; +extern u16 D_80185216; +extern u16 D_80185218; +extern s32 D_8018521C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80185214 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80185216 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80185218 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018521C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80185224; + +void func_8015E588(void) { + func_8013C9C4(&D_80185224); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80184F4C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184F4C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80185238[])(void); + D_80185238[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80184F4C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80184F4C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80185240[])(void); + D_80185240[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80184F30; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80184F30); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80184F4C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80185248[])(void); + D_80185248[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80184F4C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80184F4C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80185250[])(void); + D_80185250[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80184F4C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80185258; + extern s32 D_80185268; + extern s32 D_80185278; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185258); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185268); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80184F4C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185278); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80185288[])(void); + D_80185288[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80184F4C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80184F4C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80184F4C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184F4C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80185294[])(void); + D_80185294[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80184F4C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184F4C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80184F4C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184F4C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801852A8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801852A8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80184F4C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80184F4C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80184F4C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184F4C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80185324[])(void); + D_80185324[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80184F4C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80184F4C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80185334[])(void); + D_80185334[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80184F4C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80184F4C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80184F4C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80184F4C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80184F4C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80184F4C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80184F4C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018533C[])(void); + D_8018533C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80184F4C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80184F4C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80184F4C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80184F4C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80185348[])(void); + D_80185348[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184F4C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80184F4C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80184F4C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80184F4C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80185358[])(void); + +void func_80160EA4(void *a0) { + D_80185358[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80184F4C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80184F4C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80185388[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80185388[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801853EC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801853EC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80196A10[]; + extern u8 D_801853B8[]; + extern u8 D_801853D8[]; + extern u8 D_80196A1C[]; + extern u8 D_80196A44[]; + extern u8 D_80196A5C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80196A10[0] = p; + func_80024054(&D_801853B8, &D_80196A1C); + func_8001CE28(p, &D_80196A1C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80196A10[1] = p; + func_80024054(&D_801853D8, &D_80196A44); + func_8001CE28(p, &D_80196A44); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80196A10[2] = p; + func_800242D0((s16)func_801620C4(), &D_80196A5C, 0x84); + func_8001CE68(p, &D_80196A5C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80196A5C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80196A10[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80196A10; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801853EC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801853EC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801853EC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801853EC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80196A10[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80196A10; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80185410[])(void); + +void func_80162330(void *a0) { + D_80185410[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80196A68[i] via `extern int D_80196A68[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018541C[]; + extern s32 D_80185434; + extern u8 D_80196A74[]; + extern u8 D_80196A9C[]; + extern u8 D_80196AB8[]; + extern int D_80196A68[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80196A68[0] = (s32)item; + func_80024054(D_8018541C, D_80196A74); + func_8001CE28(item, D_80196A74); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80196A68[1] = (s32)item; + func_80024054(((u8 *)&D_80185434), D_80196A9C); + func_8001CE28(item, D_80196A9C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80196A68[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80196AB8, 0x84); + func_8001CE68(item, D_80196AB8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80196AB8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80196A68[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80196A68; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_801627E8); + + +extern void (*D_80185458[])(void); + +void func_80162834(void *a0) { + D_80185458[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80185448; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80185448, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801962E8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801962E8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801962E8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801962E8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80185460[])(void); + +void func_80163A58(void *a0) { + D_80185460[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801962F0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801962F0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801854B4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801854B4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018547C; +extern s16 D_801854B0; +extern s16 D_801854AE; +extern s16 D_801854AC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018547C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801854B0 = 0x80; + D_801854AE = 0x80; + D_801854AC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801854B0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801854B0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801854B0 - 8; + D_801854B0 = nv; + D_801854AE = nv; + D_801854AC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801854C0[])(void); + +void func_80164BA0(void *a0) { + D_801854C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80196AC8; +extern u8 D_80196AC9; +extern u8 D_80196ACA; +extern u8 D_80196ACB; +extern u8 D_80196ACC; +extern u8 D_80196ACD; +extern u8 D_80196ACE; +extern u8 D_80196ACF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80196AC8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80196AC9 = 0xf0; + *(u8 *)base = 0xf0; + D_80196ACA = 0xc0; + D_80196ACE = 0; + D_80196ACD = 0; + D_80196ACC = 0; + D_80196ACF = 0; + D_80196ACB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80196AC8; +extern u8 D_80196AC9; +extern u8 D_80196ACA; + +s32 func_80164E40(void) { + u8 *p = &D_80196AC8; + if (*p != 0) { + *p -= 0x10; + } + if (D_80196AC9 != 0) { + D_80196AC9 -= 0x10; + } + if (D_80196ACA != 0) { + D_80196ACA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801854D0[])(void); + +void func_80164EA4(void *a0) { + D_801854D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80196B14[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80196B14[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80196B08[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80196B08[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80196B08[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80196B08; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80196B08; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801854E4[]; + extern u32 D_80185504, D_80185508, D_8018550C, D_80185510; + extern u32 D_80185504, D_80185508, D_8018550C, D_80185510; + extern u32 D_80185504, D_80185508, D_8018550C, D_80185510; + extern u32 D_80185504, D_80185508, D_8018550C, D_80185510; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801854E4[0x00], p); + ApplyMatrixSV(mat, &D_801854E4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801854E4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801854E4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018550C; + *(u32 *)(prim + 0x24) = D_80185504; + *(u32 *)(prim + 0x28) = D_80185510; + *(u32 *)(prim + 0x2c) = D_80185508; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80185514[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80185514[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80185514[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80185514[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80185590[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80185590[a1 & 0x7F]; +} + + + +extern s32 D_801855B0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801855B0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018562C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018562C[a1 & 0x7F]; +} + + + +extern u8 D_8018564C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018564C[a1 & 0x7F]; +} + + + +extern u8 D_8018566C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018566C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018568C[])(void); + D_8018568C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80185708[])(void); + +void func_80165AC8(void) { + D_80185708[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80185784[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80185784[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801962F8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801962F8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80185790[])(void); + +void func_80166018(void *a0) { + D_80185790[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80185798[])(void); + +void func_801663FC(void *a0) { + D_80185798[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80185860[])(void); + +void func_80166618(void *a0) { + D_80185860[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80185870[])(void); + +void func_80166654(void *a0) { + D_80185870[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80196B88[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80196B88[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80196B88). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80196B88[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80196B88)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80196B88[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80196B88[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801857B4[]; + extern u8 D_801857A0[]; + extern u8 D_801857C8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801857B4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801857A0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801857C8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80167714); + + +extern void (*D_80185880[])(void); + +void func_801678B4(void *a0) { + D_80185880[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018588C[])(void); + +void func_80167A9C(void *a0) { + D_8018588C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80185998; + extern u8 D_801859AC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80185998); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801859AC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801857EC[]; +extern u8 D_80185800[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801857EC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80185800; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801858A4[])(void); + +void func_80168744(void *a0) { + D_801858A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80185894 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80185894[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80185894; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801858AC[])(void); + +void func_801689D8(void *a0) { + D_801858AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801858B4[])(void); + +void func_80168AA8(void *a0) { + D_801858B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801858BC[])(void); + +void func_80168D58(void *a0) { + D_801858BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801858C4[])(void); + +void func_8016901C(void *a0) { + D_801858C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_116/nonmatchings/ov_SC03_116_jr_8015C32C", func_80169228); + + +extern void (*D_801858CC[])(void); + +void func_801693CC(void *a0) { + D_801858CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801858D4[])(void); + +void func_80169830(void *a0) { + D_801858D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80185988[])(void); + +void func_80169B80(void *a0) { + D_80185988[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801858DC[]; + extern u8 D_8018594C[]; + extern u8 D_8018597C[]; + extern u8 D_80197C08[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018597C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801858DC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80197C08; + RotMatrixYXZ(rot, D_80197C08); + func_80048D9C(D_80197C08, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018594C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80185990[])(void); + +void func_80169F00(void *a0) { + D_80185990[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80185940[]; +extern char D_80185900[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80185940, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80185900); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801859C8[])(void); + +void func_8016A020(void *a0) { + D_801859C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80185998; + extern u8 D_801859AC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80185998); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801859AC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801859D4[])(void); + +void func_8016A700(void *a0) { + D_801859D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80185A1C[])(void); + +void func_8016AB30(void *a0) { + D_80185A1C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_117/ov_SC03_117_jr_8015AE2C.c b/src/ov_SC03_117/ov_SC03_117_jr_8015AE2C.c index 58bbd115b..c42c70693 100644 --- a/src/ov_SC03_117/ov_SC03_117_jr_8015AE2C.c +++ b/src/ov_SC03_117/ov_SC03_117_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801870E4[])(void); - -void func_8015C714(void *a0) { - D_801870E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80186F58[])(void*); - extern int D_80186EFC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80186F58)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80186F58)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186EFC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80186F58[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80186F58[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80186F58[])(void*); - extern int D_80186EFC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80186F58)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186EFC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80186F58)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801870F4[])(void); - D_801870F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80186F58[])(struct Ent_8015CD20 *); - extern u8 D_80186F0C; - extern u8 D_801870FC; - extern u8 D_8018710C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80186F58[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F0C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801870FC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018710C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80186F58[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018712C[])(void); - D_8018712C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018711C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018711C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80186F58[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80187188; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80187188, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018626C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018626C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80187190[])(void); - D_80187190[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018719C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018719C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018719C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018719C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80186F58[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018719C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80186F1C[]; - extern u8 D_80186F2C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F1C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F2C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018719C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018719C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018719C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801871D0[])(void); - D_801871D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186F58[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801871D8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801871F0[])(void); - D_801871F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186F58[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801871D8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80187210[])(void); - D_80187210[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80186F58[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186F58)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80187220; -extern u16 D_80187222; -extern u16 D_80187224; -extern s32 D_80187228; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80187220 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80187222 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187224 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187228, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80187230; - -void func_8015E588(void) { - func_8013C9C4(&D_80187230); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80186F58[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186F58)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80187244[])(void); - D_80187244[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80186F58[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80186F58[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018724C[])(void); - D_8018724C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80186F3C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186F3C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80186F58[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187254[])(void); - D_80187254[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80186F58[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80186F58[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018725C[])(void); - D_8018725C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80186F58[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80187264; - extern s32 D_80187274; - extern s32 D_80187284; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80186F58[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187264); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187274); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80186F58[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187284); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80187294[])(void); - D_80187294[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80186F58[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80186F58[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80186F58[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186F58[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801872A0[])(void); - D_801872A0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80186F58[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186F58[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80186F58[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186F58[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801872B4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801872B4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80186F58[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80186F58)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80186F58[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186F58[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80187330[])(void); - D_80187330[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80186F58[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80186F58)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80187340[])(void); - D_80187340[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80186F58[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80186F58[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80186F58[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80186F58[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80186F58[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80186F58[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80186F58[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80187348[])(void); - D_80187348[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80186F58[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80186F58)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80186F58[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80186F58)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187354[])(void); - D_80187354[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186F58 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80186F58[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80186F58[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80186F58[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80187364[])(void); - -void func_80160EA4(void *a0) { - D_80187364[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80186F58[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80186F58[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80187394[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80187394[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801873F8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801873F8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801CD188[]; - extern u8 D_801873C4[]; - extern u8 D_801873E4[]; - extern u8 D_801CD194[]; - extern u8 D_801CD1BC[]; - extern u8 D_801CD1D4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801CD188[0] = p; - func_80024054(&D_801873C4, &D_801CD194); - func_8001CE28(p, &D_801CD194); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801CD188[1] = p; - func_80024054(&D_801873E4, &D_801CD1BC); - func_8001CE28(p, &D_801CD1BC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801CD188[2] = p; - func_800242D0((s16)func_801620C4(), &D_801CD1D4, 0x84); - func_8001CE68(p, &D_801CD1D4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801CD1D4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CD188[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801CD188; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801873F8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801873F8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801873F8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801873F8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801CD188[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801CD188; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018741C[])(void); - -void func_80162330(void *a0) { - D_8018741C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801CD1E0[i] via `extern int D_801CD1E0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80187428[]; - extern s32 D_80187440; - extern u8 D_801CD1EC[]; - extern u8 D_801CD214[]; - extern u8 D_801CD230[]; - extern int D_801CD1E0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801CD1E0[0] = (s32)item; - func_80024054(D_80187428, D_801CD1EC); - func_8001CE28(item, D_801CD1EC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801CD1E0[1] = (s32)item; - func_80024054(((u8 *)&D_80187440), D_801CD214); - func_8001CE28(item, D_801CD214); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801CD1E0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801CD230, 0x84); - func_8001CE68(item, D_801CD230); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801CD230, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801CD1E0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801CD1E0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187464[])(void); - -void func_80162834(void *a0) { - D_80187464[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187454; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187454, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801CC988[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801CC988, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801CC988[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801CC988, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018746C[])(void); - -void func_80163A58(void *a0) { - D_8018746C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801CC990; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801CC990; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801874C0[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801874C0[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80187488; -extern s16 D_801874BC; -extern s16 D_801874BA; -extern s16 D_801874B8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80187488; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801874BC = 0x80; - D_801874BA = 0x80; - D_801874B8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801874BC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801874BC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801874BC - 8; - D_801874BC = nv; - D_801874BA = nv; - D_801874B8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801874CC[])(void); - -void func_80164BA0(void *a0) { - D_801874CC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801CD240; -extern u8 D_801CD241; -extern u8 D_801CD242; -extern u8 D_801CD243; -extern u8 D_801CD244; -extern u8 D_801CD245; -extern u8 D_801CD246; -extern u8 D_801CD247; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801CD240; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801CD241 = 0xf0; - *(u8 *)base = 0xf0; - D_801CD242 = 0xc0; - D_801CD246 = 0; - D_801CD245 = 0; - D_801CD244 = 0; - D_801CD247 = 0; - D_801CD243 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801CD240; -extern u8 D_801CD241; -extern u8 D_801CD242; - -s32 func_80164E40(void) { - u8 *p = &D_801CD240; - if (*p != 0) { - *p -= 0x10; - } - if (D_801CD241 != 0) { - D_801CD241 -= 0x10; - } - if (D_801CD242 != 0) { - D_801CD242 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801874DC[])(void); - -void func_80164EA4(void *a0) { - D_801874DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801CD28C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801CD28C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801CD280[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801CD280[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801CD280[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801CD280; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801CD280; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801874F0[]; - extern u32 D_80187510, D_80187514, D_80187518, D_8018751C; - extern u32 D_80187510, D_80187514, D_80187518, D_8018751C; - extern u32 D_80187510, D_80187514, D_80187518, D_8018751C; - extern u32 D_80187510, D_80187514, D_80187518, D_8018751C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801874F0[0x00], p); - ApplyMatrixSV(mat, &D_801874F0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801874F0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801874F0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80187518; - *(u32 *)(prim + 0x24) = D_80187510; - *(u32 *)(prim + 0x28) = D_8018751C; - *(u32 *)(prim + 0x2c) = D_80187514; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187520[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187520[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187520[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187520[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018759C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018759C[a1 & 0x7F]; -} - - - -extern s32 D_801875BC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801875BC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80187638[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80187638[a1 & 0x7F]; -} - - - -extern u8 D_80187658[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80187658[a1 & 0x7F]; -} - - - -extern u8 D_80187678[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80187678[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80187698[])(void); - D_80187698[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187714[])(void); - -void func_80165AC8(void) { - D_80187714[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80187790[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80187790[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801CC998; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801CC998, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018779C[])(void); - -void func_80166018(void *a0) { - D_8018779C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801877A4[])(void); - -void func_801663FC(void *a0) { - D_801877A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018786C[])(void); - -void func_80166618(void *a0) { - D_8018786C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018787C[])(void); - -void func_80166654(void *a0) { - D_8018787C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801CD300[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801CD300[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CD300). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801CD300[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801CD300)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801CD300[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801CD300[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801877C0[]; - extern u8 D_801877AC[]; - extern u8 D_801877D4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801877C0; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801877AC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801877D4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80167714); - - -extern void (*D_8018788C[])(void); - -void func_801678B4(void *a0) { - D_8018788C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80187898[])(void); - -void func_80167A9C(void *a0) { - D_80187898[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801879A4; - extern u8 D_801879B8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801879A4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801879B8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801877F8[]; -extern u8 D_8018780C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801877F8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018780C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801878B0[])(void); - -void func_80168744(void *a0) { - D_801878B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801878A0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801878A0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801878A0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801878B8[])(void); - -void func_801689D8(void *a0) { - D_801878B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801878C0[])(void); - -void func_80168AA8(void *a0) { - D_801878C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801878C8[])(void); - -void func_80168D58(void *a0) { - D_801878C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801878D0[])(void); - -void func_8016901C(void *a0) { - D_801878D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015AE2C", func_80169228); - - -extern void (*D_801878D8[])(void); - -void func_801693CC(void *a0) { - D_801878D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801878E0[])(void); - -void func_80169830(void *a0) { - D_801878E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187994[])(void); - -void func_80169B80(void *a0) { - D_80187994[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801878E8[]; - extern u8 D_80187958[]; - extern u8 D_80187988[]; - extern u8 D_801CE800[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80187988, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801878E8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801CE800; - RotMatrixYXZ(rot, D_801CE800); - func_80048D9C(D_801CE800, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80187958); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018799C[])(void); - -void func_80169F00(void *a0) { - D_8018799C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018794C[]; -extern char D_8018790C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018794C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018790C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801879D4[])(void); - -void func_8016A020(void *a0) { - D_801879D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801879A4; - extern u8 D_801879B8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801879A4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801879B8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801879E0[])(void); - -void func_8016A700(void *a0) { - D_801879E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80187A28[])(void); - -void func_8016AB30(void *a0) { - D_80187A28[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c b/src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c new file mode 100644 index 000000000..59e325066 --- /dev/null +++ b/src/ov_SC03_117/ov_SC03_117_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80186DF4; +extern u8 D_80186D64; +extern u8 D_80186D40; +extern u8 D_80186D1C; +extern u8 D_80186DD0; +extern u8 D_80186DAC; +extern u8 D_80186D88; +extern u8 D_80186CF8; +extern void func_80145934(void); +extern u8 D_80186E84; +extern u8 D_80186E60; +extern u8 D_80186E3C; +extern u8 D_80186E18; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018627C[]; +extern unsigned char D_801862AC[]; +extern unsigned char D_801862FC[]; +extern unsigned char D_8018632C[]; +extern unsigned char D_8018635C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801863AC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80186474[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801864FC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186504; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801CD130; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801CD134; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186534; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801865DC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80186600[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801865F0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186614[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80186620[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80186630[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80186648[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80186638; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018665C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80186678[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80186668; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018668C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801866A0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801866B4; +extern void (*D_801866DC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801866BC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80186728[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018672C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186B90[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80186BA0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801CD168; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80186BC8[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80186BA8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80186BB8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80186C08[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80186C10[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80186BDC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80186C1C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80186BEC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801CD170; +extern s32 D_801CD17C; +extern s32 D_801CD180; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80186C58[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80186C2C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801CD178; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80186EA8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80186CC8[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80186F4C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801870A0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186EBC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801870A8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186ECC; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80186EEC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801870B0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801870D8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80186F58[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801870E4[])(void); + +void func_8015C714(void *a0) { + D_801870E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80186F58[])(void*); + extern int D_80186EFC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80186F58)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80186F58)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186EFC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80186F58[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80186F58[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80186F58[])(void*); + extern int D_80186EFC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80186F58)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186EFC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80186F58)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801870F4[])(void); + D_801870F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80186F58[])(struct Ent_8015CD20 *); + extern u8 D_80186F0C; + extern u8 D_801870FC; + extern u8 D_8018710C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80186F58[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F0C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801870FC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018710C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80186F58[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018712C[])(void); + D_8018712C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018711C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018711C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80186F58[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80187188; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80187188, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018626C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018626C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80187190[])(void); + D_80187190[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018719C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018719C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018719C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018719C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80186F58[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018719C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80186F1C[]; + extern u8 D_80186F2C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F1C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186F2C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018719C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018719C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018719C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801871D0[])(void); + D_801871D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186F58[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801871D8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801871F0[])(void); + D_801871F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186F58[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801871D8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801871D8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80187210[])(void); + D_80187210[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80186F58[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186F58)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80187220; +extern u16 D_80187222; +extern u16 D_80187224; +extern s32 D_80187228; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80187220 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80187222 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187224 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187228, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80187230; + +void func_8015E588(void) { + func_8013C9C4(&D_80187230); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80186F58[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186F58)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80187244[])(void); + D_80187244[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80186F58[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80186F58[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018724C[])(void); + D_8018724C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80186F3C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186F3C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80186F58[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187254[])(void); + D_80187254[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80186F58[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80186F58[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018725C[])(void); + D_8018725C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80186F58[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80187264; + extern s32 D_80187274; + extern s32 D_80187284; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187264); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187274); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80186F58[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187284); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80187294[])(void); + D_80187294[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80186F58[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80186F58[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80186F58[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186F58[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801872A0[])(void); + D_801872A0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80186F58[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186F58[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80186F58[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186F58[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801872B4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801872B4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80186F58[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80186F58)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80186F58[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186F58[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80187330[])(void); + D_80187330[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80186F58[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80186F58)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80187340[])(void); + D_80187340[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80186F58[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80186F58[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80186F58[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80186F58[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80186F58[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80186F58[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80186F58[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80187348[])(void); + D_80187348[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80186F58[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80186F58)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80186F58[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80186F58)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187354[])(void); + D_80187354[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186F58 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80186F58[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80186F58[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80186F58[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80187364[])(void); + +void func_80160EA4(void *a0) { + D_80187364[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80186F58[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80186F58[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80187394[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80187394[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801873F8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801873F8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801CD188[]; + extern u8 D_801873C4[]; + extern u8 D_801873E4[]; + extern u8 D_801CD194[]; + extern u8 D_801CD1BC[]; + extern u8 D_801CD1D4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801CD188[0] = p; + func_80024054(&D_801873C4, &D_801CD194); + func_8001CE28(p, &D_801CD194); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801CD188[1] = p; + func_80024054(&D_801873E4, &D_801CD1BC); + func_8001CE28(p, &D_801CD1BC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801CD188[2] = p; + func_800242D0((s16)func_801620C4(), &D_801CD1D4, 0x84); + func_8001CE68(p, &D_801CD1D4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801CD1D4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CD188[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801CD188; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801873F8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801873F8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801873F8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801873F8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801CD188[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801CD188; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018741C[])(void); + +void func_80162330(void *a0) { + D_8018741C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801CD1E0[i] via `extern int D_801CD1E0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80187428[]; + extern s32 D_80187440; + extern u8 D_801CD1EC[]; + extern u8 D_801CD214[]; + extern u8 D_801CD230[]; + extern int D_801CD1E0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801CD1E0[0] = (s32)item; + func_80024054(D_80187428, D_801CD1EC); + func_8001CE28(item, D_801CD1EC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801CD1E0[1] = (s32)item; + func_80024054(((u8 *)&D_80187440), D_801CD214); + func_8001CE28(item, D_801CD214); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801CD1E0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801CD230, 0x84); + func_8001CE68(item, D_801CD230); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801CD230, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801CD1E0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801CD1E0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_801627E8); + + +extern void (*D_80187464[])(void); + +void func_80162834(void *a0) { + D_80187464[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187454; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187454, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801CC988[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801CC988, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801CC988[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801CC988, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018746C[])(void); + +void func_80163A58(void *a0) { + D_8018746C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801CC990; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801CC990; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801874C0[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801874C0[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80187488; +extern s16 D_801874BC; +extern s16 D_801874BA; +extern s16 D_801874B8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80187488; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801874BC = 0x80; + D_801874BA = 0x80; + D_801874B8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801874BC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801874BC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801874BC - 8; + D_801874BC = nv; + D_801874BA = nv; + D_801874B8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801874CC[])(void); + +void func_80164BA0(void *a0) { + D_801874CC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801CD240; +extern u8 D_801CD241; +extern u8 D_801CD242; +extern u8 D_801CD243; +extern u8 D_801CD244; +extern u8 D_801CD245; +extern u8 D_801CD246; +extern u8 D_801CD247; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801CD240; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801CD241 = 0xf0; + *(u8 *)base = 0xf0; + D_801CD242 = 0xc0; + D_801CD246 = 0; + D_801CD245 = 0; + D_801CD244 = 0; + D_801CD247 = 0; + D_801CD243 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801CD240; +extern u8 D_801CD241; +extern u8 D_801CD242; + +s32 func_80164E40(void) { + u8 *p = &D_801CD240; + if (*p != 0) { + *p -= 0x10; + } + if (D_801CD241 != 0) { + D_801CD241 -= 0x10; + } + if (D_801CD242 != 0) { + D_801CD242 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801874DC[])(void); + +void func_80164EA4(void *a0) { + D_801874DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801CD28C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801CD28C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801CD280[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801CD280[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801CD280[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801CD280; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801CD280; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801874F0[]; + extern u32 D_80187510, D_80187514, D_80187518, D_8018751C; + extern u32 D_80187510, D_80187514, D_80187518, D_8018751C; + extern u32 D_80187510, D_80187514, D_80187518, D_8018751C; + extern u32 D_80187510, D_80187514, D_80187518, D_8018751C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801874F0[0x00], p); + ApplyMatrixSV(mat, &D_801874F0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801874F0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801874F0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80187518; + *(u32 *)(prim + 0x24) = D_80187510; + *(u32 *)(prim + 0x28) = D_8018751C; + *(u32 *)(prim + 0x2c) = D_80187514; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187520[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187520[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187520[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187520[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018759C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018759C[a1 & 0x7F]; +} + + + +extern s32 D_801875BC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801875BC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80187638[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80187638[a1 & 0x7F]; +} + + + +extern u8 D_80187658[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80187658[a1 & 0x7F]; +} + + + +extern u8 D_80187678[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80187678[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80187698[])(void); + D_80187698[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187714[])(void); + +void func_80165AC8(void) { + D_80187714[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80187790[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80187790[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801CC998; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801CC998, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018779C[])(void); + +void func_80166018(void *a0) { + D_8018779C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801877A4[])(void); + +void func_801663FC(void *a0) { + D_801877A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018786C[])(void); + +void func_80166618(void *a0) { + D_8018786C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018787C[])(void); + +void func_80166654(void *a0) { + D_8018787C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801CD300[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801CD300[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801CD300). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801CD300[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801CD300)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801CD300[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801CD300[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801877C0[]; + extern u8 D_801877AC[]; + extern u8 D_801877D4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801877C0; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801877AC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801877D4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80167714); + + +extern void (*D_8018788C[])(void); + +void func_801678B4(void *a0) { + D_8018788C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80187898[])(void); + +void func_80167A9C(void *a0) { + D_80187898[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801879A4; + extern u8 D_801879B8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801879A4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801879B8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801877F8[]; +extern u8 D_8018780C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801877F8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018780C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801878B0[])(void); + +void func_80168744(void *a0) { + D_801878B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801878A0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801878A0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801878A0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801878B8[])(void); + +void func_801689D8(void *a0) { + D_801878B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801878C0[])(void); + +void func_80168AA8(void *a0) { + D_801878C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801878C8[])(void); + +void func_80168D58(void *a0) { + D_801878C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801878D0[])(void); + +void func_8016901C(void *a0) { + D_801878D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_117/nonmatchings/ov_SC03_117_jr_8015C32C", func_80169228); + + +extern void (*D_801878D8[])(void); + +void func_801693CC(void *a0) { + D_801878D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801878E0[])(void); + +void func_80169830(void *a0) { + D_801878E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187994[])(void); + +void func_80169B80(void *a0) { + D_80187994[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801878E8[]; + extern u8 D_80187958[]; + extern u8 D_80187988[]; + extern u8 D_801CE800[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80187988, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801878E8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801CE800; + RotMatrixYXZ(rot, D_801CE800); + func_80048D9C(D_801CE800, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80187958); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018799C[])(void); + +void func_80169F00(void *a0) { + D_8018799C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018794C[]; +extern char D_8018790C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018794C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018790C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801879D4[])(void); + +void func_8016A020(void *a0) { + D_801879D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801879A4; + extern u8 D_801879B8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801879A4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801879B8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801879E0[])(void); + +void func_8016A700(void *a0) { + D_801879E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80187A28[])(void); + +void func_8016AB30(void *a0) { + D_80187A28[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_118/ov_SC03_118_jr_8015AE2C.c b/src/ov_SC03_118/ov_SC03_118_jr_8015AE2C.c index 29cf0bb2f..709a7e5f3 100644 --- a/src/ov_SC03_118/ov_SC03_118_jr_8015AE2C.c +++ b/src/ov_SC03_118/ov_SC03_118_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018C190[])(void); - -void func_8015C714(void *a0) { - D_8018C190[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018C004[])(void*); - extern int D_8018BFA8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BFA8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018C004[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018C004[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018C004[])(void*); - extern int D_8018BFA8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BFA8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018C1A0[])(void); - D_8018C1A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018C004[])(struct Ent_8015CD20 *); - extern u8 D_8018BFB8; - extern u8 D_8018C1A8; - extern u8 D_8018C1B8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018C004[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BFB8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C1A8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C1B8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018C004[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018C1D8[])(void); - D_8018C1D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018C1C8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018C1C8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018C004[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018C234; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018C234, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018B318[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018B318; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018C23C[])(void); - D_8018C23C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018C248[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018C248[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018C248[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018C248[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018C004[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018C248[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018BFC8[]; - extern u8 D_8018BFD8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BFC8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BFD8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018C27C[])(void); - D_8018C27C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018C004[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018C284[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018C29C[])(void); - D_8018C29C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018C004[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018C284[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018C2BC[])(void); - D_8018C2BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018C004[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018C004)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018C2CC; -extern u16 D_8018C2CE; -extern u16 D_8018C2D0; -extern s32 D_8018C2D4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018C2CC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018C2CE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018C2D0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018C2D4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018C2DC; - -void func_8015E588(void) { - func_8013C9C4(&D_8018C2DC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018C004[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018C004)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018C2F0[])(void); - D_8018C2F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018C004[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018C004[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018C2F8[])(void); - D_8018C2F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018BFE8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018BFE8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018C004[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018C300[])(void); - D_8018C300[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018C004[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018C004[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018C308[])(void); - D_8018C308[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018C004[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018C310; - extern s32 D_8018C320; - extern s32 D_8018C330; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018C004[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C310); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C320); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018C004[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C330); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018C340[])(void); - D_8018C340[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018C004[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018C004[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018C34C[])(void); - D_8018C34C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018C004[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018C004[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018C004[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018C360[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018C360[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018C004[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018C004)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018C004[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018C004[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018C3DC[])(void); - D_8018C3DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018C004[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018C004)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018C3EC[])(void); - D_8018C3EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018C004[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018C004[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018C004[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018C004[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018C004[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018C004[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018C004[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018C3F4[])(void); - D_8018C3F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018C004[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018C004)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018C004[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018C400[])(void); - D_8018C400[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018C004 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018C004[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018C004[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018C004[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018C410[])(void); - -void func_80160EA4(void *a0) { - D_8018C410[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018C004[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018C004[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018C440[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018C440[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018C4A4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018C4A4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801D30D8[]; - extern u8 D_8018C470[]; - extern u8 D_8018C490[]; - extern u8 D_801D30E4[]; - extern u8 D_801D310C[]; - extern u8 D_801D3124[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801D30D8[0] = p; - func_80024054(&D_8018C470, &D_801D30E4); - func_8001CE28(p, &D_801D30E4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801D30D8[1] = p; - func_80024054(&D_8018C490, &D_801D310C); - func_8001CE28(p, &D_801D310C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801D30D8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801D3124, 0x84); - func_8001CE68(p, &D_801D3124); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801D3124, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D30D8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801D30D8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018C4A4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018C4A4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018C4A4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018C4A4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801D30D8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801D30D8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018C4C8[])(void); - -void func_80162330(void *a0) { - D_8018C4C8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801D3130[i] via `extern int D_801D3130[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018C4D4[]; - extern s32 D_8018C4EC; - extern u8 D_801D313C[]; - extern u8 D_801D3164[]; - extern u8 D_801D3180[]; - extern int D_801D3130[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801D3130[0] = (s32)item; - func_80024054(D_8018C4D4, D_801D313C); - func_8001CE28(item, D_801D313C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801D3130[1] = (s32)item; - func_80024054(((u8 *)&D_8018C4EC), D_801D3164); - func_8001CE28(item, D_801D3164); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801D3130[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801D3180, 0x84); - func_8001CE68(item, D_801D3180); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801D3180, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D3130[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801D3130; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018C510[])(void); - -void func_80162834(void *a0) { - D_8018C510[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018C500; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018C500, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801D28E4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801D28E4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801D28E4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801D28E4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018C518[])(void); - -void func_80163A58(void *a0) { - D_8018C518[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801D28EC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801D28EC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018C56C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018C56C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018C534; -extern s16 D_8018C568; -extern s16 D_8018C566; -extern s16 D_8018C564; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018C534; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018C568 = 0x80; - D_8018C566 = 0x80; - D_8018C564 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018C568 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018C568` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018C568 - 8; - D_8018C568 = nv; - D_8018C566 = nv; - D_8018C564 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018C578[])(void); - -void func_80164BA0(void *a0) { - D_8018C578[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801D3190; -extern u8 D_801D3191; -extern u8 D_801D3192; -extern u8 D_801D3193; -extern u8 D_801D3194; -extern u8 D_801D3195; -extern u8 D_801D3196; -extern u8 D_801D3197; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801D3190; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801D3191 = 0xf0; - *(u8 *)base = 0xf0; - D_801D3192 = 0xc0; - D_801D3196 = 0; - D_801D3195 = 0; - D_801D3194 = 0; - D_801D3197 = 0; - D_801D3193 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801D3190; -extern u8 D_801D3191; -extern u8 D_801D3192; - -s32 func_80164E40(void) { - u8 *p = &D_801D3190; - if (*p != 0) { - *p -= 0x10; - } - if (D_801D3191 != 0) { - D_801D3191 -= 0x10; - } - if (D_801D3192 != 0) { - D_801D3192 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018C588[])(void); - -void func_80164EA4(void *a0) { - D_8018C588[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801D31DC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801D31DC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801D31D0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801D31D0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801D31D0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801D31D0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801D31D0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018C59C[]; - extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; - extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; - extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; - extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018C59C[0x00], p); - ApplyMatrixSV(mat, &D_8018C59C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018C59C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018C59C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018C5C4; - *(u32 *)(prim + 0x24) = D_8018C5BC; - *(u32 *)(prim + 0x28) = D_8018C5C8; - *(u32 *)(prim + 0x2c) = D_8018C5C0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018C5CC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018C5CC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018C5CC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018C5CC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018C648[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018C648[a1 & 0x7F]; -} - - - -extern s32 D_8018C668[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018C668[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018C6E4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018C6E4[a1 & 0x7F]; -} - - - -extern u8 D_8018C704[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018C704[a1 & 0x7F]; -} - - - -extern u8 D_8018C724[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018C724[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018C744[])(void); - D_8018C744[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018C7C0[])(void); - -void func_80165AC8(void) { - D_8018C7C0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018C83C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018C83C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801D28F4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801D28F4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018C848[])(void); - -void func_80166018(void *a0) { - D_8018C848[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018C850[])(void); - -void func_801663FC(void *a0) { - D_8018C850[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018C918[])(void); - -void func_80166618(void *a0) { - D_8018C918[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018C928[])(void); - -void func_80166654(void *a0) { - D_8018C928[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801D3250[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801D3250[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D3250). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801D3250[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801D3250)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801D3250[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801D3250[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018C86C[]; - extern u8 D_8018C858[]; - extern u8 D_8018C880[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018C86C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018C858; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018C880; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80167714); - - -extern void (*D_8018C938[])(void); - -void func_801678B4(void *a0) { - D_8018C938[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018C944[])(void); - -void func_80167A9C(void *a0) { - D_8018C944[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018CA50; - extern u8 D_8018CA64[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018CA50); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018CA64; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018C8A4[]; -extern u8 D_8018C8B8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018C8A4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018C8B8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018C95C[])(void); - -void func_80168744(void *a0) { - D_8018C95C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018C94C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018C94C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018C94C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018C964[])(void); - -void func_801689D8(void *a0) { - D_8018C964[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018C96C[])(void); - -void func_80168AA8(void *a0) { - D_8018C96C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018C974[])(void); - -void func_80168D58(void *a0) { - D_8018C974[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018C97C[])(void); - -void func_8016901C(void *a0) { - D_8018C97C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015AE2C", func_80169228); - - -extern void (*D_8018C984[])(void); - -void func_801693CC(void *a0) { - D_8018C984[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018C98C[])(void); - -void func_80169830(void *a0) { - D_8018C98C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018CA40[])(void); - -void func_80169B80(void *a0) { - D_8018CA40[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018C994[]; - extern u8 D_8018CA04[]; - extern u8 D_8018CA34[]; - extern u8 D_801D4708[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018CA34, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018C994[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801D4708; - RotMatrixYXZ(rot, D_801D4708); - func_80048D9C(D_801D4708, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018CA04); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018CA48[])(void); - -void func_80169F00(void *a0) { - D_8018CA48[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018C9F8[]; -extern char D_8018C9B8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018C9F8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018C9B8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018CA80[])(void); - -void func_8016A020(void *a0) { - D_8018CA80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018CA50; - extern u8 D_8018CA64[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018CA50); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018CA64; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018CA8C[])(void); - -void func_8016A700(void *a0) { - D_8018CA8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018CAD4[])(void); - -void func_8016AB30(void *a0) { - D_8018CAD4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c b/src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c new file mode 100644 index 000000000..ad17dd2b2 --- /dev/null +++ b/src/ov_SC03_118/ov_SC03_118_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018BEA0; +extern u8 D_8018BE10; +extern u8 D_8018BDEC; +extern u8 D_8018BDC8; +extern u8 D_8018BE7C; +extern u8 D_8018BE58; +extern u8 D_8018BE34; +extern u8 D_8018BDA4; +extern void func_80145934(void); +extern u8 D_8018BF30; +extern u8 D_8018BF0C; +extern u8 D_8018BEE8; +extern u8 D_8018BEC4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018B328[]; +extern unsigned char D_8018B358[]; +extern unsigned char D_8018B3A8[]; +extern unsigned char D_8018B3D8[]; +extern unsigned char D_8018B408[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018B458[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018B520[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018B5A8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018B5B0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801D3080; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801D3084; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018B5E0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018B688[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018B6AC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018B69C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018B6C0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018B6CC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018B6DC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018B6F4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018B6E4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018B708[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018B724[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018B714; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018B738[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018B74C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018B760; +extern void (*D_8018B788[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018B768; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018B7D4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018B7D8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018BC3C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018BC4C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801D30B8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018BC74[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018BC54; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018BC64; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018BCB4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018BCBC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018BC88; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018BCC8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018BC98; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801D30C0; +extern s32 D_801D30CC; +extern s32 D_801D30D0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018BD04[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018BCD8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801D30C8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018BF54[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018BD74[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018BFF8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018C14C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018BF68; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018C154[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018BF78; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018BF98; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018C15C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018C184[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018C004[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018C190[])(void); + +void func_8015C714(void *a0) { + D_8018C190[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018C004[])(void*); + extern int D_8018BFA8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BFA8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018C004[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018C004[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018C004[])(void*); + extern int D_8018BFA8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BFA8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018C1A0[])(void); + D_8018C1A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018C004[])(struct Ent_8015CD20 *); + extern u8 D_8018BFB8; + extern u8 D_8018C1A8; + extern u8 D_8018C1B8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018C004[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BFB8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C1A8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C1B8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018C004[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018C1D8[])(void); + D_8018C1D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018C1C8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018C1C8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018C004[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018C234; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018C234, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018B318[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018B318; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018C23C[])(void); + D_8018C23C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018C248[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018C248[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018C248[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018C248[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018C004[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018C248[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018BFC8[]; + extern u8 D_8018BFD8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BFC8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BFD8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018C27C[])(void); + D_8018C27C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018C004[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018C284[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018C29C[])(void); + D_8018C29C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018C004[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018C284[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018C2BC[])(void); + D_8018C2BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018C004[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018C004)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018C2CC; +extern u16 D_8018C2CE; +extern u16 D_8018C2D0; +extern s32 D_8018C2D4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018C2CC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018C2CE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018C2D0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018C2D4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018C2DC; + +void func_8015E588(void) { + func_8013C9C4(&D_8018C2DC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018C004[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018C004)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018C2F0[])(void); + D_8018C2F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018C004[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018C004[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018C2F8[])(void); + D_8018C2F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018BFE8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018BFE8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018C004[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018C300[])(void); + D_8018C300[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018C004[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018C004[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018C308[])(void); + D_8018C308[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018C004[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018C310; + extern s32 D_8018C320; + extern s32 D_8018C330; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C310); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C320); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C330); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018C340[])(void); + D_8018C340[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018C004[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018C004[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018C34C[])(void); + D_8018C34C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018C004[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018C004[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018C004[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018C360[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018C360[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018C004[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018C004)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018C004[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018C004[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018C3DC[])(void); + D_8018C3DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018C004[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018C004)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018C3EC[])(void); + D_8018C3EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018C004[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018C004[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018C004[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018C004[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018C004[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018C004[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018C004[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018C3F4[])(void); + D_8018C3F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018C004[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018C004)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018C004[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018C400[])(void); + D_8018C400[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018C004 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018C004[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018C004[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018C004[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018C410[])(void); + +void func_80160EA4(void *a0) { + D_8018C410[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018C004[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018C004[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018C440[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018C440[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018C4A4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018C4A4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801D30D8[]; + extern u8 D_8018C470[]; + extern u8 D_8018C490[]; + extern u8 D_801D30E4[]; + extern u8 D_801D310C[]; + extern u8 D_801D3124[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801D30D8[0] = p; + func_80024054(&D_8018C470, &D_801D30E4); + func_8001CE28(p, &D_801D30E4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801D30D8[1] = p; + func_80024054(&D_8018C490, &D_801D310C); + func_8001CE28(p, &D_801D310C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801D30D8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801D3124, 0x84); + func_8001CE68(p, &D_801D3124); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801D3124, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D30D8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801D30D8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018C4A4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018C4A4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018C4A4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018C4A4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801D30D8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801D30D8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018C4C8[])(void); + +void func_80162330(void *a0) { + D_8018C4C8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801D3130[i] via `extern int D_801D3130[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018C4D4[]; + extern s32 D_8018C4EC; + extern u8 D_801D313C[]; + extern u8 D_801D3164[]; + extern u8 D_801D3180[]; + extern int D_801D3130[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801D3130[0] = (s32)item; + func_80024054(D_8018C4D4, D_801D313C); + func_8001CE28(item, D_801D313C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801D3130[1] = (s32)item; + func_80024054(((u8 *)&D_8018C4EC), D_801D3164); + func_8001CE28(item, D_801D3164); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801D3130[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801D3180, 0x84); + func_8001CE68(item, D_801D3180); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801D3180, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D3130[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801D3130; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_801627E8); + + +extern void (*D_8018C510[])(void); + +void func_80162834(void *a0) { + D_8018C510[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018C500; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018C500, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801D28E4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801D28E4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801D28E4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801D28E4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018C518[])(void); + +void func_80163A58(void *a0) { + D_8018C518[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801D28EC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801D28EC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018C56C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018C56C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018C534; +extern s16 D_8018C568; +extern s16 D_8018C566; +extern s16 D_8018C564; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018C534; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018C568 = 0x80; + D_8018C566 = 0x80; + D_8018C564 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018C568 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018C568` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018C568 - 8; + D_8018C568 = nv; + D_8018C566 = nv; + D_8018C564 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018C578[])(void); + +void func_80164BA0(void *a0) { + D_8018C578[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801D3190; +extern u8 D_801D3191; +extern u8 D_801D3192; +extern u8 D_801D3193; +extern u8 D_801D3194; +extern u8 D_801D3195; +extern u8 D_801D3196; +extern u8 D_801D3197; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801D3190; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801D3191 = 0xf0; + *(u8 *)base = 0xf0; + D_801D3192 = 0xc0; + D_801D3196 = 0; + D_801D3195 = 0; + D_801D3194 = 0; + D_801D3197 = 0; + D_801D3193 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801D3190; +extern u8 D_801D3191; +extern u8 D_801D3192; + +s32 func_80164E40(void) { + u8 *p = &D_801D3190; + if (*p != 0) { + *p -= 0x10; + } + if (D_801D3191 != 0) { + D_801D3191 -= 0x10; + } + if (D_801D3192 != 0) { + D_801D3192 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018C588[])(void); + +void func_80164EA4(void *a0) { + D_8018C588[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801D31DC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801D31DC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801D31D0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801D31D0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801D31D0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801D31D0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801D31D0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018C59C[]; + extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; + extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; + extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; + extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018C59C[0x00], p); + ApplyMatrixSV(mat, &D_8018C59C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018C59C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018C59C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018C5C4; + *(u32 *)(prim + 0x24) = D_8018C5BC; + *(u32 *)(prim + 0x28) = D_8018C5C8; + *(u32 *)(prim + 0x2c) = D_8018C5C0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018C5CC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018C5CC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018C5CC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018C5CC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018C648[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018C648[a1 & 0x7F]; +} + + + +extern s32 D_8018C668[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018C668[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018C6E4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018C6E4[a1 & 0x7F]; +} + + + +extern u8 D_8018C704[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018C704[a1 & 0x7F]; +} + + + +extern u8 D_8018C724[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018C724[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018C744[])(void); + D_8018C744[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018C7C0[])(void); + +void func_80165AC8(void) { + D_8018C7C0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018C83C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018C83C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801D28F4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801D28F4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018C848[])(void); + +void func_80166018(void *a0) { + D_8018C848[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018C850[])(void); + +void func_801663FC(void *a0) { + D_8018C850[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018C918[])(void); + +void func_80166618(void *a0) { + D_8018C918[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018C928[])(void); + +void func_80166654(void *a0) { + D_8018C928[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801D3250[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801D3250[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D3250). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801D3250[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801D3250)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801D3250[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801D3250[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018C86C[]; + extern u8 D_8018C858[]; + extern u8 D_8018C880[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018C86C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018C858; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018C880; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80167714); + + +extern void (*D_8018C938[])(void); + +void func_801678B4(void *a0) { + D_8018C938[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018C944[])(void); + +void func_80167A9C(void *a0) { + D_8018C944[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018CA50; + extern u8 D_8018CA64[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018CA50); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018CA64; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018C8A4[]; +extern u8 D_8018C8B8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018C8A4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018C8B8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018C95C[])(void); + +void func_80168744(void *a0) { + D_8018C95C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018C94C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018C94C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018C94C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018C964[])(void); + +void func_801689D8(void *a0) { + D_8018C964[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018C96C[])(void); + +void func_80168AA8(void *a0) { + D_8018C96C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018C974[])(void); + +void func_80168D58(void *a0) { + D_8018C974[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018C97C[])(void); + +void func_8016901C(void *a0) { + D_8018C97C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_118/nonmatchings/ov_SC03_118_jr_8015C32C", func_80169228); + + +extern void (*D_8018C984[])(void); + +void func_801693CC(void *a0) { + D_8018C984[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018C98C[])(void); + +void func_80169830(void *a0) { + D_8018C98C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018CA40[])(void); + +void func_80169B80(void *a0) { + D_8018CA40[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018C994[]; + extern u8 D_8018CA04[]; + extern u8 D_8018CA34[]; + extern u8 D_801D4708[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018CA34, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018C994[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801D4708; + RotMatrixYXZ(rot, D_801D4708); + func_80048D9C(D_801D4708, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018CA04); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018CA48[])(void); + +void func_80169F00(void *a0) { + D_8018CA48[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018C9F8[]; +extern char D_8018C9B8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018C9F8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018C9B8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018CA80[])(void); + +void func_8016A020(void *a0) { + D_8018CA80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018CA50; + extern u8 D_8018CA64[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018CA50); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018CA64; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018CA8C[])(void); + +void func_8016A700(void *a0) { + D_8018CA8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018CAD4[])(void); + +void func_8016AB30(void *a0) { + D_8018CAD4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_119/ov_SC03_119_jr_8015AE2C.c b/src/ov_SC03_119/ov_SC03_119_jr_8015AE2C.c index 4e1b56e18..7d72d25c3 100644 --- a/src/ov_SC03_119/ov_SC03_119_jr_8015AE2C.c +++ b/src/ov_SC03_119/ov_SC03_119_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018C190[])(void); - -void func_8015C714(void *a0) { - D_8018C190[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018C004[])(void*); - extern int D_8018BFA8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BFA8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018C004[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018C004[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018C004[])(void*); - extern int D_8018BFA8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BFA8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018C1A0[])(void); - D_8018C1A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018C004[])(struct Ent_8015CD20 *); - extern u8 D_8018BFB8; - extern u8 D_8018C1A8; - extern u8 D_8018C1B8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018C004[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BFB8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C1A8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C1B8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018C004[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018C1D8[])(void); - D_8018C1D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018C1C8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018C1C8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018C004[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018C234; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018C234, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018B318[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018B318; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018C23C[])(void); - D_8018C23C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018C248[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018C248[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018C248[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018C248[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018C004[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018C248[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018BFC8[]; - extern u8 D_8018BFD8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BFC8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BFD8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018C27C[])(void); - D_8018C27C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018C004[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018C284[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018C29C[])(void); - D_8018C29C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018C004[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018C284[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018C2BC[])(void); - D_8018C2BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018C004[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018C004)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018C2CC; -extern u16 D_8018C2CE; -extern u16 D_8018C2D0; -extern s32 D_8018C2D4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018C2CC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018C2CE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018C2D0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018C2D4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018C2DC; - -void func_8015E588(void) { - func_8013C9C4(&D_8018C2DC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018C004[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018C004)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018C2F0[])(void); - D_8018C2F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018C004[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018C004[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018C2F8[])(void); - D_8018C2F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018BFE8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018BFE8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018C004[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018C300[])(void); - D_8018C300[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018C004[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018C004[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018C308[])(void); - D_8018C308[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018C004[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018C310; - extern s32 D_8018C320; - extern s32 D_8018C330; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018C004[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C310); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C320); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018C004[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C330); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018C340[])(void); - D_8018C340[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018C004[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018C004[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018C004[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018C34C[])(void); - D_8018C34C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018C004[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018C004[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018C004[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018C004[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018C360[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018C360[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018C004[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018C004)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018C004[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018C004[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018C3DC[])(void); - D_8018C3DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018C004[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018C004)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018C3EC[])(void); - D_8018C3EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018C004[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018C004[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018C004[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018C004[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018C004[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018C004[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018C004[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018C3F4[])(void); - D_8018C3F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018C004[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018C004)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018C004[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018C004)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018C400[])(void); - D_8018C400[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018C004 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018C004[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018C004[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018C004[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018C410[])(void); - -void func_80160EA4(void *a0) { - D_8018C410[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018C004[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018C004[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018C440[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018C440[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018C4A4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018C4A4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801D30D8[]; - extern u8 D_8018C470[]; - extern u8 D_8018C490[]; - extern u8 D_801D30E4[]; - extern u8 D_801D310C[]; - extern u8 D_801D3124[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801D30D8[0] = p; - func_80024054(&D_8018C470, &D_801D30E4); - func_8001CE28(p, &D_801D30E4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801D30D8[1] = p; - func_80024054(&D_8018C490, &D_801D310C); - func_8001CE28(p, &D_801D310C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801D30D8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801D3124, 0x84); - func_8001CE68(p, &D_801D3124); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801D3124, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D30D8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801D30D8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018C4A4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018C4A4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018C4A4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018C4A4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801D30D8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801D30D8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018C4C8[])(void); - -void func_80162330(void *a0) { - D_8018C4C8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801D3130[i] via `extern int D_801D3130[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018C4D4[]; - extern s32 D_8018C4EC; - extern u8 D_801D313C[]; - extern u8 D_801D3164[]; - extern u8 D_801D3180[]; - extern int D_801D3130[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801D3130[0] = (s32)item; - func_80024054(D_8018C4D4, D_801D313C); - func_8001CE28(item, D_801D313C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801D3130[1] = (s32)item; - func_80024054(((u8 *)&D_8018C4EC), D_801D3164); - func_8001CE28(item, D_801D3164); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801D3130[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801D3180, 0x84); - func_8001CE68(item, D_801D3180); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801D3180, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801D3130[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801D3130; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018C510[])(void); - -void func_80162834(void *a0) { - D_8018C510[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018C500; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018C500, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801D28E4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801D28E4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801D28E4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801D28E4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018C518[])(void); - -void func_80163A58(void *a0) { - D_8018C518[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801D28EC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801D28EC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018C56C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018C56C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018C534; -extern s16 D_8018C568; -extern s16 D_8018C566; -extern s16 D_8018C564; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018C534; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018C568 = 0x80; - D_8018C566 = 0x80; - D_8018C564 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018C568 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018C568` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018C568 - 8; - D_8018C568 = nv; - D_8018C566 = nv; - D_8018C564 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018C578[])(void); - -void func_80164BA0(void *a0) { - D_8018C578[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801D3190; -extern u8 D_801D3191; -extern u8 D_801D3192; -extern u8 D_801D3193; -extern u8 D_801D3194; -extern u8 D_801D3195; -extern u8 D_801D3196; -extern u8 D_801D3197; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801D3190; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801D3191 = 0xf0; - *(u8 *)base = 0xf0; - D_801D3192 = 0xc0; - D_801D3196 = 0; - D_801D3195 = 0; - D_801D3194 = 0; - D_801D3197 = 0; - D_801D3193 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801D3190; -extern u8 D_801D3191; -extern u8 D_801D3192; - -s32 func_80164E40(void) { - u8 *p = &D_801D3190; - if (*p != 0) { - *p -= 0x10; - } - if (D_801D3191 != 0) { - D_801D3191 -= 0x10; - } - if (D_801D3192 != 0) { - D_801D3192 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018C588[])(void); - -void func_80164EA4(void *a0) { - D_8018C588[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801D31DC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801D31DC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801D31D0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801D31D0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801D31D0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801D31D0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801D31D0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018C59C[]; - extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; - extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; - extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; - extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018C59C[0x00], p); - ApplyMatrixSV(mat, &D_8018C59C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018C59C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018C59C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018C5C4; - *(u32 *)(prim + 0x24) = D_8018C5BC; - *(u32 *)(prim + 0x28) = D_8018C5C8; - *(u32 *)(prim + 0x2c) = D_8018C5C0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018C5CC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018C5CC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018C5CC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018C5CC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018C648[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018C648[a1 & 0x7F]; -} - - - -extern s32 D_8018C668[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018C668[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018C6E4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018C6E4[a1 & 0x7F]; -} - - - -extern u8 D_8018C704[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018C704[a1 & 0x7F]; -} - - - -extern u8 D_8018C724[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018C724[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018C744[])(void); - D_8018C744[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018C7C0[])(void); - -void func_80165AC8(void) { - D_8018C7C0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018C83C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018C83C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801D28F4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801D28F4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018C848[])(void); - -void func_80166018(void *a0) { - D_8018C848[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018C850[])(void); - -void func_801663FC(void *a0) { - D_8018C850[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018C918[])(void); - -void func_80166618(void *a0) { - D_8018C918[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018C928[])(void); - -void func_80166654(void *a0) { - D_8018C928[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801D3250[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801D3250[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D3250). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801D3250[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801D3250)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801D3250[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801D3250[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018C86C[]; - extern u8 D_8018C858[]; - extern u8 D_8018C880[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018C86C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018C858; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018C880; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80167714); - - -extern void (*D_8018C938[])(void); - -void func_801678B4(void *a0) { - D_8018C938[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018C944[])(void); - -void func_80167A9C(void *a0) { - D_8018C944[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018CA50; - extern u8 D_8018CA64[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018CA50); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018CA64; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018C8A4[]; -extern u8 D_8018C8B8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018C8A4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018C8B8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018C95C[])(void); - -void func_80168744(void *a0) { - D_8018C95C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018C94C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018C94C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018C94C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018C964[])(void); - -void func_801689D8(void *a0) { - D_8018C964[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018C96C[])(void); - -void func_80168AA8(void *a0) { - D_8018C96C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018C974[])(void); - -void func_80168D58(void *a0) { - D_8018C974[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018C97C[])(void); - -void func_8016901C(void *a0) { - D_8018C97C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015AE2C", func_80169228); - - -extern void (*D_8018C984[])(void); - -void func_801693CC(void *a0) { - D_8018C984[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018C98C[])(void); - -void func_80169830(void *a0) { - D_8018C98C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018CA40[])(void); - -void func_80169B80(void *a0) { - D_8018CA40[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018C994[]; - extern u8 D_8018CA04[]; - extern u8 D_8018CA34[]; - extern u8 D_801D4708[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018CA34, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018C994[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801D4708; - RotMatrixYXZ(rot, D_801D4708); - func_80048D9C(D_801D4708, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018CA04); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018CA48[])(void); - -void func_80169F00(void *a0) { - D_8018CA48[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018C9F8[]; -extern char D_8018C9B8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018C9F8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018C9B8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018CA80[])(void); - -void func_8016A020(void *a0) { - D_8018CA80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018CA50; - extern u8 D_8018CA64[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018CA50); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018CA64; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018CA8C[])(void); - -void func_8016A700(void *a0) { - D_8018CA8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018CAD4[])(void); - -void func_8016AB30(void *a0) { - D_8018CAD4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c b/src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c new file mode 100644 index 000000000..9b384cfab --- /dev/null +++ b/src/ov_SC03_119/ov_SC03_119_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018BEA0; +extern u8 D_8018BE10; +extern u8 D_8018BDEC; +extern u8 D_8018BDC8; +extern u8 D_8018BE7C; +extern u8 D_8018BE58; +extern u8 D_8018BE34; +extern u8 D_8018BDA4; +extern void func_80145934(void); +extern u8 D_8018BF30; +extern u8 D_8018BF0C; +extern u8 D_8018BEE8; +extern u8 D_8018BEC4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018B328[]; +extern unsigned char D_8018B358[]; +extern unsigned char D_8018B3A8[]; +extern unsigned char D_8018B3D8[]; +extern unsigned char D_8018B408[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018B458[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018B520[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018B5A8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018B5B0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801D3080; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801D3084; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018B5E0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018B688[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018B6AC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018B69C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018B6C0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018B6CC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018B6DC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018B6F4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018B6E4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018B708[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018B724[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018B714; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018B738[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018B74C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018B760; +extern void (*D_8018B788[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018B768; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018B7D4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018B7D8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018BC3C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018BC4C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801D30B8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018BC74[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018BC54; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018BC64; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018BCB4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018BCBC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018BC88; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018BCC8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018BC98; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801D30C0; +extern s32 D_801D30CC; +extern s32 D_801D30D0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018BD04[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018BCD8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801D30C8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018BF54[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018BD74[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018BFF8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018C14C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018BF68; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018C154[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018BF78; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018BF98; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018C15C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018C184[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018C004[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018C190[])(void); + +void func_8015C714(void *a0) { + D_8018C190[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018C004[])(void*); + extern int D_8018BFA8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BFA8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018C004[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018C004[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018C004[])(void*); + extern int D_8018BFA8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018BFA8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018C1A0[])(void); + D_8018C1A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018C004[])(struct Ent_8015CD20 *); + extern u8 D_8018BFB8; + extern u8 D_8018C1A8; + extern u8 D_8018C1B8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018C004[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018BFB8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C1A8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018C1B8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018C004[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018C1D8[])(void); + D_8018C1D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018C1C8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018C1C8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018C004[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018C234; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018C234, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018B318[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018B318; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018C23C[])(void); + D_8018C23C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018C248[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018C248[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018C248[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018C248[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018C004[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018C248[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018BFC8[]; + extern u8 D_8018BFD8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BFC8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018BFD8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018C248[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018C27C[])(void); + D_8018C27C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018C004[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018C284[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018C29C[])(void); + D_8018C29C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018C004[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018C284[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018C284[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018C2BC[])(void); + D_8018C2BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018C004[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018C004)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018C2CC; +extern u16 D_8018C2CE; +extern u16 D_8018C2D0; +extern s32 D_8018C2D4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018C2CC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018C2CE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018C2D0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018C2D4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018C2DC; + +void func_8015E588(void) { + func_8013C9C4(&D_8018C2DC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018C004[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018C004)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018C2F0[])(void); + D_8018C2F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018C004[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018C004[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018C2F8[])(void); + D_8018C2F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018BFE8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018BFE8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018C004[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018C300[])(void); + D_8018C300[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018C004[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018C004[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018C308[])(void); + D_8018C308[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018C004[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018C310; + extern s32 D_8018C320; + extern s32 D_8018C330; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C310); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C320); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018C004[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018C330); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018C340[])(void); + D_8018C340[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018C004[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018C004[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018C004[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018C34C[])(void); + D_8018C34C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018C004[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018C004[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018C004[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018C004[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018C360[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018C360[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018C004[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018C004)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018C004[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018C004[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018C3DC[])(void); + D_8018C3DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018C004[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018C004)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018C3EC[])(void); + D_8018C3EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018C004[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018C004[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018C004[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018C004[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018C004[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018C004[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018C004[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018C3F4[])(void); + D_8018C3F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018C004[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018C004)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018C004[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018C004)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018C400[])(void); + D_8018C400[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018C004 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018C004[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018C004[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018C004[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018C410[])(void); + +void func_80160EA4(void *a0) { + D_8018C410[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018C004[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018C004[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018C440[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018C440[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018C4A4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018C4A4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801D30D8[]; + extern u8 D_8018C470[]; + extern u8 D_8018C490[]; + extern u8 D_801D30E4[]; + extern u8 D_801D310C[]; + extern u8 D_801D3124[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801D30D8[0] = p; + func_80024054(&D_8018C470, &D_801D30E4); + func_8001CE28(p, &D_801D30E4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801D30D8[1] = p; + func_80024054(&D_8018C490, &D_801D310C); + func_8001CE28(p, &D_801D310C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801D30D8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801D3124, 0x84); + func_8001CE68(p, &D_801D3124); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801D3124, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D30D8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801D30D8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018C4A4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018C4A4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018C4A4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018C4A4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801D30D8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801D30D8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018C4C8[])(void); + +void func_80162330(void *a0) { + D_8018C4C8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801D3130[i] via `extern int D_801D3130[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018C4D4[]; + extern s32 D_8018C4EC; + extern u8 D_801D313C[]; + extern u8 D_801D3164[]; + extern u8 D_801D3180[]; + extern int D_801D3130[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801D3130[0] = (s32)item; + func_80024054(D_8018C4D4, D_801D313C); + func_8001CE28(item, D_801D313C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801D3130[1] = (s32)item; + func_80024054(((u8 *)&D_8018C4EC), D_801D3164); + func_8001CE28(item, D_801D3164); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801D3130[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801D3180, 0x84); + func_8001CE68(item, D_801D3180); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801D3180, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801D3130[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801D3130; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_801627E8); + + +extern void (*D_8018C510[])(void); + +void func_80162834(void *a0) { + D_8018C510[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018C500; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018C500, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801D28E4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801D28E4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801D28E4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801D28E4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018C518[])(void); + +void func_80163A58(void *a0) { + D_8018C518[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801D28EC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801D28EC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018C56C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018C56C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018C534; +extern s16 D_8018C568; +extern s16 D_8018C566; +extern s16 D_8018C564; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018C534; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018C568 = 0x80; + D_8018C566 = 0x80; + D_8018C564 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018C568 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018C568` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018C568 - 8; + D_8018C568 = nv; + D_8018C566 = nv; + D_8018C564 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018C578[])(void); + +void func_80164BA0(void *a0) { + D_8018C578[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801D3190; +extern u8 D_801D3191; +extern u8 D_801D3192; +extern u8 D_801D3193; +extern u8 D_801D3194; +extern u8 D_801D3195; +extern u8 D_801D3196; +extern u8 D_801D3197; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801D3190; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801D3191 = 0xf0; + *(u8 *)base = 0xf0; + D_801D3192 = 0xc0; + D_801D3196 = 0; + D_801D3195 = 0; + D_801D3194 = 0; + D_801D3197 = 0; + D_801D3193 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801D3190; +extern u8 D_801D3191; +extern u8 D_801D3192; + +s32 func_80164E40(void) { + u8 *p = &D_801D3190; + if (*p != 0) { + *p -= 0x10; + } + if (D_801D3191 != 0) { + D_801D3191 -= 0x10; + } + if (D_801D3192 != 0) { + D_801D3192 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018C588[])(void); + +void func_80164EA4(void *a0) { + D_8018C588[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801D31DC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801D31DC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801D31D0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801D31D0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801D31D0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801D31D0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801D31D0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018C59C[]; + extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; + extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; + extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; + extern u32 D_8018C5BC, D_8018C5C0, D_8018C5C4, D_8018C5C8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018C59C[0x00], p); + ApplyMatrixSV(mat, &D_8018C59C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018C59C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018C59C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018C5C4; + *(u32 *)(prim + 0x24) = D_8018C5BC; + *(u32 *)(prim + 0x28) = D_8018C5C8; + *(u32 *)(prim + 0x2c) = D_8018C5C0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018C5CC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018C5CC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018C5CC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018C5CC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018C648[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018C648[a1 & 0x7F]; +} + + + +extern s32 D_8018C668[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018C668[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018C6E4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018C6E4[a1 & 0x7F]; +} + + + +extern u8 D_8018C704[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018C704[a1 & 0x7F]; +} + + + +extern u8 D_8018C724[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018C724[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018C744[])(void); + D_8018C744[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018C7C0[])(void); + +void func_80165AC8(void) { + D_8018C7C0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018C83C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018C83C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801D28F4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801D28F4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018C848[])(void); + +void func_80166018(void *a0) { + D_8018C848[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018C850[])(void); + +void func_801663FC(void *a0) { + D_8018C850[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018C918[])(void); + +void func_80166618(void *a0) { + D_8018C918[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018C928[])(void); + +void func_80166654(void *a0) { + D_8018C928[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801D3250[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801D3250[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801D3250). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801D3250[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801D3250)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801D3250[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801D3250[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018C86C[]; + extern u8 D_8018C858[]; + extern u8 D_8018C880[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018C86C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018C858; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018C880; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80167714); + + +extern void (*D_8018C938[])(void); + +void func_801678B4(void *a0) { + D_8018C938[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018C944[])(void); + +void func_80167A9C(void *a0) { + D_8018C944[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018CA50; + extern u8 D_8018CA64[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018CA50); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018CA64; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018C8A4[]; +extern u8 D_8018C8B8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018C8A4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018C8B8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018C95C[])(void); + +void func_80168744(void *a0) { + D_8018C95C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018C94C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018C94C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018C94C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018C964[])(void); + +void func_801689D8(void *a0) { + D_8018C964[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018C96C[])(void); + +void func_80168AA8(void *a0) { + D_8018C96C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018C974[])(void); + +void func_80168D58(void *a0) { + D_8018C974[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018C97C[])(void); + +void func_8016901C(void *a0) { + D_8018C97C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_119/nonmatchings/ov_SC03_119_jr_8015C32C", func_80169228); + + +extern void (*D_8018C984[])(void); + +void func_801693CC(void *a0) { + D_8018C984[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018C98C[])(void); + +void func_80169830(void *a0) { + D_8018C98C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018CA40[])(void); + +void func_80169B80(void *a0) { + D_8018CA40[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018C994[]; + extern u8 D_8018CA04[]; + extern u8 D_8018CA34[]; + extern u8 D_801D4708[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018CA34, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018C994[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801D4708; + RotMatrixYXZ(rot, D_801D4708); + func_80048D9C(D_801D4708, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018CA04); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018CA48[])(void); + +void func_80169F00(void *a0) { + D_8018CA48[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018C9F8[]; +extern char D_8018C9B8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018C9F8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018C9B8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018CA80[])(void); + +void func_8016A020(void *a0) { + D_8018CA80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018CA50; + extern u8 D_8018CA64[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018CA50); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018CA64; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018CA8C[])(void); + +void func_8016A700(void *a0) { + D_8018CA8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018CAD4[])(void); + +void func_8016AB30(void *a0) { + D_8018CAD4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_121/ov_SC03_121_jr_8015AE2C.c b/src/ov_SC03_121/ov_SC03_121_jr_8015AE2C.c index 824af41b5..eff102bcd 100644 --- a/src/ov_SC03_121/ov_SC03_121_jr_8015AE2C.c +++ b/src/ov_SC03_121/ov_SC03_121_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801849AC[])(void); - -void func_8015C714(void *a0) { - D_801849AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80184820[])(void*); - extern int D_801847C4; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80184820)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80184820)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801847C4); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80184820[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80184820[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80184820[])(void*); - extern int D_801847C4; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80184820)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801847C4); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80184820)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801849BC[])(void); - D_801849BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80184820[])(struct Ent_8015CD20 *); - extern u8 D_801847D4; - extern u8 D_801849C4; - extern u8 D_801849D4; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80184820[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801847D4); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849C4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849D4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80184820[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801849F4[])(void); - D_801849F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801849E4; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801849E4 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80184820[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80184A50; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80184A50, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80183B34[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80183B34; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80184A58[])(void); - D_80184A58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80184A64[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80184A64[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80184A64[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80184A64[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80184820[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80184A64[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801847E4[]; - extern u8 D_801847F4[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801847E4); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801847F4); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80184A64[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184A64[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184A64[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80184A98[])(void); - D_80184A98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184820[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184AA0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80184AB8[])(void); - D_80184AB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184820[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184AA0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80184AD8[])(void); - D_80184AD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80184820[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184820)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80184AE8; -extern u16 D_80184AEA; -extern u16 D_80184AEC; -extern s32 D_80184AF0; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80184AE8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80184AEA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80184AEC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184AF0, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80184AF8; - -void func_8015E588(void) { - func_8013C9C4(&D_80184AF8); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80184820[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184820)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80184B0C[])(void); - D_80184B0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80184820[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80184820[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80184B14[])(void); - D_80184B14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80184804; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80184804); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80184820[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80184B1C[])(void); - D_80184B1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80184820[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80184820[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80184B24[])(void); - D_80184B24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80184820[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80184B2C; - extern s32 D_80184B3C; - extern s32 D_80184B4C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80184820[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B2C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B3C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80184820[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B4C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184B5C[])(void); - D_80184B5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80184820[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80184820[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80184820[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184820[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184B68[])(void); - D_80184B68[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80184820[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184820[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80184820[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184820[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80184B7C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80184B7C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80184820[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80184820)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80184820[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184820[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80184BF8[])(void); - D_80184BF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80184820[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80184820)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80184C08[])(void); - D_80184C08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80184820[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80184820[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80184820[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80184820[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80184820[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80184820[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80184820[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80184C10[])(void); - D_80184C10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80184820[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80184820)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80184820[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80184820)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80184C1C[])(void); - D_80184C1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184820 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80184820[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80184820[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80184820[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80184C2C[])(void); - -void func_80160EA4(void *a0) { - D_80184C2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80184820[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80184820[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80184C5C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80184C5C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80184CC0; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80184CC0); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801ADB80[]; - extern u8 D_80184C8C[]; - extern u8 D_80184CAC[]; - extern u8 D_801ADB8C[]; - extern u8 D_801ADBB4[]; - extern u8 D_801ADBCC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801ADB80[0] = p; - func_80024054(&D_80184C8C, &D_801ADB8C); - func_8001CE28(p, &D_801ADB8C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801ADB80[1] = p; - func_80024054(&D_80184CAC, &D_801ADBB4); - func_8001CE28(p, &D_801ADBB4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801ADB80[2] = p; - func_800242D0((s16)func_801620C4(), &D_801ADBCC, 0x84); - func_8001CE68(p, &D_801ADBCC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801ADBCC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801ADB80[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801ADB80; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80184CC0; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80184CC0; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80184CC0; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80184CC0; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801ADB80[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801ADB80; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80184CE4[])(void); - -void func_80162330(void *a0) { - D_80184CE4[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801ADBD8[i] via `extern int D_801ADBD8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80184CF0[]; - extern s32 D_80184D08; - extern u8 D_801ADBE4[]; - extern u8 D_801ADC0C[]; - extern u8 D_801ADC28[]; - extern int D_801ADBD8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801ADBD8[0] = (s32)item; - func_80024054(D_80184CF0, D_801ADBE4); - func_8001CE28(item, D_801ADBE4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801ADBD8[1] = (s32)item; - func_80024054(((u8 *)&D_80184D08), D_801ADC0C); - func_8001CE28(item, D_801ADC0C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801ADBD8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801ADC28, 0x84); - func_8001CE68(item, D_801ADC28); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801ADC28, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801ADBD8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801ADBD8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_801627E8); - - -extern void (*D_80184D2C[])(void); - -void func_80162834(void *a0) { - D_80184D2C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80184D1C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80184D1C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801AD3EC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801AD3EC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801AD3EC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801AD3EC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80184D34[])(void); - -void func_80163A58(void *a0) { - D_80184D34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801AD3F4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801AD3F4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80184D88[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80184D88[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80184D50; -extern s16 D_80184D84; -extern s16 D_80184D82; -extern s16 D_80184D80; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80184D50; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80184D84 = 0x80; - D_80184D82 = 0x80; - D_80184D80 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80184D84 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80184D84` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80184D84 - 8; - D_80184D84 = nv; - D_80184D82 = nv; - D_80184D80 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80184D94[])(void); - -void func_80164BA0(void *a0) { - D_80184D94[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801ADC38; -extern u8 D_801ADC39; -extern u8 D_801ADC3A; -extern u8 D_801ADC3B; -extern u8 D_801ADC3C; -extern u8 D_801ADC3D; -extern u8 D_801ADC3E; -extern u8 D_801ADC3F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801ADC38; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801ADC39 = 0xf0; - *(u8 *)base = 0xf0; - D_801ADC3A = 0xc0; - D_801ADC3E = 0; - D_801ADC3D = 0; - D_801ADC3C = 0; - D_801ADC3F = 0; - D_801ADC3B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801ADC38; -extern u8 D_801ADC39; -extern u8 D_801ADC3A; - -s32 func_80164E40(void) { - u8 *p = &D_801ADC38; - if (*p != 0) { - *p -= 0x10; - } - if (D_801ADC39 != 0) { - D_801ADC39 -= 0x10; - } - if (D_801ADC3A != 0) { - D_801ADC3A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80184DA4[])(void); - -void func_80164EA4(void *a0) { - D_80184DA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801ADC84[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801ADC84[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801ADC78[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801ADC78[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801ADC78[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801ADC78; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801ADC78; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80184DB8[]; - extern u32 D_80184DD8, D_80184DDC, D_80184DE0, D_80184DE4; - extern u32 D_80184DD8, D_80184DDC, D_80184DE0, D_80184DE4; - extern u32 D_80184DD8, D_80184DDC, D_80184DE0, D_80184DE4; - extern u32 D_80184DD8, D_80184DDC, D_80184DE0, D_80184DE4; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80184DB8[0x00], p); - ApplyMatrixSV(mat, &D_80184DB8[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80184DB8[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80184DB8[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80184DE0; - *(u32 *)(prim + 0x24) = D_80184DD8; - *(u32 *)(prim + 0x28) = D_80184DE4; - *(u32 *)(prim + 0x2c) = D_80184DDC; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80184DE8[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80184DE8[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80184DE8[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80184DE8[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80184E64[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80184E64[a1 & 0x7F]; -} - - - -extern s32 D_80184E84[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80184E84[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80184F00[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80184F00[a1 & 0x7F]; -} - - - -extern u8 D_80184F20[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80184F20[a1 & 0x7F]; -} - - - -extern u8 D_80184F40[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80184F40[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80184F60[])(void); - D_80184F60[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80184FDC[])(void); - -void func_80165AC8(void) { - D_80184FDC[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80185058[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80185058[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801AD3FC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801AD3FC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80185064[])(void); - -void func_80166018(void *a0) { - D_80185064[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018506C[])(void); - -void func_801663FC(void *a0) { - D_8018506C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80185134[])(void); - -void func_80166618(void *a0) { - D_80185134[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80185144[])(void); - -void func_80166654(void *a0) { - D_80185144[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801ADCF8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801ADCF8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801ADCF8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801ADCF8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801ADCF8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801ADCF8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801ADCF8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80185088[]; - extern u8 D_80185074[]; - extern u8 D_8018509C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80185088; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80185074; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018509C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80167714); - - -extern void (*D_80185154[])(void); - -void func_801678B4(void *a0) { - D_80185154[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80185160[])(void); - -void func_80167A9C(void *a0) { - D_80185160[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018526C; - extern u8 D_80185280[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018526C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185280; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801850C0[]; -extern u8 D_801850D4[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801850C0; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801850D4; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80185178[])(void); - -void func_80168744(void *a0) { - D_80185178[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80185168 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80185168[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80185168; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80185180[])(void); - -void func_801689D8(void *a0) { - D_80185180[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80185188[])(void); - -void func_80168AA8(void *a0) { - D_80185188[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80185190[])(void); - -void func_80168D58(void *a0) { - D_80185190[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80185198[])(void); - -void func_8016901C(void *a0) { - D_80185198[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015AE2C", func_80169228); - - -extern void (*D_801851A0[])(void); - -void func_801693CC(void *a0) { - D_801851A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801851A8[])(void); - -void func_80169830(void *a0) { - D_801851A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018525C[])(void); - -void func_80169B80(void *a0) { - D_8018525C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801851B0[]; - extern u8 D_80185220[]; - extern u8 D_80185250[]; - extern u8 D_801AEE68[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80185250, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801851B0[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801AEE68; - RotMatrixYXZ(rot, D_801AEE68); - func_80048D9C(D_801AEE68, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80185220); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80185264[])(void); - -void func_80169F00(void *a0) { - D_80185264[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80185214[]; -extern char D_801851D4[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80185214, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801851D4); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018529C[])(void); - -void func_8016A020(void *a0) { - D_8018529C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018526C; - extern u8 D_80185280[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018526C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185280; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801852A8[])(void); - -void func_8016A700(void *a0) { - D_801852A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801852F0[])(void); - -void func_8016AB30(void *a0) { - D_801852F0[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c b/src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c new file mode 100644 index 000000000..f48e7bc30 --- /dev/null +++ b/src/ov_SC03_121/ov_SC03_121_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801846BC; +extern u8 D_8018462C; +extern u8 D_80184608; +extern u8 D_801845E4; +extern u8 D_80184698; +extern u8 D_80184674; +extern u8 D_80184650; +extern u8 D_801845C0; +extern void func_80145934(void); +extern u8 D_8018474C; +extern u8 D_80184728; +extern u8 D_80184704; +extern u8 D_801846E0; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80183B44[]; +extern unsigned char D_80183B74[]; +extern unsigned char D_80183BC4[]; +extern unsigned char D_80183BF4[]; +extern unsigned char D_80183C24[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80183C74[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80183D3C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80183DC4[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80183DCC; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801ADB28; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801ADB2C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80183DFC; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80183EA4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80183EC8[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80183EB8; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80183EDC[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80183EE8[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80183EF8[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80183F10[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80183F00; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80183F24[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80183F40[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80183F30; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80183F54[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80183F68[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80183F7C; +extern void (*D_80183FA4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80183F84; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80183FF0[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80183FF4[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184458[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184468[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801ADB60; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80184490[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80184470; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80184480; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801844D0[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801844D8[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801844A4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801844E4[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801844B4; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801ADB68; +extern s32 D_801ADB74; +extern s32 D_801ADB78; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80184520[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801844F4[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801ADB70; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184770[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80184590[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80184814[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80184968[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80184784; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80184970[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80184794; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801847B4; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80184978[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801849A0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80184820[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80184820[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80184820[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80184820[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80184820[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80184820[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80184820[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80184820[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801849AC[])(void); + +void func_8015C714(void *a0) { + D_801849AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80184820[])(void*); + extern int D_801847C4; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80184820)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80184820)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801847C4); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80184820[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80184820[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80184820[])(void*); + extern int D_801847C4; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80184820)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801847C4); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80184820)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801849BC[])(void); + D_801849BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80184820[])(struct Ent_8015CD20 *); + extern u8 D_801847D4; + extern u8 D_801849C4; + extern u8 D_801849D4; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80184820[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801847D4); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849C4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849D4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80184820[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801849F4[])(void); + D_801849F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801849E4; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801849E4 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80184820[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80184A50; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80184A50, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80183B34[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80183B34; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80184A58[])(void); + D_80184A58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80184A64[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80184A64[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80184A64[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80184A64[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80184820[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80184A64[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801847E4[]; + extern u8 D_801847F4[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801847E4); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801847F4); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80184A64[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184A64[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184A64[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80184A98[])(void); + D_80184A98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184820[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184AA0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80184AB8[])(void); + D_80184AB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184820[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184AA0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184AA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80184AD8[])(void); + D_80184AD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80184820[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184820)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80184AE8; +extern u16 D_80184AEA; +extern u16 D_80184AEC; +extern s32 D_80184AF0; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80184AE8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80184AEA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80184AEC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184AF0, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80184AF8; + +void func_8015E588(void) { + func_8013C9C4(&D_80184AF8); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80184820[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184820)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80184B0C[])(void); + D_80184B0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80184820[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80184820[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80184B14[])(void); + D_80184B14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80184804; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80184804); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80184820[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80184B1C[])(void); + D_80184B1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80184820[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80184820[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80184B24[])(void); + D_80184B24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80184820[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80184B2C; + extern s32 D_80184B3C; + extern s32 D_80184B4C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80184820[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B2C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B3C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80184820[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B4C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184B5C[])(void); + D_80184B5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80184820[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80184820[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80184820[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184820[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184B68[])(void); + D_80184B68[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80184820[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184820[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80184820[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184820[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80184B7C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80184B7C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80184820[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80184820)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80184820[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184820[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80184BF8[])(void); + D_80184BF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80184820[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80184820)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80184C08[])(void); + D_80184C08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80184820[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80184820[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80184820[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80184820[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80184820[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80184820[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80184820[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80184C10[])(void); + D_80184C10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80184820[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80184820)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80184820[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80184820)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80184C1C[])(void); + D_80184C1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184820 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80184820[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80184820[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80184820[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80184C2C[])(void); + +void func_80160EA4(void *a0) { + D_80184C2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80184820[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80184820[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80184C5C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80184C5C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80184CC0; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80184CC0); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801ADB80[]; + extern u8 D_80184C8C[]; + extern u8 D_80184CAC[]; + extern u8 D_801ADB8C[]; + extern u8 D_801ADBB4[]; + extern u8 D_801ADBCC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801ADB80[0] = p; + func_80024054(&D_80184C8C, &D_801ADB8C); + func_8001CE28(p, &D_801ADB8C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801ADB80[1] = p; + func_80024054(&D_80184CAC, &D_801ADBB4); + func_8001CE28(p, &D_801ADBB4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801ADB80[2] = p; + func_800242D0((s16)func_801620C4(), &D_801ADBCC, 0x84); + func_8001CE68(p, &D_801ADBCC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801ADBCC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801ADB80[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801ADB80; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80184CC0; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80184CC0; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80184CC0; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80184CC0; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801ADB80[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801ADB80; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80184CE4[])(void); + +void func_80162330(void *a0) { + D_80184CE4[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801ADBD8[i] via `extern int D_801ADBD8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80184CF0[]; + extern s32 D_80184D08; + extern u8 D_801ADBE4[]; + extern u8 D_801ADC0C[]; + extern u8 D_801ADC28[]; + extern int D_801ADBD8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801ADBD8[0] = (s32)item; + func_80024054(D_80184CF0, D_801ADBE4); + func_8001CE28(item, D_801ADBE4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801ADBD8[1] = (s32)item; + func_80024054(((u8 *)&D_80184D08), D_801ADC0C); + func_8001CE28(item, D_801ADC0C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801ADBD8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801ADC28, 0x84); + func_8001CE68(item, D_801ADC28); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801ADC28, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801ADBD8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801ADBD8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_801627E8); + + +extern void (*D_80184D2C[])(void); + +void func_80162834(void *a0) { + D_80184D2C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80184D1C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80184D1C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801AD3EC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801AD3EC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801AD3EC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801AD3EC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80184D34[])(void); + +void func_80163A58(void *a0) { + D_80184D34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801AD3F4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801AD3F4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80184D88[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80184D88[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80184D50; +extern s16 D_80184D84; +extern s16 D_80184D82; +extern s16 D_80184D80; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80184D50; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80184D84 = 0x80; + D_80184D82 = 0x80; + D_80184D80 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80184D84 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80184D84` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80184D84 - 8; + D_80184D84 = nv; + D_80184D82 = nv; + D_80184D80 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80184D94[])(void); + +void func_80164BA0(void *a0) { + D_80184D94[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801ADC38; +extern u8 D_801ADC39; +extern u8 D_801ADC3A; +extern u8 D_801ADC3B; +extern u8 D_801ADC3C; +extern u8 D_801ADC3D; +extern u8 D_801ADC3E; +extern u8 D_801ADC3F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801ADC38; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801ADC39 = 0xf0; + *(u8 *)base = 0xf0; + D_801ADC3A = 0xc0; + D_801ADC3E = 0; + D_801ADC3D = 0; + D_801ADC3C = 0; + D_801ADC3F = 0; + D_801ADC3B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801ADC38; +extern u8 D_801ADC39; +extern u8 D_801ADC3A; + +s32 func_80164E40(void) { + u8 *p = &D_801ADC38; + if (*p != 0) { + *p -= 0x10; + } + if (D_801ADC39 != 0) { + D_801ADC39 -= 0x10; + } + if (D_801ADC3A != 0) { + D_801ADC3A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80184DA4[])(void); + +void func_80164EA4(void *a0) { + D_80184DA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801ADC84[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801ADC84[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801ADC78[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801ADC78[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801ADC78[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801ADC78; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801ADC78; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80184DB8[]; + extern u32 D_80184DD8, D_80184DDC, D_80184DE0, D_80184DE4; + extern u32 D_80184DD8, D_80184DDC, D_80184DE0, D_80184DE4; + extern u32 D_80184DD8, D_80184DDC, D_80184DE0, D_80184DE4; + extern u32 D_80184DD8, D_80184DDC, D_80184DE0, D_80184DE4; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80184DB8[0x00], p); + ApplyMatrixSV(mat, &D_80184DB8[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80184DB8[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80184DB8[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80184DE0; + *(u32 *)(prim + 0x24) = D_80184DD8; + *(u32 *)(prim + 0x28) = D_80184DE4; + *(u32 *)(prim + 0x2c) = D_80184DDC; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80184DE8[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80184DE8[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80184DE8[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80184DE8[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80184E64[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80184E64[a1 & 0x7F]; +} + + + +extern s32 D_80184E84[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80184E84[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80184F00[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80184F00[a1 & 0x7F]; +} + + + +extern u8 D_80184F20[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80184F20[a1 & 0x7F]; +} + + + +extern u8 D_80184F40[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80184F40[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80184F60[])(void); + D_80184F60[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80184FDC[])(void); + +void func_80165AC8(void) { + D_80184FDC[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80185058[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80185058[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801AD3FC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801AD3FC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80185064[])(void); + +void func_80166018(void *a0) { + D_80185064[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018506C[])(void); + +void func_801663FC(void *a0) { + D_8018506C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80185134[])(void); + +void func_80166618(void *a0) { + D_80185134[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80185144[])(void); + +void func_80166654(void *a0) { + D_80185144[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801ADCF8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801ADCF8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801ADCF8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801ADCF8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801ADCF8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801ADCF8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801ADCF8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80185088[]; + extern u8 D_80185074[]; + extern u8 D_8018509C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80185088; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80185074; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018509C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80167714); + + +extern void (*D_80185154[])(void); + +void func_801678B4(void *a0) { + D_80185154[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80185160[])(void); + +void func_80167A9C(void *a0) { + D_80185160[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018526C; + extern u8 D_80185280[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018526C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185280; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801850C0[]; +extern u8 D_801850D4[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801850C0; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801850D4; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80185178[])(void); + +void func_80168744(void *a0) { + D_80185178[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80185168 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80185168[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80185168; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80185180[])(void); + +void func_801689D8(void *a0) { + D_80185180[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80185188[])(void); + +void func_80168AA8(void *a0) { + D_80185188[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80185190[])(void); + +void func_80168D58(void *a0) { + D_80185190[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80185198[])(void); + +void func_8016901C(void *a0) { + D_80185198[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_121/nonmatchings/ov_SC03_121_jr_8015C32C", func_80169228); + + +extern void (*D_801851A0[])(void); + +void func_801693CC(void *a0) { + D_801851A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801851A8[])(void); + +void func_80169830(void *a0) { + D_801851A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018525C[])(void); + +void func_80169B80(void *a0) { + D_8018525C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801851B0[]; + extern u8 D_80185220[]; + extern u8 D_80185250[]; + extern u8 D_801AEE68[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80185250, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801851B0[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801AEE68; + RotMatrixYXZ(rot, D_801AEE68); + func_80048D9C(D_801AEE68, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80185220); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80185264[])(void); + +void func_80169F00(void *a0) { + D_80185264[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80185214[]; +extern char D_801851D4[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80185214, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801851D4); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018529C[])(void); + +void func_8016A020(void *a0) { + D_8018529C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018526C; + extern u8 D_80185280[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018526C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185280; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801852A8[])(void); + +void func_8016A700(void *a0) { + D_801852A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801852F0[])(void); + +void func_8016AB30(void *a0) { + D_801852F0[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_124/ov_SC03_124_jr_8015AE2C.c b/src/ov_SC03_124/ov_SC03_124_jr_8015AE2C.c index fa19b69d6..a603ee58f 100644 --- a/src/ov_SC03_124/ov_SC03_124_jr_8015AE2C.c +++ b/src/ov_SC03_124/ov_SC03_124_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018D3D8[])(void); - -void func_8015C714(void *a0) { - D_8018D3D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018D24C[])(void*); - extern int D_8018D1F0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018D24C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018D24C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D1F0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018D24C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018D24C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018D24C[])(void*); - extern int D_8018D1F0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018D24C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D1F0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018D24C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018D3E8[])(void); - D_8018D3E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018D24C[])(struct Ent_8015CD20 *); - extern u8 D_8018D200; - extern u8 D_8018D3F0; - extern u8 D_8018D400; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018D24C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D200); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D3F0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D400); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018D24C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018D420[])(void); - D_8018D420[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018D410; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018D410 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018D24C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018D47C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018D47C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018C560[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018C560; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018D484[])(void); - D_8018D484[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018D490[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018D490[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018D490[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018D490[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018D24C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018D490[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018D210[]; - extern u8 D_8018D220[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D210); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D220); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018D490[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018D490[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018D490[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018D4C4[])(void); - D_8018D4C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D24C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018D4CC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018D4E4[])(void); - D_8018D4E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018D24C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018D4CC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018D504[])(void); - D_8018D504[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018D24C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D24C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018D514; -extern u16 D_8018D516; -extern u16 D_8018D518; -extern s32 D_8018D51C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018D514 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018D516 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018D518 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018D51C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018D524; - -void func_8015E588(void) { - func_8013C9C4(&D_8018D524); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018D24C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018D24C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018D538[])(void); - D_8018D538[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018D24C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018D24C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018D540[])(void); - D_8018D540[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018D230; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D230); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018D24C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018D548[])(void); - D_8018D548[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018D24C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018D24C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018D550[])(void); - D_8018D550[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018D24C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018D558; - extern s32 D_8018D568; - extern s32 D_8018D578; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018D24C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D558); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D568); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018D24C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D578); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018D588[])(void); - D_8018D588[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018D24C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018D24C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018D24C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018D24C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018D594[])(void); - D_8018D594[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018D24C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018D24C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018D24C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D24C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018D5A8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018D5A8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018D24C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018D24C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018D24C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018D24C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018D624[])(void); - D_8018D624[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018D24C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018D24C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018D634[])(void); - D_8018D634[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018D24C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018D24C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018D24C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018D24C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018D24C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018D24C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018D24C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018D63C[])(void); - D_8018D63C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018D24C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018D24C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018D24C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018D24C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018D648[])(void); - D_8018D648[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D24C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018D24C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018D24C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018D24C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018D658[])(void); - -void func_80160EA4(void *a0) { - D_8018D658[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018D24C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018D24C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018D688[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018D688[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018D6EC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018D6EC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E06A8[]; - extern u8 D_8018D6B8[]; - extern u8 D_8018D6D8[]; - extern u8 D_801E06B4[]; - extern u8 D_801E06DC[]; - extern u8 D_801E06F4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E06A8[0] = p; - func_80024054(&D_8018D6B8, &D_801E06B4); - func_8001CE28(p, &D_801E06B4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E06A8[1] = p; - func_80024054(&D_8018D6D8, &D_801E06DC); - func_8001CE28(p, &D_801E06DC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E06A8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E06F4, 0x84); - func_8001CE68(p, &D_801E06F4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E06F4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E06A8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E06A8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018D6EC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018D6EC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018D6EC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018D6EC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E06A8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E06A8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018D710[])(void); - -void func_80162330(void *a0) { - D_8018D710[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E0700[i] via `extern int D_801E0700[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018D71C[]; - extern s32 D_8018D734; - extern u8 D_801E070C[]; - extern u8 D_801E0734[]; - extern u8 D_801E0750[]; - extern int D_801E0700[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E0700[0] = (s32)item; - func_80024054(D_8018D71C, D_801E070C); - func_8001CE28(item, D_801E070C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E0700[1] = (s32)item; - func_80024054(((u8 *)&D_8018D734), D_801E0734); - func_8001CE28(item, D_801E0734); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E0700[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E0750, 0x84); - func_8001CE68(item, D_801E0750); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E0750, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E0700[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E0700; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018D758[])(void); - -void func_80162834(void *a0) { - D_8018D758[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018D748; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018D748, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801DFB40[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801DFB40, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801DFB40[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801DFB40, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018D760[])(void); - -void func_80163A58(void *a0) { - D_8018D760[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801DFB48; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801DFB48; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018D7B4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018D7B4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018D77C; -extern s16 D_8018D7B0; -extern s16 D_8018D7AE; -extern s16 D_8018D7AC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018D77C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018D7B0 = 0x80; - D_8018D7AE = 0x80; - D_8018D7AC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018D7B0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D7B0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018D7B0 - 8; - D_8018D7B0 = nv; - D_8018D7AE = nv; - D_8018D7AC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018D7C0[])(void); - -void func_80164BA0(void *a0) { - D_8018D7C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E0760; -extern u8 D_801E0761; -extern u8 D_801E0762; -extern u8 D_801E0763; -extern u8 D_801E0764; -extern u8 D_801E0765; -extern u8 D_801E0766; -extern u8 D_801E0767; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E0760; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E0761 = 0xf0; - *(u8 *)base = 0xf0; - D_801E0762 = 0xc0; - D_801E0766 = 0; - D_801E0765 = 0; - D_801E0764 = 0; - D_801E0767 = 0; - D_801E0763 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E0760; -extern u8 D_801E0761; -extern u8 D_801E0762; - -s32 func_80164E40(void) { - u8 *p = &D_801E0760; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E0761 != 0) { - D_801E0761 -= 0x10; - } - if (D_801E0762 != 0) { - D_801E0762 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018D7D0[])(void); - -void func_80164EA4(void *a0) { - D_8018D7D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E07AC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E07AC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E07A0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E07A0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E07A0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E07A0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E07A0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018D7E4[]; - extern u32 D_8018D804, D_8018D808, D_8018D80C, D_8018D810; - extern u32 D_8018D804, D_8018D808, D_8018D80C, D_8018D810; - extern u32 D_8018D804, D_8018D808, D_8018D80C, D_8018D810; - extern u32 D_8018D804, D_8018D808, D_8018D80C, D_8018D810; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018D7E4[0x00], p); - ApplyMatrixSV(mat, &D_8018D7E4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018D7E4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018D7E4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018D80C; - *(u32 *)(prim + 0x24) = D_8018D804; - *(u32 *)(prim + 0x28) = D_8018D810; - *(u32 *)(prim + 0x2c) = D_8018D808; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018D814[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018D814[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018D814[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018D814[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018D890[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018D890[a1 & 0x7F]; -} - - - -extern s32 D_8018D8B0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018D8B0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018D92C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018D92C[a1 & 0x7F]; -} - - - -extern u8 D_8018D94C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018D94C[a1 & 0x7F]; -} - - - -extern u8 D_8018D96C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018D96C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018D98C[])(void); - D_8018D98C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018DA08[])(void); - -void func_80165AC8(void) { - D_8018DA08[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018DA84[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018DA84[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801DFB50; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801DFB50, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018DA90[])(void); - -void func_80166018(void *a0) { - D_8018DA90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018DA98[])(void); - -void func_801663FC(void *a0) { - D_8018DA98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018DB60[])(void); - -void func_80166618(void *a0) { - D_8018DB60[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018DB70[])(void); - -void func_80166654(void *a0) { - D_8018DB70[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E0820[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E0820[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E0820). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E0820[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E0820)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E0820[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E0820[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018DAB4[]; - extern u8 D_8018DAA0[]; - extern u8 D_8018DAC8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018DAB4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018DAA0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018DAC8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80167714); - - -extern void (*D_8018DB80[])(void); - -void func_801678B4(void *a0) { - D_8018DB80[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018DB8C[])(void); - -void func_80167A9C(void *a0) { - D_8018DB8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018DC98; - extern u8 D_8018DCAC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018DC98); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018DCAC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018DAEC[]; -extern u8 D_8018DB00[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018DAEC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018DB00; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018DBA4[])(void); - -void func_80168744(void *a0) { - D_8018DBA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018DB94 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018DB94[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018DB94; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018DBAC[])(void); - -void func_801689D8(void *a0) { - D_8018DBAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018DBB4[])(void); - -void func_80168AA8(void *a0) { - D_8018DBB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018DBBC[])(void); - -void func_80168D58(void *a0) { - D_8018DBBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018DBC4[])(void); - -void func_8016901C(void *a0) { - D_8018DBC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015AE2C", func_80169228); - - -extern void (*D_8018DBCC[])(void); - -void func_801693CC(void *a0) { - D_8018DBCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018DBD4[])(void); - -void func_80169830(void *a0) { - D_8018DBD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018DC88[])(void); - -void func_80169B80(void *a0) { - D_8018DC88[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018DBDC[]; - extern u8 D_8018DC4C[]; - extern u8 D_8018DC7C[]; - extern u8 D_801E2478[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018DC7C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018DBDC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801E2478; - RotMatrixYXZ(rot, D_801E2478); - func_80048D9C(D_801E2478, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018DC4C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018DC90[])(void); - -void func_80169F00(void *a0) { - D_8018DC90[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018DC40[]; -extern char D_8018DC00[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018DC40, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018DC00); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018DCC8[])(void); - -void func_8016A020(void *a0) { - D_8018DCC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018DC98; - extern u8 D_8018DCAC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018DC98); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018DCAC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018DCD4[])(void); - -void func_8016A700(void *a0) { - D_8018DCD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018DD1C[])(void); - -void func_8016AB30(void *a0) { - D_8018DD1C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c b/src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c new file mode 100644 index 000000000..6f2a2d704 --- /dev/null +++ b/src/ov_SC03_124/ov_SC03_124_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018D0E8; +extern u8 D_8018D058; +extern u8 D_8018D034; +extern u8 D_8018D010; +extern u8 D_8018D0C4; +extern u8 D_8018D0A0; +extern u8 D_8018D07C; +extern u8 D_8018CFEC; +extern void func_80145934(void); +extern u8 D_8018D178; +extern u8 D_8018D154; +extern u8 D_8018D130; +extern u8 D_8018D10C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018C570[]; +extern unsigned char D_8018C5A0[]; +extern unsigned char D_8018C5F0[]; +extern unsigned char D_8018C620[]; +extern unsigned char D_8018C650[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018C6A0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018C768[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018C7F0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018C7F8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E0650; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E0654; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018C828; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018C8D0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018C8F4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018C8E4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018C908[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018C914[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018C924[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018C93C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018C92C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018C950[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018C96C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018C95C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018C980[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018C994[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018C9A8; +extern void (*D_8018C9D0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018C9B0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018CA1C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018CA20[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018CE84[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018CE94[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E0688; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018CEBC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018CE9C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018CEAC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018CEFC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018CF04[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018CED0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018CF10[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018CEE0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E0690; +extern s32 D_801E069C; +extern s32 D_801E06A0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018CF4C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018CF20[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E0698; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018D19C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018CFBC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018D240[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018D394[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018D1B0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018D39C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018D1C0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018D1E0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018D3A4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018D3CC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018D24C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018D3D8[])(void); + +void func_8015C714(void *a0) { + D_8018D3D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018D24C[])(void*); + extern int D_8018D1F0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018D24C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018D24C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D1F0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018D24C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018D24C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018D24C[])(void*); + extern int D_8018D1F0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018D24C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018D1F0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018D24C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018D3E8[])(void); + D_8018D3E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018D24C[])(struct Ent_8015CD20 *); + extern u8 D_8018D200; + extern u8 D_8018D3F0; + extern u8 D_8018D400; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018D24C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D200); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D3F0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018D400); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018D24C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018D420[])(void); + D_8018D420[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018D410; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018D410 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018D24C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018D47C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018D47C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018C560[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018C560; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018D484[])(void); + D_8018D484[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018D490[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018D490[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018D490[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018D490[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018D24C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018D490[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018D210[]; + extern u8 D_8018D220[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D210); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018D220); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018D490[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018D490[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018D490[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018D4C4[])(void); + D_8018D4C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D24C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018D4CC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018D4E4[])(void); + D_8018D4E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018D24C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018D4CC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018D4CC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018D504[])(void); + D_8018D504[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018D24C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D24C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018D514; +extern u16 D_8018D516; +extern u16 D_8018D518; +extern s32 D_8018D51C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018D514 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018D516 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018D518 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018D51C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018D524; + +void func_8015E588(void) { + func_8013C9C4(&D_8018D524); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018D24C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018D24C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018D538[])(void); + D_8018D538[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018D24C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018D24C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018D540[])(void); + D_8018D540[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018D230; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018D230); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018D24C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018D548[])(void); + D_8018D548[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018D24C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018D24C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018D550[])(void); + D_8018D550[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018D24C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018D558; + extern s32 D_8018D568; + extern s32 D_8018D578; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D558); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D568); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018D24C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018D578); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018D588[])(void); + D_8018D588[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018D24C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018D24C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018D24C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018D24C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018D594[])(void); + D_8018D594[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018D24C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018D24C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018D24C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D24C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018D5A8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018D5A8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018D24C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018D24C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018D24C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018D24C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018D624[])(void); + D_8018D624[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018D24C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018D24C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018D634[])(void); + D_8018D634[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018D24C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018D24C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018D24C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018D24C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018D24C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018D24C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018D24C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018D63C[])(void); + D_8018D63C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018D24C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018D24C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018D24C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018D24C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018D648[])(void); + D_8018D648[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018D24C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018D24C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018D24C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018D24C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018D658[])(void); + +void func_80160EA4(void *a0) { + D_8018D658[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018D24C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018D24C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018D688[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018D688[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018D6EC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018D6EC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E06A8[]; + extern u8 D_8018D6B8[]; + extern u8 D_8018D6D8[]; + extern u8 D_801E06B4[]; + extern u8 D_801E06DC[]; + extern u8 D_801E06F4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E06A8[0] = p; + func_80024054(&D_8018D6B8, &D_801E06B4); + func_8001CE28(p, &D_801E06B4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E06A8[1] = p; + func_80024054(&D_8018D6D8, &D_801E06DC); + func_8001CE28(p, &D_801E06DC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E06A8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E06F4, 0x84); + func_8001CE68(p, &D_801E06F4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E06F4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E06A8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E06A8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018D6EC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018D6EC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018D6EC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018D6EC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E06A8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E06A8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018D710[])(void); + +void func_80162330(void *a0) { + D_8018D710[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E0700[i] via `extern int D_801E0700[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018D71C[]; + extern s32 D_8018D734; + extern u8 D_801E070C[]; + extern u8 D_801E0734[]; + extern u8 D_801E0750[]; + extern int D_801E0700[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E0700[0] = (s32)item; + func_80024054(D_8018D71C, D_801E070C); + func_8001CE28(item, D_801E070C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E0700[1] = (s32)item; + func_80024054(((u8 *)&D_8018D734), D_801E0734); + func_8001CE28(item, D_801E0734); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E0700[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E0750, 0x84); + func_8001CE68(item, D_801E0750); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E0750, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E0700[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E0700; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_801627E8); + + +extern void (*D_8018D758[])(void); + +void func_80162834(void *a0) { + D_8018D758[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018D748; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018D748, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801DFB40[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801DFB40, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801DFB40[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801DFB40, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018D760[])(void); + +void func_80163A58(void *a0) { + D_8018D760[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801DFB48; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801DFB48; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018D7B4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018D7B4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018D77C; +extern s16 D_8018D7B0; +extern s16 D_8018D7AE; +extern s16 D_8018D7AC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018D77C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018D7B0 = 0x80; + D_8018D7AE = 0x80; + D_8018D7AC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018D7B0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018D7B0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018D7B0 - 8; + D_8018D7B0 = nv; + D_8018D7AE = nv; + D_8018D7AC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018D7C0[])(void); + +void func_80164BA0(void *a0) { + D_8018D7C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E0760; +extern u8 D_801E0761; +extern u8 D_801E0762; +extern u8 D_801E0763; +extern u8 D_801E0764; +extern u8 D_801E0765; +extern u8 D_801E0766; +extern u8 D_801E0767; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E0760; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E0761 = 0xf0; + *(u8 *)base = 0xf0; + D_801E0762 = 0xc0; + D_801E0766 = 0; + D_801E0765 = 0; + D_801E0764 = 0; + D_801E0767 = 0; + D_801E0763 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E0760; +extern u8 D_801E0761; +extern u8 D_801E0762; + +s32 func_80164E40(void) { + u8 *p = &D_801E0760; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E0761 != 0) { + D_801E0761 -= 0x10; + } + if (D_801E0762 != 0) { + D_801E0762 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018D7D0[])(void); + +void func_80164EA4(void *a0) { + D_8018D7D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E07AC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E07AC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E07A0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E07A0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E07A0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E07A0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E07A0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018D7E4[]; + extern u32 D_8018D804, D_8018D808, D_8018D80C, D_8018D810; + extern u32 D_8018D804, D_8018D808, D_8018D80C, D_8018D810; + extern u32 D_8018D804, D_8018D808, D_8018D80C, D_8018D810; + extern u32 D_8018D804, D_8018D808, D_8018D80C, D_8018D810; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018D7E4[0x00], p); + ApplyMatrixSV(mat, &D_8018D7E4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018D7E4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018D7E4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018D80C; + *(u32 *)(prim + 0x24) = D_8018D804; + *(u32 *)(prim + 0x28) = D_8018D810; + *(u32 *)(prim + 0x2c) = D_8018D808; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018D814[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018D814[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018D814[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018D814[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018D890[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018D890[a1 & 0x7F]; +} + + + +extern s32 D_8018D8B0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018D8B0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018D92C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018D92C[a1 & 0x7F]; +} + + + +extern u8 D_8018D94C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018D94C[a1 & 0x7F]; +} + + + +extern u8 D_8018D96C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018D96C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018D98C[])(void); + D_8018D98C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018DA08[])(void); + +void func_80165AC8(void) { + D_8018DA08[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018DA84[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018DA84[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801DFB50; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801DFB50, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018DA90[])(void); + +void func_80166018(void *a0) { + D_8018DA90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018DA98[])(void); + +void func_801663FC(void *a0) { + D_8018DA98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018DB60[])(void); + +void func_80166618(void *a0) { + D_8018DB60[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018DB70[])(void); + +void func_80166654(void *a0) { + D_8018DB70[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E0820[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E0820[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E0820). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E0820[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E0820)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E0820[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E0820[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018DAB4[]; + extern u8 D_8018DAA0[]; + extern u8 D_8018DAC8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018DAB4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018DAA0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018DAC8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80167714); + + +extern void (*D_8018DB80[])(void); + +void func_801678B4(void *a0) { + D_8018DB80[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018DB8C[])(void); + +void func_80167A9C(void *a0) { + D_8018DB8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018DC98; + extern u8 D_8018DCAC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018DC98); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018DCAC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018DAEC[]; +extern u8 D_8018DB00[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018DAEC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018DB00; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018DBA4[])(void); + +void func_80168744(void *a0) { + D_8018DBA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018DB94 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018DB94[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018DB94; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018DBAC[])(void); + +void func_801689D8(void *a0) { + D_8018DBAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018DBB4[])(void); + +void func_80168AA8(void *a0) { + D_8018DBB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018DBBC[])(void); + +void func_80168D58(void *a0) { + D_8018DBBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018DBC4[])(void); + +void func_8016901C(void *a0) { + D_8018DBC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_124/nonmatchings/ov_SC03_124_jr_8015C32C", func_80169228); + + +extern void (*D_8018DBCC[])(void); + +void func_801693CC(void *a0) { + D_8018DBCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018DBD4[])(void); + +void func_80169830(void *a0) { + D_8018DBD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018DC88[])(void); + +void func_80169B80(void *a0) { + D_8018DC88[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018DBDC[]; + extern u8 D_8018DC4C[]; + extern u8 D_8018DC7C[]; + extern u8 D_801E2478[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018DC7C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018DBDC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801E2478; + RotMatrixYXZ(rot, D_801E2478); + func_80048D9C(D_801E2478, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018DC4C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018DC90[])(void); + +void func_80169F00(void *a0) { + D_8018DC90[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018DC40[]; +extern char D_8018DC00[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018DC40, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018DC00); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018DCC8[])(void); + +void func_8016A020(void *a0) { + D_8018DCC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018DC98; + extern u8 D_8018DCAC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018DC98); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018DCAC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018DCD4[])(void); + +void func_8016A700(void *a0) { + D_8018DCD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018DD1C[])(void); + +void func_8016AB30(void *a0) { + D_8018DD1C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_125/ov_SC03_125_jr_8015AE2C.c b/src/ov_SC03_125/ov_SC03_125_jr_8015AE2C.c index f5f57db6f..156edf70d 100644 --- a/src/ov_SC03_125/ov_SC03_125_jr_8015AE2C.c +++ b/src/ov_SC03_125/ov_SC03_125_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801865A8[])(void); - -void func_8015C714(void *a0) { - D_801865A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018641C[])(void*); - extern int D_801863C0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018641C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018641C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801863C0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018641C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018641C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018641C[])(void*); - extern int D_801863C0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018641C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801863C0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018641C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801865B8[])(void); - D_801865B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018641C[])(struct Ent_8015CD20 *); - extern u8 D_801863D0; - extern u8 D_801865C0; - extern u8 D_801865D0; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018641C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801863D0); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801865C0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801865D0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018641C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801865F0[])(void); - D_801865F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801865E0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801865E0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018641C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018664C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018664C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80185730[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80185730; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80186654[])(void); - D_80186654[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80186660[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80186660[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80186660[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80186660[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018641C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80186660[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801863E0[]; - extern u8 D_801863F0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801863E0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801863F0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80186660[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186660[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186660[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80186694[])(void); - D_80186694[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018641C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018669C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801866B4[])(void); - D_801866B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018641C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018669C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801866D4[])(void); - D_801866D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018641C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018641C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801866E4; -extern u16 D_801866E6; -extern u16 D_801866E8; -extern s32 D_801866EC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801866E4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801866E6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801866E8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801866EC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801866F4; - -void func_8015E588(void) { - func_8013C9C4(&D_801866F4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018641C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018641C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80186708[])(void); - D_80186708[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018641C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018641C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80186710[])(void); - D_80186710[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80186400; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186400); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018641C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80186718[])(void); - D_80186718[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018641C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018641C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80186720[])(void); - D_80186720[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018641C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80186728; - extern s32 D_80186738; - extern s32 D_80186748; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018641C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186728); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186738); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018641C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186748); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80186758[])(void); - D_80186758[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018641C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018641C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018641C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018641C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80186764[])(void); - D_80186764[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018641C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018641C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018641C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018641C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80186778[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80186778[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018641C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018641C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018641C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018641C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801867F4[])(void); - D_801867F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018641C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018641C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80186804[])(void); - D_80186804[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018641C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018641C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018641C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018641C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018641C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018641C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018641C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018680C[])(void); - D_8018680C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018641C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018641C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018641C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018641C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80186818[])(void); - D_80186818[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018641C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018641C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018641C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018641C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80186828[])(void); - -void func_80160EA4(void *a0) { - D_80186828[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018641C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018641C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80186858[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80186858[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801868BC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801868BC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C2FA0[]; - extern u8 D_80186888[]; - extern u8 D_801868A8[]; - extern u8 D_801C2FAC[]; - extern u8 D_801C2FD4[]; - extern u8 D_801C2FEC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C2FA0[0] = p; - func_80024054(&D_80186888, &D_801C2FAC); - func_8001CE28(p, &D_801C2FAC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C2FA0[1] = p; - func_80024054(&D_801868A8, &D_801C2FD4); - func_8001CE28(p, &D_801C2FD4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C2FA0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C2FEC, 0x84); - func_8001CE68(p, &D_801C2FEC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C2FEC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C2FA0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C2FA0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801868BC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801868BC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801868BC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801868BC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C2FA0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C2FA0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801868E0[])(void); - -void func_80162330(void *a0) { - D_801868E0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C2FF8[i] via `extern int D_801C2FF8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801868EC[]; - extern s32 D_80186904; - extern u8 D_801C3004[]; - extern u8 D_801C302C[]; - extern u8 D_801C3048[]; - extern int D_801C2FF8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C2FF8[0] = (s32)item; - func_80024054(D_801868EC, D_801C3004); - func_8001CE28(item, D_801C3004); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C2FF8[1] = (s32)item; - func_80024054(((u8 *)&D_80186904), D_801C302C); - func_8001CE28(item, D_801C302C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C2FF8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C3048, 0x84); - func_8001CE68(item, D_801C3048); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C3048, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C2FF8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C2FF8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_801627E8); - - -extern void (*D_80186928[])(void); - -void func_80162834(void *a0) { - D_80186928[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80186918; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80186918, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C282C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C282C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C282C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C282C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80186930[])(void); - -void func_80163A58(void *a0) { - D_80186930[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C2834; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C2834; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80186984[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80186984[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018694C; -extern s16 D_80186980; -extern s16 D_8018697E; -extern s16 D_8018697C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018694C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80186980 = 0x80; - D_8018697E = 0x80; - D_8018697C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80186980 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80186980` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80186980 - 8; - D_80186980 = nv; - D_8018697E = nv; - D_8018697C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80186990[])(void); - -void func_80164BA0(void *a0) { - D_80186990[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C3058; -extern u8 D_801C3059; -extern u8 D_801C305A; -extern u8 D_801C305B; -extern u8 D_801C305C; -extern u8 D_801C305D; -extern u8 D_801C305E; -extern u8 D_801C305F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C3058; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C3059 = 0xf0; - *(u8 *)base = 0xf0; - D_801C305A = 0xc0; - D_801C305E = 0; - D_801C305D = 0; - D_801C305C = 0; - D_801C305F = 0; - D_801C305B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C3058; -extern u8 D_801C3059; -extern u8 D_801C305A; - -s32 func_80164E40(void) { - u8 *p = &D_801C3058; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C3059 != 0) { - D_801C3059 -= 0x10; - } - if (D_801C305A != 0) { - D_801C305A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801869A0[])(void); - -void func_80164EA4(void *a0) { - D_801869A0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C30A4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C30A4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C3098[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C3098[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C3098[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C3098; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C3098; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801869B4[]; - extern u32 D_801869D4, D_801869D8, D_801869DC, D_801869E0; - extern u32 D_801869D4, D_801869D8, D_801869DC, D_801869E0; - extern u32 D_801869D4, D_801869D8, D_801869DC, D_801869E0; - extern u32 D_801869D4, D_801869D8, D_801869DC, D_801869E0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801869B4[0x00], p); - ApplyMatrixSV(mat, &D_801869B4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801869B4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801869B4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801869DC; - *(u32 *)(prim + 0x24) = D_801869D4; - *(u32 *)(prim + 0x28) = D_801869E0; - *(u32 *)(prim + 0x2c) = D_801869D8; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801869E4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801869E4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801869E4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801869E4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80186A60[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80186A60[a1 & 0x7F]; -} - - - -extern s32 D_80186A80[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80186A80[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80186AFC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80186AFC[a1 & 0x7F]; -} - - - -extern u8 D_80186B1C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80186B1C[a1 & 0x7F]; -} - - - -extern u8 D_80186B3C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80186B3C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80186B5C[])(void); - D_80186B5C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80186BD8[])(void); - -void func_80165AC8(void) { - D_80186BD8[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80186C54[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80186C54[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C283C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C283C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80186C60[])(void); - -void func_80166018(void *a0) { - D_80186C60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80186C68[])(void); - -void func_801663FC(void *a0) { - D_80186C68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80186D30[])(void); - -void func_80166618(void *a0) { - D_80186D30[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80186D40[])(void); - -void func_80166654(void *a0) { - D_80186D40[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C3118[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C3118[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C3118). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C3118[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C3118)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C3118[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C3118[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80186C84[]; - extern u8 D_80186C70[]; - extern u8 D_80186C98[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80186C84; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80186C70; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80186C98; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80167714); - - -extern void (*D_80186D50[])(void); - -void func_801678B4(void *a0) { - D_80186D50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80186D5C[])(void); - -void func_80167A9C(void *a0) { - D_80186D5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80186E68; - extern u8 D_80186E7C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80186E68); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80186E7C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80186CBC[]; -extern u8 D_80186CD0[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80186CBC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80186CD0; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80186D74[])(void); - -void func_80168744(void *a0) { - D_80186D74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80186D64 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80186D64[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80186D64; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80186D7C[])(void); - -void func_801689D8(void *a0) { - D_80186D7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80186D84[])(void); - -void func_80168AA8(void *a0) { - D_80186D84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80186D8C[])(void); - -void func_80168D58(void *a0) { - D_80186D8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80186D94[])(void); - -void func_8016901C(void *a0) { - D_80186D94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015AE2C", func_80169228); - - -extern void (*D_80186D9C[])(void); - -void func_801693CC(void *a0) { - D_80186D9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80186DA4[])(void); - -void func_80169830(void *a0) { - D_80186DA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80186E58[])(void); - -void func_80169B80(void *a0) { - D_80186E58[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80186DAC[]; - extern u8 D_80186E1C[]; - extern u8 D_80186E4C[]; - extern u8 D_801C43D0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80186E4C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80186DAC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C43D0; - RotMatrixYXZ(rot, D_801C43D0); - func_80048D9C(D_801C43D0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80186E1C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80186E60[])(void); - -void func_80169F00(void *a0) { - D_80186E60[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80186E10[]; -extern char D_80186DD0[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80186E10, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80186DD0); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80186E98[])(void); - -void func_8016A020(void *a0) { - D_80186E98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80186E68; - extern u8 D_80186E7C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80186E68); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80186E7C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80186EA4[])(void); - -void func_8016A700(void *a0) { - D_80186EA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80186EEC[])(void); - -void func_8016AB30(void *a0) { - D_80186EEC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c b/src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c new file mode 100644 index 000000000..9eb830cea --- /dev/null +++ b/src/ov_SC03_125/ov_SC03_125_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801862B8; +extern u8 D_80186228; +extern u8 D_80186204; +extern u8 D_801861E0; +extern u8 D_80186294; +extern u8 D_80186270; +extern u8 D_8018624C; +extern u8 D_801861BC; +extern void func_80145934(void); +extern u8 D_80186348; +extern u8 D_80186324; +extern u8 D_80186300; +extern u8 D_801862DC; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80185740[]; +extern unsigned char D_80185770[]; +extern unsigned char D_801857C0[]; +extern unsigned char D_801857F0[]; +extern unsigned char D_80185820[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80185870[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80185938[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801859C0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801859C8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C2F48; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C2F4C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801859F8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80185AA0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80185AC4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80185AB4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80185AD8[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80185AE4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80185AF4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80185B0C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80185AFC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80185B20[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80185B3C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80185B2C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80185B50[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80185B64[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80185B78; +extern void (*D_80185BA0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80185B80; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80185BEC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80185BF0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186054[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80186064[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C2F80; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018608C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018606C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018607C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801860CC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801860D4[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801860A0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801860E0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801860B0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C2F88; +extern s32 D_801C2F94; +extern s32 D_801C2F98; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018611C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801860F0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C2F90; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018636C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018618C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80186410[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80186564[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186380; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018656C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186390; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801863B0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80186574[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018659C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018641C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801865A8[])(void); + +void func_8015C714(void *a0) { + D_801865A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018641C[])(void*); + extern int D_801863C0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018641C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018641C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801863C0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018641C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018641C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018641C[])(void*); + extern int D_801863C0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018641C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801863C0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018641C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801865B8[])(void); + D_801865B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018641C[])(struct Ent_8015CD20 *); + extern u8 D_801863D0; + extern u8 D_801865C0; + extern u8 D_801865D0; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018641C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801863D0); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801865C0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801865D0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018641C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801865F0[])(void); + D_801865F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801865E0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801865E0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018641C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018664C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018664C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80185730[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80185730; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80186654[])(void); + D_80186654[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80186660[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80186660[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80186660[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80186660[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018641C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80186660[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801863E0[]; + extern u8 D_801863F0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801863E0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801863F0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80186660[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186660[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186660[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80186694[])(void); + D_80186694[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018641C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018669C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801866B4[])(void); + D_801866B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018641C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018669C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018669C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801866D4[])(void); + D_801866D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018641C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018641C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801866E4; +extern u16 D_801866E6; +extern u16 D_801866E8; +extern s32 D_801866EC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801866E4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801866E6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801866E8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801866EC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801866F4; + +void func_8015E588(void) { + func_8013C9C4(&D_801866F4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018641C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018641C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80186708[])(void); + D_80186708[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018641C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018641C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80186710[])(void); + D_80186710[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80186400; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186400); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018641C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80186718[])(void); + D_80186718[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018641C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018641C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80186720[])(void); + D_80186720[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018641C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80186728; + extern s32 D_80186738; + extern s32 D_80186748; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186728); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186738); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018641C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186748); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80186758[])(void); + D_80186758[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018641C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018641C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018641C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018641C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80186764[])(void); + D_80186764[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018641C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018641C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018641C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018641C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80186778[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80186778[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018641C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018641C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018641C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018641C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801867F4[])(void); + D_801867F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018641C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018641C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80186804[])(void); + D_80186804[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018641C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018641C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018641C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018641C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018641C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018641C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018641C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018680C[])(void); + D_8018680C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018641C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018641C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018641C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018641C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80186818[])(void); + D_80186818[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018641C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018641C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018641C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018641C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80186828[])(void); + +void func_80160EA4(void *a0) { + D_80186828[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018641C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018641C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80186858[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80186858[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801868BC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801868BC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C2FA0[]; + extern u8 D_80186888[]; + extern u8 D_801868A8[]; + extern u8 D_801C2FAC[]; + extern u8 D_801C2FD4[]; + extern u8 D_801C2FEC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C2FA0[0] = p; + func_80024054(&D_80186888, &D_801C2FAC); + func_8001CE28(p, &D_801C2FAC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C2FA0[1] = p; + func_80024054(&D_801868A8, &D_801C2FD4); + func_8001CE28(p, &D_801C2FD4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C2FA0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C2FEC, 0x84); + func_8001CE68(p, &D_801C2FEC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C2FEC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C2FA0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C2FA0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801868BC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801868BC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801868BC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801868BC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C2FA0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C2FA0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801868E0[])(void); + +void func_80162330(void *a0) { + D_801868E0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C2FF8[i] via `extern int D_801C2FF8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801868EC[]; + extern s32 D_80186904; + extern u8 D_801C3004[]; + extern u8 D_801C302C[]; + extern u8 D_801C3048[]; + extern int D_801C2FF8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C2FF8[0] = (s32)item; + func_80024054(D_801868EC, D_801C3004); + func_8001CE28(item, D_801C3004); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C2FF8[1] = (s32)item; + func_80024054(((u8 *)&D_80186904), D_801C302C); + func_8001CE28(item, D_801C302C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C2FF8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C3048, 0x84); + func_8001CE68(item, D_801C3048); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C3048, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C2FF8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C2FF8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_801627E8); + + +extern void (*D_80186928[])(void); + +void func_80162834(void *a0) { + D_80186928[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80186918; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80186918, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C282C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C282C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C282C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C282C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80186930[])(void); + +void func_80163A58(void *a0) { + D_80186930[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C2834; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C2834; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80186984[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80186984[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018694C; +extern s16 D_80186980; +extern s16 D_8018697E; +extern s16 D_8018697C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018694C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80186980 = 0x80; + D_8018697E = 0x80; + D_8018697C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80186980 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80186980` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80186980 - 8; + D_80186980 = nv; + D_8018697E = nv; + D_8018697C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80186990[])(void); + +void func_80164BA0(void *a0) { + D_80186990[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C3058; +extern u8 D_801C3059; +extern u8 D_801C305A; +extern u8 D_801C305B; +extern u8 D_801C305C; +extern u8 D_801C305D; +extern u8 D_801C305E; +extern u8 D_801C305F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C3058; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C3059 = 0xf0; + *(u8 *)base = 0xf0; + D_801C305A = 0xc0; + D_801C305E = 0; + D_801C305D = 0; + D_801C305C = 0; + D_801C305F = 0; + D_801C305B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C3058; +extern u8 D_801C3059; +extern u8 D_801C305A; + +s32 func_80164E40(void) { + u8 *p = &D_801C3058; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C3059 != 0) { + D_801C3059 -= 0x10; + } + if (D_801C305A != 0) { + D_801C305A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801869A0[])(void); + +void func_80164EA4(void *a0) { + D_801869A0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C30A4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C30A4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C3098[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C3098[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C3098[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C3098; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C3098; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801869B4[]; + extern u32 D_801869D4, D_801869D8, D_801869DC, D_801869E0; + extern u32 D_801869D4, D_801869D8, D_801869DC, D_801869E0; + extern u32 D_801869D4, D_801869D8, D_801869DC, D_801869E0; + extern u32 D_801869D4, D_801869D8, D_801869DC, D_801869E0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801869B4[0x00], p); + ApplyMatrixSV(mat, &D_801869B4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801869B4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801869B4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801869DC; + *(u32 *)(prim + 0x24) = D_801869D4; + *(u32 *)(prim + 0x28) = D_801869E0; + *(u32 *)(prim + 0x2c) = D_801869D8; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801869E4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801869E4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801869E4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801869E4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80186A60[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80186A60[a1 & 0x7F]; +} + + + +extern s32 D_80186A80[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80186A80[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80186AFC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80186AFC[a1 & 0x7F]; +} + + + +extern u8 D_80186B1C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80186B1C[a1 & 0x7F]; +} + + + +extern u8 D_80186B3C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80186B3C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80186B5C[])(void); + D_80186B5C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80186BD8[])(void); + +void func_80165AC8(void) { + D_80186BD8[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80186C54[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80186C54[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C283C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C283C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80186C60[])(void); + +void func_80166018(void *a0) { + D_80186C60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80186C68[])(void); + +void func_801663FC(void *a0) { + D_80186C68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80186D30[])(void); + +void func_80166618(void *a0) { + D_80186D30[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80186D40[])(void); + +void func_80166654(void *a0) { + D_80186D40[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C3118[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C3118[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C3118). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C3118[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C3118)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C3118[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C3118[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80186C84[]; + extern u8 D_80186C70[]; + extern u8 D_80186C98[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80186C84; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80186C70; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80186C98; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80167714); + + +extern void (*D_80186D50[])(void); + +void func_801678B4(void *a0) { + D_80186D50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80186D5C[])(void); + +void func_80167A9C(void *a0) { + D_80186D5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80186E68; + extern u8 D_80186E7C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80186E68); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80186E7C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80186CBC[]; +extern u8 D_80186CD0[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80186CBC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80186CD0; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80186D74[])(void); + +void func_80168744(void *a0) { + D_80186D74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80186D64 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80186D64[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80186D64; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80186D7C[])(void); + +void func_801689D8(void *a0) { + D_80186D7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80186D84[])(void); + +void func_80168AA8(void *a0) { + D_80186D84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80186D8C[])(void); + +void func_80168D58(void *a0) { + D_80186D8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80186D94[])(void); + +void func_8016901C(void *a0) { + D_80186D94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_125/nonmatchings/ov_SC03_125_jr_8015C32C", func_80169228); + + +extern void (*D_80186D9C[])(void); + +void func_801693CC(void *a0) { + D_80186D9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80186DA4[])(void); + +void func_80169830(void *a0) { + D_80186DA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80186E58[])(void); + +void func_80169B80(void *a0) { + D_80186E58[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80186DAC[]; + extern u8 D_80186E1C[]; + extern u8 D_80186E4C[]; + extern u8 D_801C43D0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80186E4C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80186DAC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C43D0; + RotMatrixYXZ(rot, D_801C43D0); + func_80048D9C(D_801C43D0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80186E1C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80186E60[])(void); + +void func_80169F00(void *a0) { + D_80186E60[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80186E10[]; +extern char D_80186DD0[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80186E10, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80186DD0); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80186E98[])(void); + +void func_8016A020(void *a0) { + D_80186E98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80186E68; + extern u8 D_80186E7C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80186E68); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80186E7C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80186EA4[])(void); + +void func_8016A700(void *a0) { + D_80186EA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80186EEC[])(void); + +void func_8016AB30(void *a0) { + D_80186EEC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC03_126/ov_SC03_126_jr_8015AE2C.c b/src/ov_SC03_126/ov_SC03_126_jr_8015AE2C.c index a34913839..2568e6cd0 100644 --- a/src/ov_SC03_126/ov_SC03_126_jr_8015AE2C.c +++ b/src/ov_SC03_126/ov_SC03_126_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181AA0[])(void); - -void func_8015C714(void *a0) { - D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181914[])(void*); - extern int D_801818B8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181914[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181914[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181914[])(void*); - extern int D_801818B8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181AB0[])(void); - D_80181AB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181914[])(struct Ent_8015CD20 *); - extern u8 D_801818C8; - extern u8 D_80181AB8; - extern u8 D_80181AC8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801818C8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AB8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AC8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181AE8[])(void); - D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181AD8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181AD8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181B44; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181B44, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180C28[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180C28; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80181B4C[])(void); - D_80181B4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80181B58[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181914[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80181B58[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801818D8[]; - extern u8 D_801818E8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818D8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818E8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80181B8C[])(void); - D_80181B8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181914[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181B94[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181BAC[])(void); - D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181914[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181B94[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181BCC[])(void); - D_80181BCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181914[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181914)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181BDC; -extern u16 D_80181BDE; -extern u16 D_80181BE0; -extern s32 D_80181BE4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181BDC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80181BDE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181BE0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181BE4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181BEC; - -void func_8015E588(void) { - func_8013C9C4(&D_80181BEC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181914[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181914)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181C00[])(void); - D_80181C00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181914[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181914[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181C08[])(void); - D_80181C08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801818F8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801818F8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181914[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181C10[])(void); - D_80181C10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181914[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181914[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181C18[])(void); - D_80181C18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181914[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181C20; - extern s32 D_80181C30; - extern s32 D_80181C40; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181914[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C20); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C30); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181914[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C40); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80181C50[])(void); - D_80181C50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181914[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80181C5C[])(void); - D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181914[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181914[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80181C70[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80181C70[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181914[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181914)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181914[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181914[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181CEC[])(void); - D_80181CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181914[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181914)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181CFC[])(void); - D_80181CFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181914[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181D04[])(void); - D_80181D04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181914[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181914)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181914[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181D10[])(void); - D_80181D10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181914 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181914[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181914[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181914[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181D20[])(void); - -void func_80160EA4(void *a0) { - D_80181D20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181914[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80181D50[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80181D50[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181DB4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181DB4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8018E868[]; - extern u8 D_80181D80[]; - extern u8 D_80181DA0[]; - extern u8 D_8018E874[]; - extern u8 D_8018E89C[]; - extern u8 D_8018E8B4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8018E868[0] = p; - func_80024054(&D_80181D80, &D_8018E874); - func_8001CE28(p, &D_8018E874); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8018E868[1] = p; - func_80024054(&D_80181DA0, &D_8018E89C); - func_8001CE28(p, &D_8018E89C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8018E868[2] = p; - func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); - func_8001CE68(p, &D_8018E8B4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E868[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8018E868; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181DB4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181DB4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181DB4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181DB4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8018E868[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8018E868; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181DD8[])(void); - -void func_80162330(void *a0) { - D_80181DD8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8018E8C0[i] via `extern int D_8018E8C0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181DE4[]; - extern s32 D_80181DFC; - extern u8 D_8018E8CC[]; - extern u8 D_8018E8F4[]; - extern u8 D_8018E910[]; - extern int D_8018E8C0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8018E8C0[0] = (s32)item; - func_80024054(D_80181DE4, D_8018E8CC); - func_8001CE28(item, D_8018E8CC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8018E8C0[1] = (s32)item; - func_80024054(((u8 *)&D_80181DFC), D_8018E8F4); - func_8001CE28(item, D_8018E8F4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8018E8C0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); - func_8001CE68(item, D_8018E910); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E8C0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8018E8C0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181E20[])(void); - -void func_80162834(void *a0) { - D_80181E20[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181E10; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181E10, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8018E118[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8018E118, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8018E118[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8018E118, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181E28[])(void); - -void func_80163A58(void *a0) { - D_80181E28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8018E120; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8018E120; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80181E7C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80181E7C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181E44; -extern s16 D_80181E78; -extern s16 D_80181E76; -extern s16 D_80181E74; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181E44; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181E78 = 0x80; - D_80181E76 = 0x80; - D_80181E74 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181E78 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181E78` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181E78 - 8; - D_80181E78 = nv; - D_80181E76 = nv; - D_80181E74 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181E88[])(void); - -void func_80164BA0(void *a0) { - D_80181E88[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8018E920; -extern u8 D_8018E921; -extern u8 D_8018E922; -extern u8 D_8018E923; -extern u8 D_8018E924; -extern u8 D_8018E925; -extern u8 D_8018E926; -extern u8 D_8018E927; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8018E920; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8018E921 = 0xf0; - *(u8 *)base = 0xf0; - D_8018E922 = 0xc0; - D_8018E926 = 0; - D_8018E925 = 0; - D_8018E924 = 0; - D_8018E927 = 0; - D_8018E923 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8018E920; -extern u8 D_8018E921; -extern u8 D_8018E922; - -s32 func_80164E40(void) { - u8 *p = &D_8018E920; - if (*p != 0) { - *p -= 0x10; - } - if (D_8018E921 != 0) { - D_8018E921 -= 0x10; - } - if (D_8018E922 != 0) { - D_8018E922 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181E98[])(void); - -void func_80164EA4(void *a0) { - D_80181E98[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8018E96C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8018E96C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8018E960[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8018E960[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8018E960[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8018E960; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8018E960; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181EAC[]; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181EAC[0x00], p); - ApplyMatrixSV(mat, &D_80181EAC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181EAC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181EAC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181ED4; - *(u32 *)(prim + 0x24) = D_80181ECC; - *(u32 *)(prim + 0x28) = D_80181ED8; - *(u32 *)(prim + 0x2c) = D_80181ED0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181EDC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181EDC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181EDC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181EDC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80181F58[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80181F58[a1 & 0x7F]; -} - - - -extern s32 D_80181F78[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181F78[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181FF4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181FF4[a1 & 0x7F]; -} - - - -extern u8 D_80182014[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182014[a1 & 0x7F]; -} - - - -extern u8 D_80182034[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182034[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80182054[])(void); - D_80182054[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801820D0[])(void); - -void func_80165AC8(void) { - D_801820D0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018214C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018214C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8018E128; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8018E128, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80182158[])(void); - -void func_80166018(void *a0) { - D_80182158[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80182160[])(void); - -void func_801663FC(void *a0) { - D_80182160[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182228[])(void); - -void func_80166618(void *a0) { - D_80182228[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182238[])(void); - -void func_80166654(void *a0) { - D_80182238[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8018E9E0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8018E9E0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018E9E0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8018E9E0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8018E9E0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8018E9E0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8018E9E0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018217C[]; - extern u8 D_80182168[]; - extern u8 D_80182190[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018217C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80182168; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182190; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80167714); - - -extern void (*D_80182248[])(void); - -void func_801678B4(void *a0) { - D_80182248[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80182254[])(void); - -void func_80167A9C(void *a0) { - D_80182254[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80182360; - extern u8 D_80182374[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80182360); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182374; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801821B4[]; -extern u8 D_801821C8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801821B4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801821C8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018226C[])(void); - -void func_80168744(void *a0) { - D_8018226C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018225C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018225C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018225C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80182274[])(void); - -void func_801689D8(void *a0) { - D_80182274[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018227C[])(void); - -void func_80168AA8(void *a0) { - D_8018227C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80182284[])(void); - -void func_80168D58(void *a0) { - D_80182284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018228C[])(void); - -void func_8016901C(void *a0) { - D_8018228C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015AE2C", func_80169228); - - -extern void (*D_80182294[])(void); - -void func_801693CC(void *a0) { - D_80182294[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018229C[])(void); - -void func_80169830(void *a0) { - D_8018229C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80182350[])(void); - -void func_80169B80(void *a0) { - D_80182350[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801822A4[]; - extern u8 D_80182314[]; - extern u8 D_80182344[]; - extern u8 D_8018F9E0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80182344, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801822A4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8018F9E0; - RotMatrixYXZ(rot, D_8018F9E0); - func_80048D9C(D_8018F9E0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182314); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80182358[])(void); - -void func_80169F00(void *a0) { - D_80182358[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80182308[]; -extern char D_801822C8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80182308, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801822C8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80182390[])(void); - -void func_8016A020(void *a0) { - D_80182390[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80182360; - extern u8 D_80182374[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80182360); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182374; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018239C[])(void); - -void func_8016A700(void *a0) { - D_8018239C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801823E4[])(void); - -void func_8016AB30(void *a0) { - D_801823E4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c b/src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c new file mode 100644 index 000000000..49bceac60 --- /dev/null +++ b/src/ov_SC03_126/ov_SC03_126_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801817B0; +extern u8 D_80181720; +extern u8 D_801816FC; +extern u8 D_801816D8; +extern u8 D_8018178C; +extern u8 D_80181768; +extern u8 D_80181744; +extern u8 D_801816B4; +extern void func_80145934(void); +extern u8 D_80181840; +extern u8 D_8018181C; +extern u8 D_801817F8; +extern u8 D_801817D4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180C38[]; +extern unsigned char D_80180C68[]; +extern unsigned char D_80180CB8[]; +extern unsigned char D_80180CE8[]; +extern unsigned char D_80180D18[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80180D68[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80180E30[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180EB8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180EC0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8018E810; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8018E814; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180EF0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180F98[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180FBC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180FAC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180FD0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180FDC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180FEC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181004[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180FF4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181018[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181034[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181024; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181048[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018105C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80181070; +extern void (*D_80181098[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80181078; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801810E4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801810E8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018154C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018155C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8018E848; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80181584[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80181564; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80181574; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801815C4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801815CC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80181598; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801815D8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801815A8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8018E850; +extern s32 D_8018E85C; +extern s32 D_8018E860; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80181614[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801815E8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8018E858; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80181864[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80181684[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181908[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80181A5C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80181878; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80181A64[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80181888; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801818A8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80181A6C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80181A94[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181914[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181AA0[])(void); + +void func_8015C714(void *a0) { + D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181914[])(void*); + extern int D_801818B8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181914[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181914[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181914[])(void*); + extern int D_801818B8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181AB0[])(void); + D_80181AB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181914[])(struct Ent_8015CD20 *); + extern u8 D_801818C8; + extern u8 D_80181AB8; + extern u8 D_80181AC8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801818C8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AB8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AC8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181AE8[])(void); + D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181AD8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181AD8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181B44; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181B44, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180C28[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180C28; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80181B4C[])(void); + D_80181B4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80181B58[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181914[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80181B58[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801818D8[]; + extern u8 D_801818E8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818D8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818E8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80181B8C[])(void); + D_80181B8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181914[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181B94[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181BAC[])(void); + D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181914[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181B94[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181BCC[])(void); + D_80181BCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181914[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181914)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181BDC; +extern u16 D_80181BDE; +extern u16 D_80181BE0; +extern s32 D_80181BE4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181BDC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80181BDE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181BE0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181BE4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181BEC; + +void func_8015E588(void) { + func_8013C9C4(&D_80181BEC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181914[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181914)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181C00[])(void); + D_80181C00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181914[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181914[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181C08[])(void); + D_80181C08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801818F8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801818F8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181914[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181C10[])(void); + D_80181C10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181914[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181914[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181C18[])(void); + D_80181C18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181914[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181C20; + extern s32 D_80181C30; + extern s32 D_80181C40; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181914[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C20); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C30); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C40); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80181C50[])(void); + D_80181C50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181914[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80181C5C[])(void); + D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181914[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181914[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80181C70[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80181C70[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181914[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181914)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181914[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181914[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181CEC[])(void); + D_80181CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181914[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181914)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181CFC[])(void); + D_80181CFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181914[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181D04[])(void); + D_80181D04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181914[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181914)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181914[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181D10[])(void); + D_80181D10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181914 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181914[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181914[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181914[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181D20[])(void); + +void func_80160EA4(void *a0) { + D_80181D20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181914[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80181D50[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80181D50[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181DB4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181DB4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8018E868[]; + extern u8 D_80181D80[]; + extern u8 D_80181DA0[]; + extern u8 D_8018E874[]; + extern u8 D_8018E89C[]; + extern u8 D_8018E8B4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8018E868[0] = p; + func_80024054(&D_80181D80, &D_8018E874); + func_8001CE28(p, &D_8018E874); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8018E868[1] = p; + func_80024054(&D_80181DA0, &D_8018E89C); + func_8001CE28(p, &D_8018E89C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8018E868[2] = p; + func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); + func_8001CE68(p, &D_8018E8B4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E868[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8018E868; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181DB4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181DB4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181DB4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181DB4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8018E868[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8018E868; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181DD8[])(void); + +void func_80162330(void *a0) { + D_80181DD8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8018E8C0[i] via `extern int D_8018E8C0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181DE4[]; + extern s32 D_80181DFC; + extern u8 D_8018E8CC[]; + extern u8 D_8018E8F4[]; + extern u8 D_8018E910[]; + extern int D_8018E8C0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8018E8C0[0] = (s32)item; + func_80024054(D_80181DE4, D_8018E8CC); + func_8001CE28(item, D_8018E8CC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8018E8C0[1] = (s32)item; + func_80024054(((u8 *)&D_80181DFC), D_8018E8F4); + func_8001CE28(item, D_8018E8F4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8018E8C0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); + func_8001CE68(item, D_8018E910); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E8C0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8018E8C0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_801627E8); + + +extern void (*D_80181E20[])(void); + +void func_80162834(void *a0) { + D_80181E20[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181E10; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181E10, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8018E118[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8018E118, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8018E118[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8018E118, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181E28[])(void); + +void func_80163A58(void *a0) { + D_80181E28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8018E120; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8018E120; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80181E7C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80181E7C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181E44; +extern s16 D_80181E78; +extern s16 D_80181E76; +extern s16 D_80181E74; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181E44; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181E78 = 0x80; + D_80181E76 = 0x80; + D_80181E74 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181E78 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181E78` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181E78 - 8; + D_80181E78 = nv; + D_80181E76 = nv; + D_80181E74 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181E88[])(void); + +void func_80164BA0(void *a0) { + D_80181E88[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8018E920; +extern u8 D_8018E921; +extern u8 D_8018E922; +extern u8 D_8018E923; +extern u8 D_8018E924; +extern u8 D_8018E925; +extern u8 D_8018E926; +extern u8 D_8018E927; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8018E920; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8018E921 = 0xf0; + *(u8 *)base = 0xf0; + D_8018E922 = 0xc0; + D_8018E926 = 0; + D_8018E925 = 0; + D_8018E924 = 0; + D_8018E927 = 0; + D_8018E923 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8018E920; +extern u8 D_8018E921; +extern u8 D_8018E922; + +s32 func_80164E40(void) { + u8 *p = &D_8018E920; + if (*p != 0) { + *p -= 0x10; + } + if (D_8018E921 != 0) { + D_8018E921 -= 0x10; + } + if (D_8018E922 != 0) { + D_8018E922 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181E98[])(void); + +void func_80164EA4(void *a0) { + D_80181E98[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8018E96C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8018E96C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8018E960[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8018E960[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8018E960[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8018E960; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8018E960; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181EAC[]; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181EAC[0x00], p); + ApplyMatrixSV(mat, &D_80181EAC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181EAC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181EAC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181ED4; + *(u32 *)(prim + 0x24) = D_80181ECC; + *(u32 *)(prim + 0x28) = D_80181ED8; + *(u32 *)(prim + 0x2c) = D_80181ED0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181EDC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181EDC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181EDC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181EDC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80181F58[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80181F58[a1 & 0x7F]; +} + + + +extern s32 D_80181F78[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181F78[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181FF4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181FF4[a1 & 0x7F]; +} + + + +extern u8 D_80182014[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182014[a1 & 0x7F]; +} + + + +extern u8 D_80182034[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182034[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80182054[])(void); + D_80182054[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801820D0[])(void); + +void func_80165AC8(void) { + D_801820D0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018214C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018214C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8018E128; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8018E128, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80182158[])(void); + +void func_80166018(void *a0) { + D_80182158[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80182160[])(void); + +void func_801663FC(void *a0) { + D_80182160[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182228[])(void); + +void func_80166618(void *a0) { + D_80182228[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182238[])(void); + +void func_80166654(void *a0) { + D_80182238[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8018E9E0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8018E9E0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018E9E0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8018E9E0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8018E9E0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8018E9E0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8018E9E0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018217C[]; + extern u8 D_80182168[]; + extern u8 D_80182190[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018217C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80182168; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182190; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80167714); + + +extern void (*D_80182248[])(void); + +void func_801678B4(void *a0) { + D_80182248[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80182254[])(void); + +void func_80167A9C(void *a0) { + D_80182254[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80182360; + extern u8 D_80182374[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80182360); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182374; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801821B4[]; +extern u8 D_801821C8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801821B4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801821C8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018226C[])(void); + +void func_80168744(void *a0) { + D_8018226C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018225C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018225C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018225C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80182274[])(void); + +void func_801689D8(void *a0) { + D_80182274[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018227C[])(void); + +void func_80168AA8(void *a0) { + D_8018227C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80182284[])(void); + +void func_80168D58(void *a0) { + D_80182284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018228C[])(void); + +void func_8016901C(void *a0) { + D_8018228C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC03_126/nonmatchings/ov_SC03_126_jr_8015C32C", func_80169228); + + +extern void (*D_80182294[])(void); + +void func_801693CC(void *a0) { + D_80182294[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018229C[])(void); + +void func_80169830(void *a0) { + D_8018229C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80182350[])(void); + +void func_80169B80(void *a0) { + D_80182350[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801822A4[]; + extern u8 D_80182314[]; + extern u8 D_80182344[]; + extern u8 D_8018F9E0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80182344, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801822A4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8018F9E0; + RotMatrixYXZ(rot, D_8018F9E0); + func_80048D9C(D_8018F9E0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182314); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80182358[])(void); + +void func_80169F00(void *a0) { + D_80182358[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80182308[]; +extern char D_801822C8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80182308, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801822C8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80182390[])(void); + +void func_8016A020(void *a0) { + D_80182390[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80182360; + extern u8 D_80182374[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80182360); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182374; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018239C[])(void); + +void func_8016A700(void *a0) { + D_8018239C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801823E4[])(void); + +void func_8016AB30(void *a0) { + D_801823E4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_000/ov_SC04_000_jr_8015AE2C.c b/src/ov_SC04_000/ov_SC04_000_jr_8015AE2C.c index e3f0ee4ef..98a389848 100644 --- a/src/ov_SC04_000/ov_SC04_000_jr_8015AE2C.c +++ b/src/ov_SC04_000/ov_SC04_000_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80185AAC[])(void); - -void func_8015C714(void *a0) { - D_80185AAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80185920[])(void*); - extern int D_801858C4; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80185920)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80185920)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801858C4); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80185920[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80185920[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80185920[])(void*); - extern int D_801858C4; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80185920)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801858C4); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80185920)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80185ABC[])(void); - D_80185ABC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80185920[])(struct Ent_8015CD20 *); - extern u8 D_801858D4; - extern u8 D_80185AC4; - extern u8 D_80185AD4; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80185920[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801858D4); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185AC4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185AD4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80185920[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80185AF4[])(void); - D_80185AF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80185AE4; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80185AE4 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80185920[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80185B50; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80185B50, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80184C34[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80184C34; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80185B58[])(void); - D_80185B58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80185B64[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80185B64[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80185B64[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80185B64[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80185920[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80185B64[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801858E4[]; - extern u8 D_801858F4[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801858E4); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801858F4); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80185B64[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185B64[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185B64[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80185B98[])(void); - D_80185B98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185920[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80185BA0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80185BB8[])(void); - D_80185BB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185920[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80185BA0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80185BD8[])(void); - D_80185BD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80185920[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185920)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80185BE8; -extern u16 D_80185BEA; -extern u16 D_80185BEC; -extern s32 D_80185BF0; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80185BE8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80185BEA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80185BEC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185BF0, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80185BF8; - -void func_8015E588(void) { - func_8013C9C4(&D_80185BF8); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80185920[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185920)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80185C0C[])(void); - D_80185C0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80185920[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80185920[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80185C14[])(void); - D_80185C14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80185904; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185904); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80185920[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80185C1C[])(void); - D_80185C1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80185920[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80185920[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80185C24[])(void); - D_80185C24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80185920[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80185C2C; - extern s32 D_80185C3C; - extern s32 D_80185C4C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80185920[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185C2C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185C3C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80185920[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185C4C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80185C5C[])(void); - D_80185C5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80185920[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80185920[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80185920[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185920[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80185C68[])(void); - D_80185C68[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80185920[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185920[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80185920[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185920[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80185C7C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80185C7C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80185920[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80185920)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80185920[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185920[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80185CF8[])(void); - D_80185CF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80185920[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80185920)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80185D08[])(void); - D_80185D08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80185920[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80185920[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80185920[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80185920[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80185920[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80185920[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80185920[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80185D10[])(void); - D_80185D10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80185920[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80185920)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80185920[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80185920)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80185D1C[])(void); - D_80185D1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185920 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80185920[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80185920[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80185920[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80185D2C[])(void); - -void func_80160EA4(void *a0) { - D_80185D2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80185920[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80185920[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80185D5C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80185D5C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80185DC0; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80185DC0); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A8918[]; - extern u8 D_80185D8C[]; - extern u8 D_80185DAC[]; - extern u8 D_801A8924[]; - extern u8 D_801A894C[]; - extern u8 D_801A8964[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A8918[0] = p; - func_80024054(&D_80185D8C, &D_801A8924); - func_8001CE28(p, &D_801A8924); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A8918[1] = p; - func_80024054(&D_80185DAC, &D_801A894C); - func_8001CE28(p, &D_801A894C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A8918[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A8964, 0x84); - func_8001CE68(p, &D_801A8964); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A8964, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A8918[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A8918; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80185DC0; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80185DC0; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80185DC0; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80185DC0; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A8918[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A8918; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80185DE4[])(void); - -void func_80162330(void *a0) { - D_80185DE4[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A8970[i] via `extern int D_801A8970[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80185DF0[]; - extern s32 D_80185E08; - extern u8 D_801A897C[]; - extern u8 D_801A89A4[]; - extern u8 D_801A89C0[]; - extern int D_801A8970[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A8970[0] = (s32)item; - func_80024054(D_80185DF0, D_801A897C); - func_8001CE28(item, D_801A897C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A8970[1] = (s32)item; - func_80024054(((u8 *)&D_80185E08), D_801A89A4); - func_8001CE28(item, D_801A89A4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A8970[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A89C0, 0x84); - func_8001CE68(item, D_801A89C0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A89C0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A8970[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A8970; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_801627E8); - - -extern void (*D_80185E2C[])(void); - -void func_80162834(void *a0) { - D_80185E2C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80185E1C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80185E1C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801A8194[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801A8194, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801A8194[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801A8194, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80185E34[])(void); - -void func_80163A58(void *a0) { - D_80185E34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801A819C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801A819C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80185E88[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80185E88[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80185E50; -extern s16 D_80185E84; -extern s16 D_80185E82; -extern s16 D_80185E80; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80185E50; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80185E84 = 0x80; - D_80185E82 = 0x80; - D_80185E80 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80185E84 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80185E84` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80185E84 - 8; - D_80185E84 = nv; - D_80185E82 = nv; - D_80185E80 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80185E94[])(void); - -void func_80164BA0(void *a0) { - D_80185E94[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A89D0; -extern u8 D_801A89D1; -extern u8 D_801A89D2; -extern u8 D_801A89D3; -extern u8 D_801A89D4; -extern u8 D_801A89D5; -extern u8 D_801A89D6; -extern u8 D_801A89D7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A89D0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A89D1 = 0xf0; - *(u8 *)base = 0xf0; - D_801A89D2 = 0xc0; - D_801A89D6 = 0; - D_801A89D5 = 0; - D_801A89D4 = 0; - D_801A89D7 = 0; - D_801A89D3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A89D0; -extern u8 D_801A89D1; -extern u8 D_801A89D2; - -s32 func_80164E40(void) { - u8 *p = &D_801A89D0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A89D1 != 0) { - D_801A89D1 -= 0x10; - } - if (D_801A89D2 != 0) { - D_801A89D2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80185EA4[])(void); - -void func_80164EA4(void *a0) { - D_80185EA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A8A1C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A8A1C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A8A10[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A8A10[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A8A10[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A8A10; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A8A10; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80185EB8[]; - extern u32 D_80185ED8, D_80185EDC, D_80185EE0, D_80185EE4; - extern u32 D_80185ED8, D_80185EDC, D_80185EE0, D_80185EE4; - extern u32 D_80185ED8, D_80185EDC, D_80185EE0, D_80185EE4; - extern u32 D_80185ED8, D_80185EDC, D_80185EE0, D_80185EE4; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80185EB8[0x00], p); - ApplyMatrixSV(mat, &D_80185EB8[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80185EB8[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80185EB8[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80185EE0; - *(u32 *)(prim + 0x24) = D_80185ED8; - *(u32 *)(prim + 0x28) = D_80185EE4; - *(u32 *)(prim + 0x2c) = D_80185EDC; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80185EE8[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80185EE8[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80185EE8[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80185EE8[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80185F64[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80185F64[a1 & 0x7F]; -} - - - -extern s32 D_80185F84[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80185F84[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80186000[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80186000[a1 & 0x7F]; -} - - - -extern u8 D_80186020[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80186020[a1 & 0x7F]; -} - - - -extern u8 D_80186040[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80186040[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80186060[])(void); - D_80186060[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801860DC[])(void); - -void func_80165AC8(void) { - D_801860DC[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80186158[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80186158[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801A81A4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801A81A4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80186164[])(void); - -void func_80166018(void *a0) { - D_80186164[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018616C[])(void); - -void func_801663FC(void *a0) { - D_8018616C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80186234[])(void); - -void func_80166618(void *a0) { - D_80186234[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80186244[])(void); - -void func_80166654(void *a0) { - D_80186244[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A8A90[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A8A90[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A8A90). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A8A90[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A8A90)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A8A90[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A8A90[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80186188[]; - extern u8 D_80186174[]; - extern u8 D_8018619C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80186188; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80186174; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018619C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80167714); - - -extern void (*D_80186254[])(void); - -void func_801678B4(void *a0) { - D_80186254[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80186260[])(void); - -void func_80167A9C(void *a0) { - D_80186260[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018636C; - extern u8 D_80186380[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018636C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80186380; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801861C0[]; -extern u8 D_801861D4[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801861C0; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801861D4; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80186278[])(void); - -void func_80168744(void *a0) { - D_80186278[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80186268 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80186268[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80186268; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80186280[])(void); - -void func_801689D8(void *a0) { - D_80186280[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80186288[])(void); - -void func_80168AA8(void *a0) { - D_80186288[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80186290[])(void); - -void func_80168D58(void *a0) { - D_80186290[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80186298[])(void); - -void func_8016901C(void *a0) { - D_80186298[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015AE2C", func_80169228); - - -extern void (*D_801862A0[])(void); - -void func_801693CC(void *a0) { - D_801862A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801862A8[])(void); - -void func_80169830(void *a0) { - D_801862A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018635C[])(void); - -void func_80169B80(void *a0) { - D_8018635C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801862B0[]; - extern u8 D_80186320[]; - extern u8 D_80186350[]; - extern u8 D_801AAF10[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80186350, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801862B0[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801AAF10; - RotMatrixYXZ(rot, D_801AAF10); - func_80048D9C(D_801AAF10, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80186320); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80186364[])(void); - -void func_80169F00(void *a0) { - D_80186364[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80186314[]; -extern char D_801862D4[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80186314, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801862D4); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018639C[])(void); - -void func_8016A020(void *a0) { - D_8018639C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018636C; - extern u8 D_80186380[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018636C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80186380; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801863A8[])(void); - -void func_8016A700(void *a0) { - D_801863A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801863F0[])(void); - -void func_8016AB30(void *a0) { - D_801863F0[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c b/src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c new file mode 100644 index 000000000..2d3c24740 --- /dev/null +++ b/src/ov_SC04_000/ov_SC04_000_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801857BC; +extern u8 D_8018572C; +extern u8 D_80185708; +extern u8 D_801856E4; +extern u8 D_80185798; +extern u8 D_80185774; +extern u8 D_80185750; +extern u8 D_801856C0; +extern void func_80145934(void); +extern u8 D_8018584C; +extern u8 D_80185828; +extern u8 D_80185804; +extern u8 D_801857E0; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80184C44[]; +extern unsigned char D_80184C74[]; +extern unsigned char D_80184CC4[]; +extern unsigned char D_80184CF4[]; +extern unsigned char D_80184D24[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80184D74[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80184E3C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80184EC4[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80184ECC; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A88C0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A88C4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80184EFC; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80184FA4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80184FC8[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80184FB8; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80184FDC[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80184FE8[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80184FF8[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80185010[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80185000; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80185024[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80185040[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80185030; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80185054[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80185068[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018507C; +extern void (*D_801850A4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80185084; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801850F0[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801850F4[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80185558[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80185568[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A88F8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80185590[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80185570; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80185580; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801855D0[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801855D8[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801855A4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801855E4[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801855B4; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A8900; +extern s32 D_801A890C; +extern s32 D_801A8910; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80185620[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801855F4[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A8908; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80185870[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80185690[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80185914[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80185A68[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80185884; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80185A70[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80185894; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801858B4; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80185A78[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80185AA0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80185920[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80185920[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80185920[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80185920[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80185920[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80185920[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80185920[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80185920[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80185AAC[])(void); + +void func_8015C714(void *a0) { + D_80185AAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80185920[])(void*); + extern int D_801858C4; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80185920)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80185920)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801858C4); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80185920[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80185920[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80185920[])(void*); + extern int D_801858C4; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80185920)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801858C4); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80185920)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80185ABC[])(void); + D_80185ABC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80185920[])(struct Ent_8015CD20 *); + extern u8 D_801858D4; + extern u8 D_80185AC4; + extern u8 D_80185AD4; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80185920[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801858D4); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185AC4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185AD4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80185920[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80185AF4[])(void); + D_80185AF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80185AE4; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80185AE4 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80185920[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80185B50; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80185B50, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80184C34[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80184C34; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80185B58[])(void); + D_80185B58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80185B64[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80185B64[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80185B64[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80185B64[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80185920[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80185B64[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801858E4[]; + extern u8 D_801858F4[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801858E4); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801858F4); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80185B64[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185B64[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185B64[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80185B98[])(void); + D_80185B98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185920[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80185BA0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80185BB8[])(void); + D_80185BB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185920[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80185BA0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80185BA0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80185BD8[])(void); + D_80185BD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80185920[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185920)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80185BE8; +extern u16 D_80185BEA; +extern u16 D_80185BEC; +extern s32 D_80185BF0; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80185BE8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80185BEA + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80185BEC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185BF0, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80185BF8; + +void func_8015E588(void) { + func_8013C9C4(&D_80185BF8); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80185920[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185920)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80185C0C[])(void); + D_80185C0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80185920[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80185920[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80185C14[])(void); + D_80185C14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80185904; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185904); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80185920[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80185C1C[])(void); + D_80185C1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80185920[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80185920[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80185C24[])(void); + D_80185C24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80185920[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80185C2C; + extern s32 D_80185C3C; + extern s32 D_80185C4C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80185920[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185C2C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185C3C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80185920[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185C4C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80185C5C[])(void); + D_80185C5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80185920[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80185920[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80185920[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185920[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80185C68[])(void); + D_80185C68[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80185920[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185920[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80185920[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185920[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80185C7C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80185C7C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80185920[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80185920)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80185920[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185920[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80185CF8[])(void); + D_80185CF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80185920[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80185920)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80185D08[])(void); + D_80185D08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80185920[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80185920[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80185920[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80185920[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80185920[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80185920[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80185920[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80185D10[])(void); + D_80185D10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80185920[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80185920)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80185920[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80185920)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80185D1C[])(void); + D_80185D1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185920 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80185920[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80185920[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80185920[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80185D2C[])(void); + +void func_80160EA4(void *a0) { + D_80185D2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80185920[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80185920[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80185D5C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80185D5C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80185DC0; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80185DC0); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A8918[]; + extern u8 D_80185D8C[]; + extern u8 D_80185DAC[]; + extern u8 D_801A8924[]; + extern u8 D_801A894C[]; + extern u8 D_801A8964[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A8918[0] = p; + func_80024054(&D_80185D8C, &D_801A8924); + func_8001CE28(p, &D_801A8924); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A8918[1] = p; + func_80024054(&D_80185DAC, &D_801A894C); + func_8001CE28(p, &D_801A894C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A8918[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A8964, 0x84); + func_8001CE68(p, &D_801A8964); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A8964, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A8918[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A8918; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80185DC0; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80185DC0; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80185DC0; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80185DC0; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A8918[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A8918; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80185DE4[])(void); + +void func_80162330(void *a0) { + D_80185DE4[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A8970[i] via `extern int D_801A8970[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80185DF0[]; + extern s32 D_80185E08; + extern u8 D_801A897C[]; + extern u8 D_801A89A4[]; + extern u8 D_801A89C0[]; + extern int D_801A8970[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A8970[0] = (s32)item; + func_80024054(D_80185DF0, D_801A897C); + func_8001CE28(item, D_801A897C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A8970[1] = (s32)item; + func_80024054(((u8 *)&D_80185E08), D_801A89A4); + func_8001CE28(item, D_801A89A4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A8970[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A89C0, 0x84); + func_8001CE68(item, D_801A89C0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A89C0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A8970[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A8970; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_801627E8); + + +extern void (*D_80185E2C[])(void); + +void func_80162834(void *a0) { + D_80185E2C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80185E1C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80185E1C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801A8194[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801A8194, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801A8194[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801A8194, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80185E34[])(void); + +void func_80163A58(void *a0) { + D_80185E34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801A819C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801A819C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80185E88[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80185E88[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80185E50; +extern s16 D_80185E84; +extern s16 D_80185E82; +extern s16 D_80185E80; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80185E50; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80185E84 = 0x80; + D_80185E82 = 0x80; + D_80185E80 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80185E84 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80185E84` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80185E84 - 8; + D_80185E84 = nv; + D_80185E82 = nv; + D_80185E80 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80185E94[])(void); + +void func_80164BA0(void *a0) { + D_80185E94[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A89D0; +extern u8 D_801A89D1; +extern u8 D_801A89D2; +extern u8 D_801A89D3; +extern u8 D_801A89D4; +extern u8 D_801A89D5; +extern u8 D_801A89D6; +extern u8 D_801A89D7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A89D0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A89D1 = 0xf0; + *(u8 *)base = 0xf0; + D_801A89D2 = 0xc0; + D_801A89D6 = 0; + D_801A89D5 = 0; + D_801A89D4 = 0; + D_801A89D7 = 0; + D_801A89D3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A89D0; +extern u8 D_801A89D1; +extern u8 D_801A89D2; + +s32 func_80164E40(void) { + u8 *p = &D_801A89D0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A89D1 != 0) { + D_801A89D1 -= 0x10; + } + if (D_801A89D2 != 0) { + D_801A89D2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80185EA4[])(void); + +void func_80164EA4(void *a0) { + D_80185EA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A8A1C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A8A1C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A8A10[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A8A10[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A8A10[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A8A10; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A8A10; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80185EB8[]; + extern u32 D_80185ED8, D_80185EDC, D_80185EE0, D_80185EE4; + extern u32 D_80185ED8, D_80185EDC, D_80185EE0, D_80185EE4; + extern u32 D_80185ED8, D_80185EDC, D_80185EE0, D_80185EE4; + extern u32 D_80185ED8, D_80185EDC, D_80185EE0, D_80185EE4; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80185EB8[0x00], p); + ApplyMatrixSV(mat, &D_80185EB8[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80185EB8[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80185EB8[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80185EE0; + *(u32 *)(prim + 0x24) = D_80185ED8; + *(u32 *)(prim + 0x28) = D_80185EE4; + *(u32 *)(prim + 0x2c) = D_80185EDC; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80185EE8[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80185EE8[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80185EE8[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80185EE8[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80185F64[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80185F64[a1 & 0x7F]; +} + + + +extern s32 D_80185F84[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80185F84[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80186000[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80186000[a1 & 0x7F]; +} + + + +extern u8 D_80186020[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80186020[a1 & 0x7F]; +} + + + +extern u8 D_80186040[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80186040[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80186060[])(void); + D_80186060[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801860DC[])(void); + +void func_80165AC8(void) { + D_801860DC[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80186158[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80186158[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801A81A4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801A81A4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80186164[])(void); + +void func_80166018(void *a0) { + D_80186164[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018616C[])(void); + +void func_801663FC(void *a0) { + D_8018616C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80186234[])(void); + +void func_80166618(void *a0) { + D_80186234[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80186244[])(void); + +void func_80166654(void *a0) { + D_80186244[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A8A90[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A8A90[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A8A90). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A8A90[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A8A90)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A8A90[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A8A90[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80186188[]; + extern u8 D_80186174[]; + extern u8 D_8018619C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80186188; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80186174; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018619C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80167714); + + +extern void (*D_80186254[])(void); + +void func_801678B4(void *a0) { + D_80186254[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80186260[])(void); + +void func_80167A9C(void *a0) { + D_80186260[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018636C; + extern u8 D_80186380[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018636C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80186380; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801861C0[]; +extern u8 D_801861D4[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801861C0; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801861D4; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80186278[])(void); + +void func_80168744(void *a0) { + D_80186278[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80186268 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80186268[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80186268; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80186280[])(void); + +void func_801689D8(void *a0) { + D_80186280[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80186288[])(void); + +void func_80168AA8(void *a0) { + D_80186288[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80186290[])(void); + +void func_80168D58(void *a0) { + D_80186290[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80186298[])(void); + +void func_8016901C(void *a0) { + D_80186298[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_000/nonmatchings/ov_SC04_000_jr_8015C32C", func_80169228); + + +extern void (*D_801862A0[])(void); + +void func_801693CC(void *a0) { + D_801862A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801862A8[])(void); + +void func_80169830(void *a0) { + D_801862A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018635C[])(void); + +void func_80169B80(void *a0) { + D_8018635C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801862B0[]; + extern u8 D_80186320[]; + extern u8 D_80186350[]; + extern u8 D_801AAF10[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80186350, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801862B0[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801AAF10; + RotMatrixYXZ(rot, D_801AAF10); + func_80048D9C(D_801AAF10, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80186320); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80186364[])(void); + +void func_80169F00(void *a0) { + D_80186364[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80186314[]; +extern char D_801862D4[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80186314, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801862D4); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018639C[])(void); + +void func_8016A020(void *a0) { + D_8018639C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018636C; + extern u8 D_80186380[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018636C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80186380; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801863A8[])(void); + +void func_8016A700(void *a0) { + D_801863A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801863F0[])(void); + +void func_8016AB30(void *a0) { + D_801863F0[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_002/ov_SC04_002_jr_8015AE2C.c b/src/ov_SC04_002/ov_SC04_002_jr_8015AE2C.c index fcfbc5b0f..e3c734868 100644 --- a/src/ov_SC04_002/ov_SC04_002_jr_8015AE2C.c +++ b/src/ov_SC04_002/ov_SC04_002_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018AC18[])(void); - -void func_8015C714(void *a0) { - D_8018AC18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018AA8C[])(void*); - extern int D_8018AA30; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018AA30); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018AA8C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018AA8C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018AA8C[])(void*); - extern int D_8018AA30; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018AA30); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018AC28[])(void); - D_8018AC28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018AA8C[])(struct Ent_8015CD20 *); - extern u8 D_8018AA40; - extern u8 D_8018AC30; - extern u8 D_8018AC40; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018AA8C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AA40); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AC30); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AC40); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018AA8C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018AC60[])(void); - D_8018AC60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018AC50; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018AC50 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018AA8C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018ACBC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018ACBC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80189DA0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80189DA0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018ACC4[])(void); - D_8018ACC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018ACD0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018ACD0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018ACD0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018ACD0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018AA8C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018ACD0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018AA50[]; - extern u8 D_8018AA60[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018AA50); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018AA60); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018ACD0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018ACD0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018ACD0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018AD04[])(void); - D_8018AD04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018AA8C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018AD0C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018AD24[])(void); - D_8018AD24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018AA8C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018AD0C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018AD44[])(void); - D_8018AD44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018AA8C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018AA8C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018AD54; -extern u16 D_8018AD56; -extern u16 D_8018AD58; -extern s32 D_8018AD5C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018AD54 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018AD56 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018AD58 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018AD5C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018AD64; - -void func_8015E588(void) { - func_8013C9C4(&D_8018AD64); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018AA8C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018AA8C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018AD78[])(void); - D_8018AD78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018AA8C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018AA8C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018AD80[])(void); - D_8018AD80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018AA70; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018AA70); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018AA8C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018AD88[])(void); - D_8018AD88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018AA8C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018AA8C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018AD90[])(void); - D_8018AD90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018AA8C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018AD98; - extern s32 D_8018ADA8; - extern s32 D_8018ADB8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018AA8C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018AD98); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018ADA8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018AA8C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018ADB8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018ADC8[])(void); - D_8018ADC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018AA8C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018AA8C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018AA8C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018AA8C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018ADD4[])(void); - D_8018ADD4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018AA8C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018AA8C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018AA8C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018AA8C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018ADE8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018ADE8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018AA8C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018AA8C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018AA8C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018AA8C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018AE64[])(void); - D_8018AE64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018AA8C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018AA8C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018AE74[])(void); - D_8018AE74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018AA8C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018AA8C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018AA8C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018AA8C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018AA8C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018AA8C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018AA8C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018AE7C[])(void); - D_8018AE7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018AA8C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018AA8C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018AA8C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018AE88[])(void); - D_8018AE88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018AA8C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018AA8C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018AA8C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018AA8C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018AE98[])(void); - -void func_80160EA4(void *a0) { - D_8018AE98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018AA8C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018AA8C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018AEC8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018AEC8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018AF2C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018AF2C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801BFC28[]; - extern u8 D_8018AEF8[]; - extern u8 D_8018AF18[]; - extern u8 D_801BFC34[]; - extern u8 D_801BFC5C[]; - extern u8 D_801BFC74[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801BFC28[0] = p; - func_80024054(&D_8018AEF8, &D_801BFC34); - func_8001CE28(p, &D_801BFC34); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801BFC28[1] = p; - func_80024054(&D_8018AF18, &D_801BFC5C); - func_8001CE28(p, &D_801BFC5C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801BFC28[2] = p; - func_800242D0((s16)func_801620C4(), &D_801BFC74, 0x84); - func_8001CE68(p, &D_801BFC74); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801BFC74, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BFC28[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801BFC28; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018AF2C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018AF2C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018AF2C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018AF2C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801BFC28[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801BFC28; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018AF50[])(void); - -void func_80162330(void *a0) { - D_8018AF50[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801BFC80[i] via `extern int D_801BFC80[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018AF5C[]; - extern s32 D_8018AF74; - extern u8 D_801BFC8C[]; - extern u8 D_801BFCB4[]; - extern u8 D_801BFCD0[]; - extern int D_801BFC80[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801BFC80[0] = (s32)item; - func_80024054(D_8018AF5C, D_801BFC8C); - func_8001CE28(item, D_801BFC8C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801BFC80[1] = (s32)item; - func_80024054(((u8 *)&D_8018AF74), D_801BFCB4); - func_8001CE28(item, D_801BFCB4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801BFC80[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801BFCD0, 0x84); - func_8001CE68(item, D_801BFCD0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801BFCD0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BFC80[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801BFC80; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018AF98[])(void); - -void func_80162834(void *a0) { - D_8018AF98[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018AF88; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018AF88, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801BF4E4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801BF4E4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801BF4E4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801BF4E4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018AFA0[])(void); - -void func_80163A58(void *a0) { - D_8018AFA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801BF4EC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801BF4EC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018AFF4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018AFF4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018AFBC; -extern s16 D_8018AFF0; -extern s16 D_8018AFEE; -extern s16 D_8018AFEC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018AFBC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018AFF0 = 0x80; - D_8018AFEE = 0x80; - D_8018AFEC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018AFF0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018AFF0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018AFF0 - 8; - D_8018AFF0 = nv; - D_8018AFEE = nv; - D_8018AFEC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018B000[])(void); - -void func_80164BA0(void *a0) { - D_8018B000[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801BFCE0; -extern u8 D_801BFCE1; -extern u8 D_801BFCE2; -extern u8 D_801BFCE3; -extern u8 D_801BFCE4; -extern u8 D_801BFCE5; -extern u8 D_801BFCE6; -extern u8 D_801BFCE7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801BFCE0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801BFCE1 = 0xf0; - *(u8 *)base = 0xf0; - D_801BFCE2 = 0xc0; - D_801BFCE6 = 0; - D_801BFCE5 = 0; - D_801BFCE4 = 0; - D_801BFCE7 = 0; - D_801BFCE3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801BFCE0; -extern u8 D_801BFCE1; -extern u8 D_801BFCE2; - -s32 func_80164E40(void) { - u8 *p = &D_801BFCE0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801BFCE1 != 0) { - D_801BFCE1 -= 0x10; - } - if (D_801BFCE2 != 0) { - D_801BFCE2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018B010[])(void); - -void func_80164EA4(void *a0) { - D_8018B010[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801BFD2C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801BFD2C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801BFD20[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801BFD20[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801BFD20[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801BFD20; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801BFD20; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018B024[]; - extern u32 D_8018B044, D_8018B048, D_8018B04C, D_8018B050; - extern u32 D_8018B044, D_8018B048, D_8018B04C, D_8018B050; - extern u32 D_8018B044, D_8018B048, D_8018B04C, D_8018B050; - extern u32 D_8018B044, D_8018B048, D_8018B04C, D_8018B050; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018B024[0x00], p); - ApplyMatrixSV(mat, &D_8018B024[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018B024[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018B024[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018B04C; - *(u32 *)(prim + 0x24) = D_8018B044; - *(u32 *)(prim + 0x28) = D_8018B050; - *(u32 *)(prim + 0x2c) = D_8018B048; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018B054[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018B054[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018B054[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018B054[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018B0D0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018B0D0[a1 & 0x7F]; -} - - - -extern s32 D_8018B0F0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018B0F0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018B16C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018B16C[a1 & 0x7F]; -} - - - -extern u8 D_8018B18C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018B18C[a1 & 0x7F]; -} - - - -extern u8 D_8018B1AC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018B1AC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018B1CC[])(void); - D_8018B1CC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018B248[])(void); - -void func_80165AC8(void) { - D_8018B248[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018B2C4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018B2C4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801BF4F4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801BF4F4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018B2D0[])(void); - -void func_80166018(void *a0) { - D_8018B2D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018B2D8[])(void); - -void func_801663FC(void *a0) { - D_8018B2D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018B3A0[])(void); - -void func_80166618(void *a0) { - D_8018B3A0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018B3B0[])(void); - -void func_80166654(void *a0) { - D_8018B3B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801BFDA0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801BFDA0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BFDA0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801BFDA0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801BFDA0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801BFDA0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801BFDA0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018B2F4[]; - extern u8 D_8018B2E0[]; - extern u8 D_8018B308[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018B2F4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018B2E0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018B308; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80167714); - - -extern void (*D_8018B3C0[])(void); - -void func_801678B4(void *a0) { - D_8018B3C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018B3CC[])(void); - -void func_80167A9C(void *a0) { - D_8018B3CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018B4D8; - extern u8 D_8018B4EC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018B4D8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018B4EC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018B32C[]; -extern u8 D_8018B340[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018B32C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018B340; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018B3E4[])(void); - -void func_80168744(void *a0) { - D_8018B3E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018B3D4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018B3D4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018B3D4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018B3EC[])(void); - -void func_801689D8(void *a0) { - D_8018B3EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018B3F4[])(void); - -void func_80168AA8(void *a0) { - D_8018B3F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018B3FC[])(void); - -void func_80168D58(void *a0) { - D_8018B3FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018B404[])(void); - -void func_8016901C(void *a0) { - D_8018B404[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015AE2C", func_80169228); - - -extern void (*D_8018B40C[])(void); - -void func_801693CC(void *a0) { - D_8018B40C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018B414[])(void); - -void func_80169830(void *a0) { - D_8018B414[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018B4C8[])(void); - -void func_80169B80(void *a0) { - D_8018B4C8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018B41C[]; - extern u8 D_8018B48C[]; - extern u8 D_8018B4BC[]; - extern u8 D_801C15E8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018B4BC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018B41C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C15E8; - RotMatrixYXZ(rot, D_801C15E8); - func_80048D9C(D_801C15E8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018B48C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018B4D0[])(void); - -void func_80169F00(void *a0) { - D_8018B4D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018B480[]; -extern char D_8018B440[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018B480, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018B440); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018B508[])(void); - -void func_8016A020(void *a0) { - D_8018B508[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018B4D8; - extern u8 D_8018B4EC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018B4D8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018B4EC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018B514[])(void); - -void func_8016A700(void *a0) { - D_8018B514[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018B55C[])(void); - -void func_8016AB30(void *a0) { - D_8018B55C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c b/src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c new file mode 100644 index 000000000..3cdf07cf0 --- /dev/null +++ b/src/ov_SC04_002/ov_SC04_002_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018A928; +extern u8 D_8018A898; +extern u8 D_8018A874; +extern u8 D_8018A850; +extern u8 D_8018A904; +extern u8 D_8018A8E0; +extern u8 D_8018A8BC; +extern u8 D_8018A82C; +extern void func_80145934(void); +extern u8 D_8018A9B8; +extern u8 D_8018A994; +extern u8 D_8018A970; +extern u8 D_8018A94C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80189DB0[]; +extern unsigned char D_80189DE0[]; +extern unsigned char D_80189E30[]; +extern unsigned char D_80189E60[]; +extern unsigned char D_80189E90[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80189EE0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80189FA8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018A030[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018A038; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801BFBD0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801BFBD4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018A068; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018A110[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018A134[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018A124; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018A148[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018A154[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018A164[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018A17C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018A16C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018A190[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018A1AC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018A19C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018A1C0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018A1D4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018A1E8; +extern void (*D_8018A210[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018A1F0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018A25C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018A260[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018A6C4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018A6D4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801BFC08; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018A6FC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018A6DC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018A6EC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018A73C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018A744[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018A710; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018A750[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018A720; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801BFC10; +extern s32 D_801BFC1C; +extern s32 D_801BFC20; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018A78C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018A760[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801BFC18; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018A9DC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018A7FC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018AA80[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018ABD4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018A9F0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018ABDC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018AA00; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018AA20; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018ABE4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018AC0C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018AA8C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018AC18[])(void); + +void func_8015C714(void *a0) { + D_8018AC18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018AA8C[])(void*); + extern int D_8018AA30; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018AA30); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018AA8C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018AA8C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018AA8C[])(void*); + extern int D_8018AA30; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018AA30); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018AC28[])(void); + D_8018AC28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018AA8C[])(struct Ent_8015CD20 *); + extern u8 D_8018AA40; + extern u8 D_8018AC30; + extern u8 D_8018AC40; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018AA8C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AA40); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AC30); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AC40); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018AA8C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018AC60[])(void); + D_8018AC60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018AC50; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018AC50 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018AA8C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018ACBC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018ACBC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80189DA0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80189DA0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018ACC4[])(void); + D_8018ACC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018ACD0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018ACD0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018ACD0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018ACD0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018AA8C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018ACD0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018AA50[]; + extern u8 D_8018AA60[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018AA50); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018AA60); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018ACD0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018ACD0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018ACD0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018AD04[])(void); + D_8018AD04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018AA8C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018AD0C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018AD24[])(void); + D_8018AD24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018AA8C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018AD0C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018AD0C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018AD44[])(void); + D_8018AD44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018AA8C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018AA8C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018AD54; +extern u16 D_8018AD56; +extern u16 D_8018AD58; +extern s32 D_8018AD5C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018AD54 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018AD56 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018AD58 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018AD5C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018AD64; + +void func_8015E588(void) { + func_8013C9C4(&D_8018AD64); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018AA8C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018AA8C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018AD78[])(void); + D_8018AD78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018AA8C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018AA8C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018AD80[])(void); + D_8018AD80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018AA70; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018AA70); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018AA8C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018AD88[])(void); + D_8018AD88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018AA8C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018AA8C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018AD90[])(void); + D_8018AD90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018AA8C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018AD98; + extern s32 D_8018ADA8; + extern s32 D_8018ADB8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018AD98); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018ADA8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018AA8C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018ADB8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018ADC8[])(void); + D_8018ADC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018AA8C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018AA8C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018AA8C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018AA8C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018ADD4[])(void); + D_8018ADD4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018AA8C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018AA8C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018AA8C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018AA8C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018ADE8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018ADE8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018AA8C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018AA8C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018AA8C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018AA8C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018AE64[])(void); + D_8018AE64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018AA8C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018AA8C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018AE74[])(void); + D_8018AE74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018AA8C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018AA8C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018AA8C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018AA8C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018AA8C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018AA8C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018AA8C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018AE7C[])(void); + D_8018AE7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018AA8C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018AA8C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018AA8C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018AA8C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018AE88[])(void); + D_8018AE88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018AA8C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018AA8C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018AA8C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018AA8C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018AE98[])(void); + +void func_80160EA4(void *a0) { + D_8018AE98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018AA8C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018AA8C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018AEC8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018AEC8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018AF2C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018AF2C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801BFC28[]; + extern u8 D_8018AEF8[]; + extern u8 D_8018AF18[]; + extern u8 D_801BFC34[]; + extern u8 D_801BFC5C[]; + extern u8 D_801BFC74[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801BFC28[0] = p; + func_80024054(&D_8018AEF8, &D_801BFC34); + func_8001CE28(p, &D_801BFC34); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801BFC28[1] = p; + func_80024054(&D_8018AF18, &D_801BFC5C); + func_8001CE28(p, &D_801BFC5C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801BFC28[2] = p; + func_800242D0((s16)func_801620C4(), &D_801BFC74, 0x84); + func_8001CE68(p, &D_801BFC74); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801BFC74, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BFC28[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801BFC28; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018AF2C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018AF2C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018AF2C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018AF2C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801BFC28[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801BFC28; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018AF50[])(void); + +void func_80162330(void *a0) { + D_8018AF50[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801BFC80[i] via `extern int D_801BFC80[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018AF5C[]; + extern s32 D_8018AF74; + extern u8 D_801BFC8C[]; + extern u8 D_801BFCB4[]; + extern u8 D_801BFCD0[]; + extern int D_801BFC80[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801BFC80[0] = (s32)item; + func_80024054(D_8018AF5C, D_801BFC8C); + func_8001CE28(item, D_801BFC8C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801BFC80[1] = (s32)item; + func_80024054(((u8 *)&D_8018AF74), D_801BFCB4); + func_8001CE28(item, D_801BFCB4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801BFC80[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801BFCD0, 0x84); + func_8001CE68(item, D_801BFCD0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801BFCD0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BFC80[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801BFC80; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_801627E8); + + +extern void (*D_8018AF98[])(void); + +void func_80162834(void *a0) { + D_8018AF98[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018AF88; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018AF88, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801BF4E4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801BF4E4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801BF4E4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801BF4E4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018AFA0[])(void); + +void func_80163A58(void *a0) { + D_8018AFA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801BF4EC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801BF4EC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018AFF4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018AFF4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018AFBC; +extern s16 D_8018AFF0; +extern s16 D_8018AFEE; +extern s16 D_8018AFEC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018AFBC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018AFF0 = 0x80; + D_8018AFEE = 0x80; + D_8018AFEC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018AFF0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018AFF0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018AFF0 - 8; + D_8018AFF0 = nv; + D_8018AFEE = nv; + D_8018AFEC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018B000[])(void); + +void func_80164BA0(void *a0) { + D_8018B000[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801BFCE0; +extern u8 D_801BFCE1; +extern u8 D_801BFCE2; +extern u8 D_801BFCE3; +extern u8 D_801BFCE4; +extern u8 D_801BFCE5; +extern u8 D_801BFCE6; +extern u8 D_801BFCE7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801BFCE0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801BFCE1 = 0xf0; + *(u8 *)base = 0xf0; + D_801BFCE2 = 0xc0; + D_801BFCE6 = 0; + D_801BFCE5 = 0; + D_801BFCE4 = 0; + D_801BFCE7 = 0; + D_801BFCE3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801BFCE0; +extern u8 D_801BFCE1; +extern u8 D_801BFCE2; + +s32 func_80164E40(void) { + u8 *p = &D_801BFCE0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801BFCE1 != 0) { + D_801BFCE1 -= 0x10; + } + if (D_801BFCE2 != 0) { + D_801BFCE2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018B010[])(void); + +void func_80164EA4(void *a0) { + D_8018B010[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801BFD2C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801BFD2C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801BFD20[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801BFD20[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801BFD20[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801BFD20; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801BFD20; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018B024[]; + extern u32 D_8018B044, D_8018B048, D_8018B04C, D_8018B050; + extern u32 D_8018B044, D_8018B048, D_8018B04C, D_8018B050; + extern u32 D_8018B044, D_8018B048, D_8018B04C, D_8018B050; + extern u32 D_8018B044, D_8018B048, D_8018B04C, D_8018B050; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018B024[0x00], p); + ApplyMatrixSV(mat, &D_8018B024[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018B024[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018B024[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018B04C; + *(u32 *)(prim + 0x24) = D_8018B044; + *(u32 *)(prim + 0x28) = D_8018B050; + *(u32 *)(prim + 0x2c) = D_8018B048; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018B054[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018B054[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018B054[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018B054[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018B0D0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018B0D0[a1 & 0x7F]; +} + + + +extern s32 D_8018B0F0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018B0F0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018B16C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018B16C[a1 & 0x7F]; +} + + + +extern u8 D_8018B18C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018B18C[a1 & 0x7F]; +} + + + +extern u8 D_8018B1AC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018B1AC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018B1CC[])(void); + D_8018B1CC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018B248[])(void); + +void func_80165AC8(void) { + D_8018B248[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018B2C4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018B2C4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801BF4F4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801BF4F4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018B2D0[])(void); + +void func_80166018(void *a0) { + D_8018B2D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018B2D8[])(void); + +void func_801663FC(void *a0) { + D_8018B2D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018B3A0[])(void); + +void func_80166618(void *a0) { + D_8018B3A0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018B3B0[])(void); + +void func_80166654(void *a0) { + D_8018B3B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801BFDA0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801BFDA0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BFDA0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801BFDA0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801BFDA0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801BFDA0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801BFDA0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018B2F4[]; + extern u8 D_8018B2E0[]; + extern u8 D_8018B308[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018B2F4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018B2E0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018B308; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80167714); + + +extern void (*D_8018B3C0[])(void); + +void func_801678B4(void *a0) { + D_8018B3C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018B3CC[])(void); + +void func_80167A9C(void *a0) { + D_8018B3CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018B4D8; + extern u8 D_8018B4EC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018B4D8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018B4EC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018B32C[]; +extern u8 D_8018B340[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018B32C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018B340; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018B3E4[])(void); + +void func_80168744(void *a0) { + D_8018B3E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018B3D4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018B3D4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018B3D4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018B3EC[])(void); + +void func_801689D8(void *a0) { + D_8018B3EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018B3F4[])(void); + +void func_80168AA8(void *a0) { + D_8018B3F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018B3FC[])(void); + +void func_80168D58(void *a0) { + D_8018B3FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018B404[])(void); + +void func_8016901C(void *a0) { + D_8018B404[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_002/nonmatchings/ov_SC04_002_jr_8015C32C", func_80169228); + + +extern void (*D_8018B40C[])(void); + +void func_801693CC(void *a0) { + D_8018B40C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018B414[])(void); + +void func_80169830(void *a0) { + D_8018B414[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018B4C8[])(void); + +void func_80169B80(void *a0) { + D_8018B4C8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018B41C[]; + extern u8 D_8018B48C[]; + extern u8 D_8018B4BC[]; + extern u8 D_801C15E8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018B4BC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018B41C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C15E8; + RotMatrixYXZ(rot, D_801C15E8); + func_80048D9C(D_801C15E8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018B48C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018B4D0[])(void); + +void func_80169F00(void *a0) { + D_8018B4D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018B480[]; +extern char D_8018B440[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018B480, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018B440); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018B508[])(void); + +void func_8016A020(void *a0) { + D_8018B508[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018B4D8; + extern u8 D_8018B4EC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018B4D8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018B4EC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018B514[])(void); + +void func_8016A700(void *a0) { + D_8018B514[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018B55C[])(void); + +void func_8016AB30(void *a0) { + D_8018B55C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_003/ov_SC04_003_jr_8015AE2C.c b/src/ov_SC04_003/ov_SC04_003_jr_8015AE2C.c index 53fed1588..12920efb6 100644 --- a/src/ov_SC04_003/ov_SC04_003_jr_8015AE2C.c +++ b/src/ov_SC04_003/ov_SC04_003_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801849B4[])(void); - -void func_8015C714(void *a0) { - D_801849B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80184828[])(void*); - extern int D_801847CC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80184828)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80184828)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801847CC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80184828[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80184828[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80184828[])(void*); - extern int D_801847CC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80184828)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801847CC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80184828)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801849C4[])(void); - D_801849C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80184828[])(struct Ent_8015CD20 *); - extern u8 D_801847DC; - extern u8 D_801849CC; - extern u8 D_801849DC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80184828[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801847DC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849CC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849DC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80184828[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801849FC[])(void); - D_801849FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801849EC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801849EC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80184828[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80184A58; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80184A58, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80183B3C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80183B3C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80184A60[])(void); - D_80184A60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80184A6C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80184A6C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80184A6C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80184A6C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80184828[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80184A6C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801847EC[]; - extern u8 D_801847FC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801847EC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801847FC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80184A6C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184A6C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184A6C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80184AA0[])(void); - D_80184AA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184828[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184AA8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80184AC0[])(void); - D_80184AC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184828[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184AA8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80184AE0[])(void); - D_80184AE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80184828[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184828)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80184AF0; -extern u16 D_80184AF2; -extern u16 D_80184AF4; -extern s32 D_80184AF8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80184AF0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80184AF2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80184AF4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184AF8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80184B00; - -void func_8015E588(void) { - func_8013C9C4(&D_80184B00); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80184828[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184828)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80184B14[])(void); - D_80184B14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80184828[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80184828[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80184B1C[])(void); - D_80184B1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018480C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018480C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80184828[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80184B24[])(void); - D_80184B24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80184828[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80184828[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80184B2C[])(void); - D_80184B2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80184828[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80184B34; - extern s32 D_80184B44; - extern s32 D_80184B54; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80184828[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B34); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B44); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80184828[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B54); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184B64[])(void); - D_80184B64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80184828[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80184828[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80184828[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184828[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184B70[])(void); - D_80184B70[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80184828[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184828[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80184828[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184828[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80184B84[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80184B84[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80184828[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80184828)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80184828[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184828[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80184C00[])(void); - D_80184C00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80184828[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80184828)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80184C10[])(void); - D_80184C10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80184828[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80184828[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80184828[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80184828[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80184828[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80184828[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80184828[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80184C18[])(void); - D_80184C18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80184828[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80184828)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80184828[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80184828)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80184C24[])(void); - D_80184C24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184828 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80184828[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80184828[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80184828[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80184C34[])(void); - -void func_80160EA4(void *a0) { - D_80184C34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80184828[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80184828[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80184C64[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80184C64[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80184CC8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80184CC8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019A890[]; - extern u8 D_80184C94[]; - extern u8 D_80184CB4[]; - extern u8 D_8019A89C[]; - extern u8 D_8019A8C4[]; - extern u8 D_8019A8DC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019A890[0] = p; - func_80024054(&D_80184C94, &D_8019A89C); - func_8001CE28(p, &D_8019A89C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019A890[1] = p; - func_80024054(&D_80184CB4, &D_8019A8C4); - func_8001CE28(p, &D_8019A8C4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019A890[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019A8DC, 0x84); - func_8001CE68(p, &D_8019A8DC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019A8DC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019A890[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019A890; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80184CC8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80184CC8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80184CC8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80184CC8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019A890[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019A890; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80184CEC[])(void); - -void func_80162330(void *a0) { - D_80184CEC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019A8E8[i] via `extern int D_8019A8E8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80184CF8[]; - extern s32 D_80184D10; - extern u8 D_8019A8F4[]; - extern u8 D_8019A91C[]; - extern u8 D_8019A938[]; - extern int D_8019A8E8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019A8E8[0] = (s32)item; - func_80024054(D_80184CF8, D_8019A8F4); - func_8001CE28(item, D_8019A8F4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019A8E8[1] = (s32)item; - func_80024054(((u8 *)&D_80184D10), D_8019A91C); - func_8001CE28(item, D_8019A91C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019A8E8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019A938, 0x84); - func_8001CE68(item, D_8019A938); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019A938, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019A8E8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019A8E8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_801627E8); - - -extern void (*D_80184D34[])(void); - -void func_80162834(void *a0) { - D_80184D34[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80184D24; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80184D24, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019A160[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019A160, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019A160[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019A160, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80184D3C[])(void); - -void func_80163A58(void *a0) { - D_80184D3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019A168; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019A168; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80184D90[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80184D90[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80184D58; -extern s16 D_80184D8C; -extern s16 D_80184D8A; -extern s16 D_80184D88; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80184D58; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80184D8C = 0x80; - D_80184D8A = 0x80; - D_80184D88 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80184D8C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80184D8C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80184D8C - 8; - D_80184D8C = nv; - D_80184D8A = nv; - D_80184D88 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80184D9C[])(void); - -void func_80164BA0(void *a0) { - D_80184D9C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019A948; -extern u8 D_8019A949; -extern u8 D_8019A94A; -extern u8 D_8019A94B; -extern u8 D_8019A94C; -extern u8 D_8019A94D; -extern u8 D_8019A94E; -extern u8 D_8019A94F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019A948; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019A949 = 0xf0; - *(u8 *)base = 0xf0; - D_8019A94A = 0xc0; - D_8019A94E = 0; - D_8019A94D = 0; - D_8019A94C = 0; - D_8019A94F = 0; - D_8019A94B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019A948; -extern u8 D_8019A949; -extern u8 D_8019A94A; - -s32 func_80164E40(void) { - u8 *p = &D_8019A948; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019A949 != 0) { - D_8019A949 -= 0x10; - } - if (D_8019A94A != 0) { - D_8019A94A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80184DAC[])(void); - -void func_80164EA4(void *a0) { - D_80184DAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019A994[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019A994[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019A988[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019A988[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019A988[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019A988; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019A988; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80184DC0[]; - extern u32 D_80184DE0, D_80184DE4, D_80184DE8, D_80184DEC; - extern u32 D_80184DE0, D_80184DE4, D_80184DE8, D_80184DEC; - extern u32 D_80184DE0, D_80184DE4, D_80184DE8, D_80184DEC; - extern u32 D_80184DE0, D_80184DE4, D_80184DE8, D_80184DEC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80184DC0[0x00], p); - ApplyMatrixSV(mat, &D_80184DC0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80184DC0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80184DC0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80184DE8; - *(u32 *)(prim + 0x24) = D_80184DE0; - *(u32 *)(prim + 0x28) = D_80184DEC; - *(u32 *)(prim + 0x2c) = D_80184DE4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80184DF0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80184DF0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80184DF0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80184DF0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80184E6C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80184E6C[a1 & 0x7F]; -} - - - -extern s32 D_80184E8C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80184E8C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80184F08[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80184F08[a1 & 0x7F]; -} - - - -extern u8 D_80184F28[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80184F28[a1 & 0x7F]; -} - - - -extern u8 D_80184F48[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80184F48[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80184F68[])(void); - D_80184F68[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80184FE4[])(void); - -void func_80165AC8(void) { - D_80184FE4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80185060[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80185060[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019A170; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019A170, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018506C[])(void); - -void func_80166018(void *a0) { - D_8018506C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80185074[])(void); - -void func_801663FC(void *a0) { - D_80185074[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018513C[])(void); - -void func_80166618(void *a0) { - D_8018513C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018514C[])(void); - -void func_80166654(void *a0) { - D_8018514C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019AA08[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019AA08[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019AA08). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019AA08[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019AA08)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019AA08[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019AA08[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80185090[]; - extern u8 D_8018507C[]; - extern u8 D_801850A4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80185090; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018507C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801850A4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80167714); - - -extern void (*D_8018515C[])(void); - -void func_801678B4(void *a0) { - D_8018515C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80185168[])(void); - -void func_80167A9C(void *a0) { - D_80185168[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80185274; - extern u8 D_80185288[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80185274); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185288; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801850C8[]; -extern u8 D_801850DC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801850C8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801850DC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80185180[])(void); - -void func_80168744(void *a0) { - D_80185180[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80185170 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80185170[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80185170; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80185188[])(void); - -void func_801689D8(void *a0) { - D_80185188[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80185190[])(void); - -void func_80168AA8(void *a0) { - D_80185190[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80185198[])(void); - -void func_80168D58(void *a0) { - D_80185198[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801851A0[])(void); - -void func_8016901C(void *a0) { - D_801851A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015AE2C", func_80169228); - - -extern void (*D_801851A8[])(void); - -void func_801693CC(void *a0) { - D_801851A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801851B0[])(void); - -void func_80169830(void *a0) { - D_801851B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80185264[])(void); - -void func_80169B80(void *a0) { - D_80185264[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801851B8[]; - extern u8 D_80185228[]; - extern u8 D_80185258[]; - extern u8 D_8019BAA8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80185258, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801851B8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019BAA8; - RotMatrixYXZ(rot, D_8019BAA8); - func_80048D9C(D_8019BAA8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80185228); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018526C[])(void); - -void func_80169F00(void *a0) { - D_8018526C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018521C[]; -extern char D_801851DC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018521C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801851DC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801852A4[])(void); - -void func_8016A020(void *a0) { - D_801852A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80185274; - extern u8 D_80185288[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80185274); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185288; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801852B0[])(void); - -void func_8016A700(void *a0) { - D_801852B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801852F8[])(void); - -void func_8016AB30(void *a0) { - D_801852F8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c b/src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c new file mode 100644 index 000000000..5f02079e4 --- /dev/null +++ b/src/ov_SC04_003/ov_SC04_003_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801846C4; +extern u8 D_80184634; +extern u8 D_80184610; +extern u8 D_801845EC; +extern u8 D_801846A0; +extern u8 D_8018467C; +extern u8 D_80184658; +extern u8 D_801845C8; +extern void func_80145934(void); +extern u8 D_80184754; +extern u8 D_80184730; +extern u8 D_8018470C; +extern u8 D_801846E8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80183B4C[]; +extern unsigned char D_80183B7C[]; +extern unsigned char D_80183BCC[]; +extern unsigned char D_80183BFC[]; +extern unsigned char D_80183C2C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80183C7C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80183D44[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80183DCC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80183DD4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019A838; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019A83C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80183E04; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80183EAC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80183ED0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80183EC0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80183EE4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80183EF0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80183F00[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80183F18[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80183F08; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80183F2C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80183F48[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80183F38; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80183F5C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80183F70[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80183F84; +extern void (*D_80183FAC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80183F8C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80183FF8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80183FFC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184460[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184470[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019A870; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80184498[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80184478; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80184488; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801844D8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801844E0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801844AC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801844EC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801844BC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019A878; +extern s32 D_8019A884; +extern s32 D_8019A888; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80184528[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801844FC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019A880; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184778[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80184598[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018481C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80184970[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018478C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80184978[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018479C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801847BC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80184980[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801849A8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80184828[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80184828[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80184828[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80184828[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80184828[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80184828[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80184828[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80184828[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801849B4[])(void); + +void func_8015C714(void *a0) { + D_801849B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80184828[])(void*); + extern int D_801847CC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80184828)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80184828)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801847CC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80184828[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80184828[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80184828[])(void*); + extern int D_801847CC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80184828)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801847CC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80184828)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801849C4[])(void); + D_801849C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80184828[])(struct Ent_8015CD20 *); + extern u8 D_801847DC; + extern u8 D_801849CC; + extern u8 D_801849DC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80184828[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801847DC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849CC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801849DC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80184828[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801849FC[])(void); + D_801849FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801849EC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801849EC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80184828[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80184A58; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80184A58, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80183B3C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80183B3C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80184A60[])(void); + D_80184A60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80184A6C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80184A6C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80184A6C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80184A6C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80184828[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80184A6C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801847EC[]; + extern u8 D_801847FC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801847EC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801847FC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80184A6C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184A6C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184A6C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80184AA0[])(void); + D_80184AA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184828[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184AA8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80184AC0[])(void); + D_80184AC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184828[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184AA8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184AA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80184AE0[])(void); + D_80184AE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80184828[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184828)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80184AF0; +extern u16 D_80184AF2; +extern u16 D_80184AF4; +extern s32 D_80184AF8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80184AF0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80184AF2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80184AF4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184AF8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80184B00; + +void func_8015E588(void) { + func_8013C9C4(&D_80184B00); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80184828[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184828)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80184B14[])(void); + D_80184B14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80184828[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80184828[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80184B1C[])(void); + D_80184B1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018480C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018480C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80184828[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80184B24[])(void); + D_80184B24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80184828[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80184828[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80184B2C[])(void); + D_80184B2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80184828[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80184B34; + extern s32 D_80184B44; + extern s32 D_80184B54; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80184828[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B34); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B44); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80184828[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184B54); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184B64[])(void); + D_80184B64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80184828[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80184828[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80184828[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184828[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184B70[])(void); + D_80184B70[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80184828[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184828[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80184828[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184828[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80184B84[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80184B84[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80184828[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80184828)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80184828[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184828[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80184C00[])(void); + D_80184C00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80184828[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80184828)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80184C10[])(void); + D_80184C10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80184828[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80184828[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80184828[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80184828[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80184828[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80184828[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80184828[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80184C18[])(void); + D_80184C18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80184828[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80184828)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80184828[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80184828)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80184C24[])(void); + D_80184C24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184828 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80184828[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80184828[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80184828[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80184C34[])(void); + +void func_80160EA4(void *a0) { + D_80184C34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80184828[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80184828[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80184C64[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80184C64[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80184CC8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80184CC8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019A890[]; + extern u8 D_80184C94[]; + extern u8 D_80184CB4[]; + extern u8 D_8019A89C[]; + extern u8 D_8019A8C4[]; + extern u8 D_8019A8DC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019A890[0] = p; + func_80024054(&D_80184C94, &D_8019A89C); + func_8001CE28(p, &D_8019A89C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019A890[1] = p; + func_80024054(&D_80184CB4, &D_8019A8C4); + func_8001CE28(p, &D_8019A8C4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019A890[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019A8DC, 0x84); + func_8001CE68(p, &D_8019A8DC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019A8DC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019A890[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019A890; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80184CC8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80184CC8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80184CC8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80184CC8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019A890[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019A890; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80184CEC[])(void); + +void func_80162330(void *a0) { + D_80184CEC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019A8E8[i] via `extern int D_8019A8E8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80184CF8[]; + extern s32 D_80184D10; + extern u8 D_8019A8F4[]; + extern u8 D_8019A91C[]; + extern u8 D_8019A938[]; + extern int D_8019A8E8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019A8E8[0] = (s32)item; + func_80024054(D_80184CF8, D_8019A8F4); + func_8001CE28(item, D_8019A8F4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019A8E8[1] = (s32)item; + func_80024054(((u8 *)&D_80184D10), D_8019A91C); + func_8001CE28(item, D_8019A91C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019A8E8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019A938, 0x84); + func_8001CE68(item, D_8019A938); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019A938, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019A8E8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019A8E8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_801627E8); + + +extern void (*D_80184D34[])(void); + +void func_80162834(void *a0) { + D_80184D34[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80184D24; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80184D24, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019A160[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019A160, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019A160[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019A160, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80184D3C[])(void); + +void func_80163A58(void *a0) { + D_80184D3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019A168; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019A168; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80184D90[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80184D90[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80184D58; +extern s16 D_80184D8C; +extern s16 D_80184D8A; +extern s16 D_80184D88; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80184D58; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80184D8C = 0x80; + D_80184D8A = 0x80; + D_80184D88 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80184D8C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80184D8C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80184D8C - 8; + D_80184D8C = nv; + D_80184D8A = nv; + D_80184D88 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80184D9C[])(void); + +void func_80164BA0(void *a0) { + D_80184D9C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019A948; +extern u8 D_8019A949; +extern u8 D_8019A94A; +extern u8 D_8019A94B; +extern u8 D_8019A94C; +extern u8 D_8019A94D; +extern u8 D_8019A94E; +extern u8 D_8019A94F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019A948; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019A949 = 0xf0; + *(u8 *)base = 0xf0; + D_8019A94A = 0xc0; + D_8019A94E = 0; + D_8019A94D = 0; + D_8019A94C = 0; + D_8019A94F = 0; + D_8019A94B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019A948; +extern u8 D_8019A949; +extern u8 D_8019A94A; + +s32 func_80164E40(void) { + u8 *p = &D_8019A948; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019A949 != 0) { + D_8019A949 -= 0x10; + } + if (D_8019A94A != 0) { + D_8019A94A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80184DAC[])(void); + +void func_80164EA4(void *a0) { + D_80184DAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019A994[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019A994[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019A988[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019A988[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019A988[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019A988; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019A988; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80184DC0[]; + extern u32 D_80184DE0, D_80184DE4, D_80184DE8, D_80184DEC; + extern u32 D_80184DE0, D_80184DE4, D_80184DE8, D_80184DEC; + extern u32 D_80184DE0, D_80184DE4, D_80184DE8, D_80184DEC; + extern u32 D_80184DE0, D_80184DE4, D_80184DE8, D_80184DEC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80184DC0[0x00], p); + ApplyMatrixSV(mat, &D_80184DC0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80184DC0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80184DC0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80184DE8; + *(u32 *)(prim + 0x24) = D_80184DE0; + *(u32 *)(prim + 0x28) = D_80184DEC; + *(u32 *)(prim + 0x2c) = D_80184DE4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80184DF0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80184DF0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80184DF0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80184DF0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80184E6C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80184E6C[a1 & 0x7F]; +} + + + +extern s32 D_80184E8C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80184E8C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80184F08[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80184F08[a1 & 0x7F]; +} + + + +extern u8 D_80184F28[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80184F28[a1 & 0x7F]; +} + + + +extern u8 D_80184F48[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80184F48[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80184F68[])(void); + D_80184F68[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80184FE4[])(void); + +void func_80165AC8(void) { + D_80184FE4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80185060[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80185060[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019A170; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019A170, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018506C[])(void); + +void func_80166018(void *a0) { + D_8018506C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80185074[])(void); + +void func_801663FC(void *a0) { + D_80185074[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018513C[])(void); + +void func_80166618(void *a0) { + D_8018513C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018514C[])(void); + +void func_80166654(void *a0) { + D_8018514C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019AA08[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019AA08[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019AA08). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019AA08[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019AA08)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019AA08[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019AA08[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80185090[]; + extern u8 D_8018507C[]; + extern u8 D_801850A4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80185090; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018507C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801850A4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80167714); + + +extern void (*D_8018515C[])(void); + +void func_801678B4(void *a0) { + D_8018515C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80185168[])(void); + +void func_80167A9C(void *a0) { + D_80185168[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80185274; + extern u8 D_80185288[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80185274); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185288; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801850C8[]; +extern u8 D_801850DC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801850C8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801850DC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80185180[])(void); + +void func_80168744(void *a0) { + D_80185180[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80185170 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80185170[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80185170; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80185188[])(void); + +void func_801689D8(void *a0) { + D_80185188[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80185190[])(void); + +void func_80168AA8(void *a0) { + D_80185190[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80185198[])(void); + +void func_80168D58(void *a0) { + D_80185198[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801851A0[])(void); + +void func_8016901C(void *a0) { + D_801851A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_003/nonmatchings/ov_SC04_003_jr_8015C32C", func_80169228); + + +extern void (*D_801851A8[])(void); + +void func_801693CC(void *a0) { + D_801851A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801851B0[])(void); + +void func_80169830(void *a0) { + D_801851B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80185264[])(void); + +void func_80169B80(void *a0) { + D_80185264[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801851B8[]; + extern u8 D_80185228[]; + extern u8 D_80185258[]; + extern u8 D_8019BAA8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80185258, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801851B8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019BAA8; + RotMatrixYXZ(rot, D_8019BAA8); + func_80048D9C(D_8019BAA8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80185228); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018526C[])(void); + +void func_80169F00(void *a0) { + D_8018526C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018521C[]; +extern char D_801851DC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018521C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801851DC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801852A4[])(void); + +void func_8016A020(void *a0) { + D_801852A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80185274; + extern u8 D_80185288[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80185274); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185288; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801852B0[])(void); + +void func_8016A700(void *a0) { + D_801852B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801852F8[])(void); + +void func_8016AB30(void *a0) { + D_801852F8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_004/ov_SC04_004_jr_8015AE2C.c b/src/ov_SC04_004/ov_SC04_004_jr_8015AE2C.c index cdf60362b..a53f2b274 100644 --- a/src/ov_SC04_004/ov_SC04_004_jr_8015AE2C.c +++ b/src/ov_SC04_004/ov_SC04_004_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80186EE8[])(void); - -void func_8015C714(void *a0) { - D_80186EE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80186D5C[])(void*); - extern int D_80186D00; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80186D5C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80186D5C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186D00); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80186D5C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80186D5C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80186D5C[])(void*); - extern int D_80186D00; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80186D5C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186D00); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80186D5C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80186EF8[])(void); - D_80186EF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80186D5C[])(struct Ent_8015CD20 *); - extern u8 D_80186D10; - extern u8 D_80186F00; - extern u8 D_80186F10; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80186D5C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D10); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F00); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F10); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80186D5C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80186F30[])(void); - D_80186F30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80186F20; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80186F20 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80186D5C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80186F8C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80186F8C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80186070[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80186070; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80186F94[])(void); - D_80186F94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80186FA0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80186FA0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80186FA0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80186FA0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80186D5C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80186FA0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80186D20[]; - extern u8 D_80186D30[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186D20); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186D30); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80186FA0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186FA0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186FA0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80186FD4[])(void); - D_80186FD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186D5C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186FDC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80186FF4[])(void); - D_80186FF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186D5C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186FDC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80187014[])(void); - D_80187014[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80186D5C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186D5C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80187024; -extern u16 D_80187026; -extern u16 D_80187028; -extern s32 D_8018702C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80187024 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80187026 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187028 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018702C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80187034; - -void func_8015E588(void) { - func_8013C9C4(&D_80187034); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80186D5C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186D5C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80187048[])(void); - D_80187048[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80186D5C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80186D5C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80187050[])(void); - D_80187050[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80186D40; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186D40); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80186D5C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187058[])(void); - D_80187058[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80186D5C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80186D5C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80187060[])(void); - D_80187060[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80186D5C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80187068; - extern s32 D_80187078; - extern s32 D_80187088; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80186D5C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187068); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187078); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80186D5C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187088); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80187098[])(void); - D_80187098[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80186D5C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80186D5C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80186D5C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186D5C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801870A4[])(void); - D_801870A4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80186D5C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186D5C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80186D5C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186D5C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801870B8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801870B8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80186D5C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80186D5C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80186D5C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186D5C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80187134[])(void); - D_80187134[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80186D5C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80186D5C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80187144[])(void); - D_80187144[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80186D5C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80186D5C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80186D5C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80186D5C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80186D5C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80186D5C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80186D5C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018714C[])(void); - D_8018714C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80186D5C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80186D5C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80186D5C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80186D5C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187158[])(void); - D_80187158[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186D5C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80186D5C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80186D5C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80186D5C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80187168[])(void); - -void func_80160EA4(void *a0) { - D_80187168[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80186D5C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80186D5C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80187198[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80187198[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801871FC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801871FC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B2690[]; - extern u8 D_801871C8[]; - extern u8 D_801871E8[]; - extern u8 D_801B269C[]; - extern u8 D_801B26C4[]; - extern u8 D_801B26DC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B2690[0] = p; - func_80024054(&D_801871C8, &D_801B269C); - func_8001CE28(p, &D_801B269C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B2690[1] = p; - func_80024054(&D_801871E8, &D_801B26C4); - func_8001CE28(p, &D_801B26C4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B2690[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B26DC, 0x84); - func_8001CE68(p, &D_801B26DC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B26DC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B2690[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B2690; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801871FC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801871FC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801871FC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801871FC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B2690[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B2690; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80187220[])(void); - -void func_80162330(void *a0) { - D_80187220[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B26E8[i] via `extern int D_801B26E8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018722C[]; - extern s32 D_80187244; - extern u8 D_801B26F4[]; - extern u8 D_801B271C[]; - extern u8 D_801B2738[]; - extern int D_801B26E8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B26E8[0] = (s32)item; - func_80024054(D_8018722C, D_801B26F4); - func_8001CE28(item, D_801B26F4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B26E8[1] = (s32)item; - func_80024054(((u8 *)&D_80187244), D_801B271C); - func_8001CE28(item, D_801B271C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B26E8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B2738, 0x84); - func_8001CE68(item, D_801B2738); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B2738, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B26E8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B26E8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187268[])(void); - -void func_80162834(void *a0) { - D_80187268[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187258; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187258, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B1F5C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B1F5C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B1F5C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B1F5C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80187270[])(void); - -void func_80163A58(void *a0) { - D_80187270[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B1F64; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B1F64; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801872C4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801872C4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018728C; -extern s16 D_801872C0; -extern s16 D_801872BE; -extern s16 D_801872BC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018728C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801872C0 = 0x80; - D_801872BE = 0x80; - D_801872BC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801872C0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801872C0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801872C0 - 8; - D_801872C0 = nv; - D_801872BE = nv; - D_801872BC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801872D0[])(void); - -void func_80164BA0(void *a0) { - D_801872D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B2748; -extern u8 D_801B2749; -extern u8 D_801B274A; -extern u8 D_801B274B; -extern u8 D_801B274C; -extern u8 D_801B274D; -extern u8 D_801B274E; -extern u8 D_801B274F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B2748; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B2749 = 0xf0; - *(u8 *)base = 0xf0; - D_801B274A = 0xc0; - D_801B274E = 0; - D_801B274D = 0; - D_801B274C = 0; - D_801B274F = 0; - D_801B274B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B2748; -extern u8 D_801B2749; -extern u8 D_801B274A; - -s32 func_80164E40(void) { - u8 *p = &D_801B2748; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B2749 != 0) { - D_801B2749 -= 0x10; - } - if (D_801B274A != 0) { - D_801B274A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801872E0[])(void); - -void func_80164EA4(void *a0) { - D_801872E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B2794[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B2794[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B2788[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B2788[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B2788[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B2788; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B2788; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801872F4[]; - extern u32 D_80187314, D_80187318, D_8018731C, D_80187320; - extern u32 D_80187314, D_80187318, D_8018731C, D_80187320; - extern u32 D_80187314, D_80187318, D_8018731C, D_80187320; - extern u32 D_80187314, D_80187318, D_8018731C, D_80187320; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801872F4[0x00], p); - ApplyMatrixSV(mat, &D_801872F4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801872F4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801872F4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018731C; - *(u32 *)(prim + 0x24) = D_80187314; - *(u32 *)(prim + 0x28) = D_80187320; - *(u32 *)(prim + 0x2c) = D_80187318; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187324[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187324[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187324[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187324[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801873A0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801873A0[a1 & 0x7F]; -} - - - -extern s32 D_801873C0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801873C0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018743C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018743C[a1 & 0x7F]; -} - - - -extern u8 D_8018745C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018745C[a1 & 0x7F]; -} - - - -extern u8 D_8018747C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018747C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018749C[])(void); - D_8018749C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187518[])(void); - -void func_80165AC8(void) { - D_80187518[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80187594[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80187594[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B1F6C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B1F6C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801875A0[])(void); - -void func_80166018(void *a0) { - D_801875A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801875A8[])(void); - -void func_801663FC(void *a0) { - D_801875A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80187670[])(void); - -void func_80166618(void *a0) { - D_80187670[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80187680[])(void); - -void func_80166654(void *a0) { - D_80187680[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B2808[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B2808[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B2808). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B2808[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B2808)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B2808[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B2808[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801875C4[]; - extern u8 D_801875B0[]; - extern u8 D_801875D8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801875C4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801875B0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801875D8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80167714); - - -extern void (*D_80187690[])(void); - -void func_801678B4(void *a0) { - D_80187690[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018769C[])(void); - -void func_80167A9C(void *a0) { - D_8018769C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801877A8; - extern u8 D_801877BC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801877A8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801877BC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801875FC[]; -extern u8 D_80187610[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801875FC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187610; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801876B4[])(void); - -void func_80168744(void *a0) { - D_801876B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801876A4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801876A4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801876A4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801876BC[])(void); - -void func_801689D8(void *a0) { - D_801876BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801876C4[])(void); - -void func_80168AA8(void *a0) { - D_801876C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801876CC[])(void); - -void func_80168D58(void *a0) { - D_801876CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801876D4[])(void); - -void func_8016901C(void *a0) { - D_801876D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015AE2C", func_80169228); - - -extern void (*D_801876DC[])(void); - -void func_801693CC(void *a0) { - D_801876DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801876E4[])(void); - -void func_80169830(void *a0) { - D_801876E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187798[])(void); - -void func_80169B80(void *a0) { - D_80187798[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801876EC[]; - extern u8 D_8018775C[]; - extern u8 D_8018778C[]; - extern u8 D_801B3B08[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018778C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801876EC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B3B08; - RotMatrixYXZ(rot, D_801B3B08); - func_80048D9C(D_801B3B08, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018775C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801877A0[])(void); - -void func_80169F00(void *a0) { - D_801877A0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80187750[]; -extern char D_80187710[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80187750, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187710); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801877D8[])(void); - -void func_8016A020(void *a0) { - D_801877D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801877A8; - extern u8 D_801877BC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801877A8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801877BC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801877E4[])(void); - -void func_8016A700(void *a0) { - D_801877E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018782C[])(void); - -void func_8016AB30(void *a0) { - D_8018782C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c b/src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c new file mode 100644 index 000000000..851d2a718 --- /dev/null +++ b/src/ov_SC04_004/ov_SC04_004_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80186BF8; +extern u8 D_80186B68; +extern u8 D_80186B44; +extern u8 D_80186B20; +extern u8 D_80186BD4; +extern u8 D_80186BB0; +extern u8 D_80186B8C; +extern u8 D_80186AFC; +extern void func_80145934(void); +extern u8 D_80186C88; +extern u8 D_80186C64; +extern u8 D_80186C40; +extern u8 D_80186C1C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80186080[]; +extern unsigned char D_801860B0[]; +extern unsigned char D_80186100[]; +extern unsigned char D_80186130[]; +extern unsigned char D_80186160[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801861B0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80186278[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80186300[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186308; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B2638; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B263C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186338; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801863E0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80186404[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801863F4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186418[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80186424[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80186434[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018644C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018643C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80186460[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018647C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018646C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80186490[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801864A4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801864B8; +extern void (*D_801864E0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801864C0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018652C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80186530[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80186994[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801869A4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B2670; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801869CC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801869AC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801869BC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80186A0C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80186A14[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801869E0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80186A20[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801869F0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B2678; +extern s32 D_801B2684; +extern s32 D_801B2688; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80186A5C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80186A30[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B2680; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80186CAC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80186ACC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80186D50[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80186EA4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186CC0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80186EAC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186CD0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80186CF0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80186EB4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80186EDC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80186D5C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80186EE8[])(void); + +void func_8015C714(void *a0) { + D_80186EE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80186D5C[])(void*); + extern int D_80186D00; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80186D5C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80186D5C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186D00); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80186D5C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80186D5C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80186D5C[])(void*); + extern int D_80186D00; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80186D5C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186D00); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80186D5C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80186EF8[])(void); + D_80186EF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80186D5C[])(struct Ent_8015CD20 *); + extern u8 D_80186D10; + extern u8 D_80186F00; + extern u8 D_80186F10; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80186D5C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D10); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F00); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186F10); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80186D5C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80186F30[])(void); + D_80186F30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80186F20; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80186F20 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80186D5C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80186F8C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80186F8C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80186070[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80186070; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80186F94[])(void); + D_80186F94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80186FA0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80186FA0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80186FA0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80186FA0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80186D5C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80186FA0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80186D20[]; + extern u8 D_80186D30[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186D20); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186D30); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80186FA0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186FA0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186FA0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80186FD4[])(void); + D_80186FD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186D5C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186FDC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80186FF4[])(void); + D_80186FF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186D5C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186FDC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186FDC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80187014[])(void); + D_80187014[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80186D5C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186D5C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80187024; +extern u16 D_80187026; +extern u16 D_80187028; +extern s32 D_8018702C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80187024 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80187026 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187028 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018702C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80187034; + +void func_8015E588(void) { + func_8013C9C4(&D_80187034); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80186D5C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186D5C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80187048[])(void); + D_80187048[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80186D5C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80186D5C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80187050[])(void); + D_80187050[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80186D40; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186D40); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80186D5C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187058[])(void); + D_80187058[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80186D5C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80186D5C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80187060[])(void); + D_80187060[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80186D5C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80187068; + extern s32 D_80187078; + extern s32 D_80187088; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187068); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187078); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80186D5C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187088); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80187098[])(void); + D_80187098[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80186D5C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80186D5C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80186D5C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186D5C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801870A4[])(void); + D_801870A4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80186D5C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186D5C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80186D5C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186D5C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801870B8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801870B8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80186D5C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80186D5C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80186D5C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186D5C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80187134[])(void); + D_80187134[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80186D5C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80186D5C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80187144[])(void); + D_80187144[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80186D5C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80186D5C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80186D5C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80186D5C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80186D5C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80186D5C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80186D5C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018714C[])(void); + D_8018714C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80186D5C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80186D5C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80186D5C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80186D5C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187158[])(void); + D_80187158[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186D5C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80186D5C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80186D5C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80186D5C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80187168[])(void); + +void func_80160EA4(void *a0) { + D_80187168[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80186D5C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80186D5C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80187198[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80187198[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801871FC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801871FC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B2690[]; + extern u8 D_801871C8[]; + extern u8 D_801871E8[]; + extern u8 D_801B269C[]; + extern u8 D_801B26C4[]; + extern u8 D_801B26DC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B2690[0] = p; + func_80024054(&D_801871C8, &D_801B269C); + func_8001CE28(p, &D_801B269C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B2690[1] = p; + func_80024054(&D_801871E8, &D_801B26C4); + func_8001CE28(p, &D_801B26C4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B2690[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B26DC, 0x84); + func_8001CE68(p, &D_801B26DC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B26DC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B2690[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B2690; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801871FC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801871FC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801871FC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801871FC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B2690[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B2690; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80187220[])(void); + +void func_80162330(void *a0) { + D_80187220[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B26E8[i] via `extern int D_801B26E8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018722C[]; + extern s32 D_80187244; + extern u8 D_801B26F4[]; + extern u8 D_801B271C[]; + extern u8 D_801B2738[]; + extern int D_801B26E8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B26E8[0] = (s32)item; + func_80024054(D_8018722C, D_801B26F4); + func_8001CE28(item, D_801B26F4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B26E8[1] = (s32)item; + func_80024054(((u8 *)&D_80187244), D_801B271C); + func_8001CE28(item, D_801B271C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B26E8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B2738, 0x84); + func_8001CE68(item, D_801B2738); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B2738, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B26E8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B26E8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_801627E8); + + +extern void (*D_80187268[])(void); + +void func_80162834(void *a0) { + D_80187268[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187258; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187258, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B1F5C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B1F5C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B1F5C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B1F5C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80187270[])(void); + +void func_80163A58(void *a0) { + D_80187270[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B1F64; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B1F64; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801872C4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801872C4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018728C; +extern s16 D_801872C0; +extern s16 D_801872BE; +extern s16 D_801872BC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018728C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801872C0 = 0x80; + D_801872BE = 0x80; + D_801872BC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801872C0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801872C0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801872C0 - 8; + D_801872C0 = nv; + D_801872BE = nv; + D_801872BC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801872D0[])(void); + +void func_80164BA0(void *a0) { + D_801872D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B2748; +extern u8 D_801B2749; +extern u8 D_801B274A; +extern u8 D_801B274B; +extern u8 D_801B274C; +extern u8 D_801B274D; +extern u8 D_801B274E; +extern u8 D_801B274F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B2748; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B2749 = 0xf0; + *(u8 *)base = 0xf0; + D_801B274A = 0xc0; + D_801B274E = 0; + D_801B274D = 0; + D_801B274C = 0; + D_801B274F = 0; + D_801B274B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B2748; +extern u8 D_801B2749; +extern u8 D_801B274A; + +s32 func_80164E40(void) { + u8 *p = &D_801B2748; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B2749 != 0) { + D_801B2749 -= 0x10; + } + if (D_801B274A != 0) { + D_801B274A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801872E0[])(void); + +void func_80164EA4(void *a0) { + D_801872E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B2794[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B2794[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B2788[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B2788[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B2788[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B2788; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B2788; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801872F4[]; + extern u32 D_80187314, D_80187318, D_8018731C, D_80187320; + extern u32 D_80187314, D_80187318, D_8018731C, D_80187320; + extern u32 D_80187314, D_80187318, D_8018731C, D_80187320; + extern u32 D_80187314, D_80187318, D_8018731C, D_80187320; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801872F4[0x00], p); + ApplyMatrixSV(mat, &D_801872F4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801872F4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801872F4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018731C; + *(u32 *)(prim + 0x24) = D_80187314; + *(u32 *)(prim + 0x28) = D_80187320; + *(u32 *)(prim + 0x2c) = D_80187318; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187324[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187324[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187324[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187324[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801873A0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801873A0[a1 & 0x7F]; +} + + + +extern s32 D_801873C0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801873C0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018743C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018743C[a1 & 0x7F]; +} + + + +extern u8 D_8018745C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018745C[a1 & 0x7F]; +} + + + +extern u8 D_8018747C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018747C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018749C[])(void); + D_8018749C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187518[])(void); + +void func_80165AC8(void) { + D_80187518[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80187594[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80187594[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B1F6C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B1F6C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801875A0[])(void); + +void func_80166018(void *a0) { + D_801875A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801875A8[])(void); + +void func_801663FC(void *a0) { + D_801875A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80187670[])(void); + +void func_80166618(void *a0) { + D_80187670[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80187680[])(void); + +void func_80166654(void *a0) { + D_80187680[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B2808[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B2808[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B2808). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B2808[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B2808)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B2808[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B2808[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801875C4[]; + extern u8 D_801875B0[]; + extern u8 D_801875D8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801875C4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801875B0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801875D8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80167714); + + +extern void (*D_80187690[])(void); + +void func_801678B4(void *a0) { + D_80187690[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018769C[])(void); + +void func_80167A9C(void *a0) { + D_8018769C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801877A8; + extern u8 D_801877BC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801877A8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801877BC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801875FC[]; +extern u8 D_80187610[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801875FC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187610; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801876B4[])(void); + +void func_80168744(void *a0) { + D_801876B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801876A4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801876A4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801876A4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801876BC[])(void); + +void func_801689D8(void *a0) { + D_801876BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801876C4[])(void); + +void func_80168AA8(void *a0) { + D_801876C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801876CC[])(void); + +void func_80168D58(void *a0) { + D_801876CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801876D4[])(void); + +void func_8016901C(void *a0) { + D_801876D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_004/nonmatchings/ov_SC04_004_jr_8015C32C", func_80169228); + + +extern void (*D_801876DC[])(void); + +void func_801693CC(void *a0) { + D_801876DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801876E4[])(void); + +void func_80169830(void *a0) { + D_801876E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187798[])(void); + +void func_80169B80(void *a0) { + D_80187798[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801876EC[]; + extern u8 D_8018775C[]; + extern u8 D_8018778C[]; + extern u8 D_801B3B08[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018778C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801876EC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B3B08; + RotMatrixYXZ(rot, D_801B3B08); + func_80048D9C(D_801B3B08, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018775C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801877A0[])(void); + +void func_80169F00(void *a0) { + D_801877A0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80187750[]; +extern char D_80187710[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80187750, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187710); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801877D8[])(void); + +void func_8016A020(void *a0) { + D_801877D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801877A8; + extern u8 D_801877BC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801877A8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801877BC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801877E4[])(void); + +void func_8016A700(void *a0) { + D_801877E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018782C[])(void); + +void func_8016AB30(void *a0) { + D_8018782C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_005/ov_SC04_005_jr_8015AE2C.c b/src/ov_SC04_005/ov_SC04_005_jr_8015AE2C.c index 6ef2f9f87..f21aa029f 100644 --- a/src/ov_SC04_005/ov_SC04_005_jr_8015AE2C.c +++ b/src/ov_SC04_005/ov_SC04_005_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018A31C[])(void); - -void func_8015C714(void *a0) { - D_8018A31C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018A190[])(void*); - extern int D_8018A134; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018A190)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018A190)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018A134); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018A190[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018A190[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018A190[])(void*); - extern int D_8018A134; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018A190)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018A134); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018A190)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018A32C[])(void); - D_8018A32C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018A190[])(struct Ent_8015CD20 *); - extern u8 D_8018A144; - extern u8 D_8018A334; - extern u8 D_8018A344; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018A190[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A144); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A334); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A344); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018A190[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018A364[])(void); - D_8018A364[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018A354; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018A354 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018A190[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018A3C0; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018A3C0, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801894A4[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801894A4; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018A3C8[])(void); - D_8018A3C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018A3D4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018A3D4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018A3D4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018A3D4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018A190[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018A3D4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018A154[]; - extern u8 D_8018A164[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018A154); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018A164); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018A3D4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018A3D4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018A3D4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018A408[])(void); - D_8018A408[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018A190[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018A410[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018A428[])(void); - D_8018A428[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018A190[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018A410[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018A448[])(void); - D_8018A448[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018A190[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018A190)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018A458; -extern u16 D_8018A45A; -extern u16 D_8018A45C; -extern s32 D_8018A460; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018A458 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018A45A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018A45C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018A460, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018A468; - -void func_8015E588(void) { - func_8013C9C4(&D_8018A468); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018A190[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018A190)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018A47C[])(void); - D_8018A47C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018A190[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018A190[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018A484[])(void); - D_8018A484[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018A174; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018A174); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018A190[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018A48C[])(void); - D_8018A48C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018A190[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018A190[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018A494[])(void); - D_8018A494[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018A190[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018A49C; - extern s32 D_8018A4AC; - extern s32 D_8018A4BC; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018A190[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A49C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A4AC); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018A190[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A4BC); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018A4CC[])(void); - D_8018A4CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018A190[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018A190[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018A190[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018A190[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018A4D8[])(void); - D_8018A4D8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018A190[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018A190[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018A190[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018A190[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018A4EC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018A4EC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018A190[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018A190)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018A190[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018A190[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018A568[])(void); - D_8018A568[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018A190[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018A190)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018A578[])(void); - D_8018A578[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018A190[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018A190[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018A190[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018A190[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018A190[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018A190[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018A190[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018A580[])(void); - D_8018A580[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018A190[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018A190)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018A190[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018A190)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018A58C[])(void); - D_8018A58C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018A190 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018A190[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018A190[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018A190[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018A59C[])(void); - -void func_80160EA4(void *a0) { - D_8018A59C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018A190[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018A190[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018A5CC[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018A5CC[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018A630; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018A630); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C0868[]; - extern u8 D_8018A5FC[]; - extern u8 D_8018A61C[]; - extern u8 D_801C0874[]; - extern u8 D_801C089C[]; - extern u8 D_801C08B4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C0868[0] = p; - func_80024054(&D_8018A5FC, &D_801C0874); - func_8001CE28(p, &D_801C0874); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C0868[1] = p; - func_80024054(&D_8018A61C, &D_801C089C); - func_8001CE28(p, &D_801C089C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C0868[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C08B4, 0x84); - func_8001CE68(p, &D_801C08B4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C08B4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C0868[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C0868; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018A630; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018A630; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018A630; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018A630; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C0868[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C0868; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018A654[])(void); - -void func_80162330(void *a0) { - D_8018A654[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C08C0[i] via `extern int D_801C08C0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018A660[]; - extern s32 D_8018A678; - extern u8 D_801C08CC[]; - extern u8 D_801C08F4[]; - extern u8 D_801C0910[]; - extern int D_801C08C0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C08C0[0] = (s32)item; - func_80024054(D_8018A660, D_801C08CC); - func_8001CE28(item, D_801C08CC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C08C0[1] = (s32)item; - func_80024054(((u8 *)&D_8018A678), D_801C08F4); - func_8001CE28(item, D_801C08F4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C08C0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C0910, 0x84); - func_8001CE68(item, D_801C0910); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C0910, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C08C0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C08C0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018A69C[])(void); - -void func_80162834(void *a0) { - D_8018A69C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018A68C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018A68C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C0120[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C0120, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C0120[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C0120, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018A6A4[])(void); - -void func_80163A58(void *a0) { - D_8018A6A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C0128; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C0128; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018A6F8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018A6F8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018A6C0; -extern s16 D_8018A6F4; -extern s16 D_8018A6F2; -extern s16 D_8018A6F0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018A6C0; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018A6F4 = 0x80; - D_8018A6F2 = 0x80; - D_8018A6F0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018A6F4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018A6F4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018A6F4 - 8; - D_8018A6F4 = nv; - D_8018A6F2 = nv; - D_8018A6F0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018A704[])(void); - -void func_80164BA0(void *a0) { - D_8018A704[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C0920; -extern u8 D_801C0921; -extern u8 D_801C0922; -extern u8 D_801C0923; -extern u8 D_801C0924; -extern u8 D_801C0925; -extern u8 D_801C0926; -extern u8 D_801C0927; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C0920; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C0921 = 0xf0; - *(u8 *)base = 0xf0; - D_801C0922 = 0xc0; - D_801C0926 = 0; - D_801C0925 = 0; - D_801C0924 = 0; - D_801C0927 = 0; - D_801C0923 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C0920; -extern u8 D_801C0921; -extern u8 D_801C0922; - -s32 func_80164E40(void) { - u8 *p = &D_801C0920; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C0921 != 0) { - D_801C0921 -= 0x10; - } - if (D_801C0922 != 0) { - D_801C0922 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018A714[])(void); - -void func_80164EA4(void *a0) { - D_8018A714[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C096C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C096C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C0960[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C0960[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C0960[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C0960; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C0960; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018A728[]; - extern u32 D_8018A748, D_8018A74C, D_8018A750, D_8018A754; - extern u32 D_8018A748, D_8018A74C, D_8018A750, D_8018A754; - extern u32 D_8018A748, D_8018A74C, D_8018A750, D_8018A754; - extern u32 D_8018A748, D_8018A74C, D_8018A750, D_8018A754; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018A728[0x00], p); - ApplyMatrixSV(mat, &D_8018A728[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018A728[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018A728[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018A750; - *(u32 *)(prim + 0x24) = D_8018A748; - *(u32 *)(prim + 0x28) = D_8018A754; - *(u32 *)(prim + 0x2c) = D_8018A74C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018A758[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018A758[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018A758[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018A758[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018A7D4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018A7D4[a1 & 0x7F]; -} - - - -extern s32 D_8018A7F4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018A7F4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018A870[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018A870[a1 & 0x7F]; -} - - - -extern u8 D_8018A890[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018A890[a1 & 0x7F]; -} - - - -extern u8 D_8018A8B0[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018A8B0[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018A8D0[])(void); - D_8018A8D0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018A94C[])(void); - -void func_80165AC8(void) { - D_8018A94C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018A9C8[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018A9C8[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C0130; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C0130, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018A9D4[])(void); - -void func_80166018(void *a0) { - D_8018A9D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018A9DC[])(void); - -void func_801663FC(void *a0) { - D_8018A9DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018AAA4[])(void); - -void func_80166618(void *a0) { - D_8018AAA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018AAB4[])(void); - -void func_80166654(void *a0) { - D_8018AAB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C09E0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C09E0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C09E0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C09E0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C09E0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C09E0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C09E0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018A9F8[]; - extern u8 D_8018A9E4[]; - extern u8 D_8018AA0C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018A9F8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018A9E4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018AA0C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80167714); - - -extern void (*D_8018AAC4[])(void); - -void func_801678B4(void *a0) { - D_8018AAC4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018AAD0[])(void); - -void func_80167A9C(void *a0) { - D_8018AAD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018ABDC; - extern u8 D_8018ABF0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018ABDC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018ABF0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018AA30[]; -extern u8 D_8018AA44[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018AA30; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018AA44; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018AAE8[])(void); - -void func_80168744(void *a0) { - D_8018AAE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018AAD8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018AAD8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018AAD8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018AAF0[])(void); - -void func_801689D8(void *a0) { - D_8018AAF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018AAF8[])(void); - -void func_80168AA8(void *a0) { - D_8018AAF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018AB00[])(void); - -void func_80168D58(void *a0) { - D_8018AB00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018AB08[])(void); - -void func_8016901C(void *a0) { - D_8018AB08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015AE2C", func_80169228); - - -extern void (*D_8018AB10[])(void); - -void func_801693CC(void *a0) { - D_8018AB10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018AB18[])(void); - -void func_80169830(void *a0) { - D_8018AB18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018ABCC[])(void); - -void func_80169B80(void *a0) { - D_8018ABCC[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018AB20[]; - extern u8 D_8018AB90[]; - extern u8 D_8018ABC0[]; - extern u8 D_801C21E8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018ABC0, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018AB20[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C21E8; - RotMatrixYXZ(rot, D_801C21E8); - func_80048D9C(D_801C21E8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018AB90); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018ABD4[])(void); - -void func_80169F00(void *a0) { - D_8018ABD4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018AB84[]; -extern char D_8018AB44[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018AB84, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018AB44); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018AC0C[])(void); - -void func_8016A020(void *a0) { - D_8018AC0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018ABDC; - extern u8 D_8018ABF0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018ABDC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018ABF0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018AC18[])(void); - -void func_8016A700(void *a0) { - D_8018AC18[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018AC60[])(void); - -void func_8016AB30(void *a0) { - D_8018AC60[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c b/src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c new file mode 100644 index 000000000..54255bc4d --- /dev/null +++ b/src/ov_SC04_005/ov_SC04_005_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018A02C; +extern u8 D_80189F9C; +extern u8 D_80189F78; +extern u8 D_80189F54; +extern u8 D_8018A008; +extern u8 D_80189FE4; +extern u8 D_80189FC0; +extern u8 D_80189F30; +extern void func_80145934(void); +extern u8 D_8018A0BC; +extern u8 D_8018A098; +extern u8 D_8018A074; +extern u8 D_8018A050; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801894B4[]; +extern unsigned char D_801894E4[]; +extern unsigned char D_80189534[]; +extern unsigned char D_80189564[]; +extern unsigned char D_80189594[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801895E4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801896AC[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80189734[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018973C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C0810; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C0814; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018976C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80189814[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80189838[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80189828; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018984C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80189858[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80189868[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80189880[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80189870; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80189894[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801898B0[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801898A0; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801898C4[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801898D8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801898EC; +extern void (*D_80189914[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801898F4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80189960[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80189964[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80189DC8[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80189DD8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C0848; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80189E00[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80189DE0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80189DF0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80189E40[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80189E48[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80189E14; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80189E54[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80189E24; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C0850; +extern s32 D_801C085C; +extern s32 D_801C0860; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80189E90[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80189E64[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C0858; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018A0E0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80189F00[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018A184[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018A2D8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018A0F4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018A2E0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018A104; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018A124; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018A2E8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018A310[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018A190[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018A31C[])(void); + +void func_8015C714(void *a0) { + D_8018A31C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018A190[])(void*); + extern int D_8018A134; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018A190)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018A190)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018A134); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018A190[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018A190[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018A190[])(void*); + extern int D_8018A134; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018A190)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018A134); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018A190)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018A32C[])(void); + D_8018A32C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018A190[])(struct Ent_8015CD20 *); + extern u8 D_8018A144; + extern u8 D_8018A334; + extern u8 D_8018A344; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018A190[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A144); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A334); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A344); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018A190[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018A364[])(void); + D_8018A364[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018A354; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018A354 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018A190[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018A3C0; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018A3C0, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801894A4[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801894A4; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018A3C8[])(void); + D_8018A3C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018A3D4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018A3D4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018A3D4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018A3D4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018A190[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018A3D4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018A154[]; + extern u8 D_8018A164[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018A154); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018A164); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018A3D4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018A3D4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018A3D4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018A408[])(void); + D_8018A408[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018A190[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018A410[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018A428[])(void); + D_8018A428[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018A190[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018A410[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018A410[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018A448[])(void); + D_8018A448[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018A190[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018A190)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018A458; +extern u16 D_8018A45A; +extern u16 D_8018A45C; +extern s32 D_8018A460; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018A458 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018A45A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018A45C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018A460, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018A468; + +void func_8015E588(void) { + func_8013C9C4(&D_8018A468); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018A190[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018A190)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018A47C[])(void); + D_8018A47C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018A190[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018A190[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018A484[])(void); + D_8018A484[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018A174; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018A174); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018A190[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018A48C[])(void); + D_8018A48C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018A190[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018A190[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018A494[])(void); + D_8018A494[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018A190[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018A49C; + extern s32 D_8018A4AC; + extern s32 D_8018A4BC; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A49C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A4AC); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018A190[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018A4BC); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018A4CC[])(void); + D_8018A4CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018A190[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018A190[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018A190[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018A190[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018A4D8[])(void); + D_8018A4D8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018A190[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018A190[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018A190[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018A190[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018A4EC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018A4EC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018A190[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018A190)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018A190[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018A190[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018A568[])(void); + D_8018A568[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018A190[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018A190)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018A578[])(void); + D_8018A578[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018A190[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018A190[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018A190[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018A190[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018A190[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018A190[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018A190[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018A580[])(void); + D_8018A580[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018A190[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018A190)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018A190[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018A190)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018A58C[])(void); + D_8018A58C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018A190 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018A190[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018A190[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018A190[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018A59C[])(void); + +void func_80160EA4(void *a0) { + D_8018A59C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018A190[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018A190[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018A5CC[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018A5CC[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018A630; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018A630); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C0868[]; + extern u8 D_8018A5FC[]; + extern u8 D_8018A61C[]; + extern u8 D_801C0874[]; + extern u8 D_801C089C[]; + extern u8 D_801C08B4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C0868[0] = p; + func_80024054(&D_8018A5FC, &D_801C0874); + func_8001CE28(p, &D_801C0874); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C0868[1] = p; + func_80024054(&D_8018A61C, &D_801C089C); + func_8001CE28(p, &D_801C089C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C0868[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C08B4, 0x84); + func_8001CE68(p, &D_801C08B4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C08B4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C0868[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C0868; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018A630; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018A630; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018A630; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018A630; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C0868[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C0868; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018A654[])(void); + +void func_80162330(void *a0) { + D_8018A654[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C08C0[i] via `extern int D_801C08C0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018A660[]; + extern s32 D_8018A678; + extern u8 D_801C08CC[]; + extern u8 D_801C08F4[]; + extern u8 D_801C0910[]; + extern int D_801C08C0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C08C0[0] = (s32)item; + func_80024054(D_8018A660, D_801C08CC); + func_8001CE28(item, D_801C08CC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C08C0[1] = (s32)item; + func_80024054(((u8 *)&D_8018A678), D_801C08F4); + func_8001CE28(item, D_801C08F4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C08C0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C0910, 0x84); + func_8001CE68(item, D_801C0910); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C0910, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C08C0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C08C0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_801627E8); + + +extern void (*D_8018A69C[])(void); + +void func_80162834(void *a0) { + D_8018A69C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018A68C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018A68C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C0120[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C0120, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C0120[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C0120, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018A6A4[])(void); + +void func_80163A58(void *a0) { + D_8018A6A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C0128; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C0128; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018A6F8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018A6F8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018A6C0; +extern s16 D_8018A6F4; +extern s16 D_8018A6F2; +extern s16 D_8018A6F0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018A6C0; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018A6F4 = 0x80; + D_8018A6F2 = 0x80; + D_8018A6F0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018A6F4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018A6F4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018A6F4 - 8; + D_8018A6F4 = nv; + D_8018A6F2 = nv; + D_8018A6F0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018A704[])(void); + +void func_80164BA0(void *a0) { + D_8018A704[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C0920; +extern u8 D_801C0921; +extern u8 D_801C0922; +extern u8 D_801C0923; +extern u8 D_801C0924; +extern u8 D_801C0925; +extern u8 D_801C0926; +extern u8 D_801C0927; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C0920; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C0921 = 0xf0; + *(u8 *)base = 0xf0; + D_801C0922 = 0xc0; + D_801C0926 = 0; + D_801C0925 = 0; + D_801C0924 = 0; + D_801C0927 = 0; + D_801C0923 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C0920; +extern u8 D_801C0921; +extern u8 D_801C0922; + +s32 func_80164E40(void) { + u8 *p = &D_801C0920; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C0921 != 0) { + D_801C0921 -= 0x10; + } + if (D_801C0922 != 0) { + D_801C0922 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018A714[])(void); + +void func_80164EA4(void *a0) { + D_8018A714[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C096C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C096C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C0960[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C0960[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C0960[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C0960; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C0960; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018A728[]; + extern u32 D_8018A748, D_8018A74C, D_8018A750, D_8018A754; + extern u32 D_8018A748, D_8018A74C, D_8018A750, D_8018A754; + extern u32 D_8018A748, D_8018A74C, D_8018A750, D_8018A754; + extern u32 D_8018A748, D_8018A74C, D_8018A750, D_8018A754; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018A728[0x00], p); + ApplyMatrixSV(mat, &D_8018A728[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018A728[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018A728[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018A750; + *(u32 *)(prim + 0x24) = D_8018A748; + *(u32 *)(prim + 0x28) = D_8018A754; + *(u32 *)(prim + 0x2c) = D_8018A74C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018A758[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018A758[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018A758[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018A758[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018A7D4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018A7D4[a1 & 0x7F]; +} + + + +extern s32 D_8018A7F4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018A7F4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018A870[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018A870[a1 & 0x7F]; +} + + + +extern u8 D_8018A890[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018A890[a1 & 0x7F]; +} + + + +extern u8 D_8018A8B0[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018A8B0[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018A8D0[])(void); + D_8018A8D0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018A94C[])(void); + +void func_80165AC8(void) { + D_8018A94C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018A9C8[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018A9C8[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C0130; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C0130, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018A9D4[])(void); + +void func_80166018(void *a0) { + D_8018A9D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018A9DC[])(void); + +void func_801663FC(void *a0) { + D_8018A9DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018AAA4[])(void); + +void func_80166618(void *a0) { + D_8018AAA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018AAB4[])(void); + +void func_80166654(void *a0) { + D_8018AAB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C09E0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C09E0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C09E0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C09E0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C09E0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C09E0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C09E0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018A9F8[]; + extern u8 D_8018A9E4[]; + extern u8 D_8018AA0C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018A9F8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018A9E4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018AA0C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80167714); + + +extern void (*D_8018AAC4[])(void); + +void func_801678B4(void *a0) { + D_8018AAC4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018AAD0[])(void); + +void func_80167A9C(void *a0) { + D_8018AAD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018ABDC; + extern u8 D_8018ABF0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018ABDC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018ABF0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018AA30[]; +extern u8 D_8018AA44[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018AA30; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018AA44; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018AAE8[])(void); + +void func_80168744(void *a0) { + D_8018AAE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018AAD8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018AAD8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018AAD8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018AAF0[])(void); + +void func_801689D8(void *a0) { + D_8018AAF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018AAF8[])(void); + +void func_80168AA8(void *a0) { + D_8018AAF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018AB00[])(void); + +void func_80168D58(void *a0) { + D_8018AB00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018AB08[])(void); + +void func_8016901C(void *a0) { + D_8018AB08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_005/nonmatchings/ov_SC04_005_jr_8015C32C", func_80169228); + + +extern void (*D_8018AB10[])(void); + +void func_801693CC(void *a0) { + D_8018AB10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018AB18[])(void); + +void func_80169830(void *a0) { + D_8018AB18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018ABCC[])(void); + +void func_80169B80(void *a0) { + D_8018ABCC[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018AB20[]; + extern u8 D_8018AB90[]; + extern u8 D_8018ABC0[]; + extern u8 D_801C21E8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018ABC0, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018AB20[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C21E8; + RotMatrixYXZ(rot, D_801C21E8); + func_80048D9C(D_801C21E8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018AB90); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018ABD4[])(void); + +void func_80169F00(void *a0) { + D_8018ABD4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018AB84[]; +extern char D_8018AB44[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018AB84, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018AB44); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018AC0C[])(void); + +void func_8016A020(void *a0) { + D_8018AC0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018ABDC; + extern u8 D_8018ABF0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018ABDC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018ABF0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018AC18[])(void); + +void func_8016A700(void *a0) { + D_8018AC18[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018AC60[])(void); + +void func_8016AB30(void *a0) { + D_8018AC60[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_006/ov_SC04_006_jr_8015AE2C.c b/src/ov_SC04_006/ov_SC04_006_jr_8015AE2C.c index d5762807e..0271dcdf6 100644 --- a/src/ov_SC04_006/ov_SC04_006_jr_8015AE2C.c +++ b/src/ov_SC04_006/ov_SC04_006_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801823FC[])(void); - -void func_8015C714(void *a0) { - D_801823FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80182270[])(void*); - extern int D_80182214; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80182270)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80182270)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182214); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80182270[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80182270[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80182270[])(void*); - extern int D_80182214; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80182270)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182214); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80182270)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018240C[])(void); - D_8018240C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80182270[])(struct Ent_8015CD20 *); - extern u8 D_80182224; - extern u8 D_80182414; - extern u8 D_80182424; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80182270[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182224); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182414); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182424); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80182270[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80182444[])(void); - D_80182444[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80182434; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80182434 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80182270[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801824A0; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801824A0, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80181584[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80181584; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801824A8[])(void); - D_801824A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801824B4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801824B4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801824B4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801824B4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80182270[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801824B4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80182234[]; - extern u8 D_80182244[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182234); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182244); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801824B4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801824B4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801824B4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801824E8[])(void); - D_801824E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182270[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801824F0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80182508[])(void); - D_80182508[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182270[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801824F0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80182528[])(void); - D_80182528[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80182270[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182270)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80182538; -extern u16 D_8018253A; -extern u16 D_8018253C; -extern s32 D_80182540; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80182538 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018253A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018253C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182540, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80182548; - -void func_8015E588(void) { - func_8013C9C4(&D_80182548); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80182270[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182270)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018255C[])(void); - D_8018255C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80182270[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80182270[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80182564[])(void); - D_80182564[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80182254; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182254); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80182270[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018256C[])(void); - D_8018256C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80182270[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80182270[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80182574[])(void); - D_80182574[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80182270[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018257C; - extern s32 D_8018258C; - extern s32 D_8018259C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80182270[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018257C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018258C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80182270[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018259C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801825AC[])(void); - D_801825AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80182270[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80182270[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80182270[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182270[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801825B8[])(void); - D_801825B8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80182270[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182270[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80182270[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182270[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801825CC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801825CC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80182270[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80182270)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80182270[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182270[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80182648[])(void); - D_80182648[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80182270[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80182270)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80182658[])(void); - D_80182658[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80182270[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80182270[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80182270[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80182270[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80182270[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80182270[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80182270[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80182660[])(void); - D_80182660[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80182270[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80182270)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80182270[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80182270)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018266C[])(void); - D_8018266C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182270 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80182270[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80182270[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80182270[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018267C[])(void); - -void func_80160EA4(void *a0) { - D_8018267C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80182270[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80182270[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801826AC[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801826AC[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80182710; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80182710); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019CB10[]; - extern u8 D_801826DC[]; - extern u8 D_801826FC[]; - extern u8 D_8019CB1C[]; - extern u8 D_8019CB44[]; - extern u8 D_8019CB5C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019CB10[0] = p; - func_80024054(&D_801826DC, &D_8019CB1C); - func_8001CE28(p, &D_8019CB1C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019CB10[1] = p; - func_80024054(&D_801826FC, &D_8019CB44); - func_8001CE28(p, &D_8019CB44); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019CB10[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019CB5C, 0x84); - func_8001CE68(p, &D_8019CB5C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019CB5C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019CB10[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019CB10; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80182710; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80182710; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80182710; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80182710; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019CB10[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019CB10; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80182734[])(void); - -void func_80162330(void *a0) { - D_80182734[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019CB68[i] via `extern int D_8019CB68[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80182740[]; - extern s32 D_80182758; - extern u8 D_8019CB74[]; - extern u8 D_8019CB9C[]; - extern u8 D_8019CBB8[]; - extern int D_8019CB68[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019CB68[0] = (s32)item; - func_80024054(D_80182740, D_8019CB74); - func_8001CE28(item, D_8019CB74); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019CB68[1] = (s32)item; - func_80024054(((u8 *)&D_80182758), D_8019CB9C); - func_8001CE28(item, D_8019CB9C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019CB68[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019CBB8, 0x84); - func_8001CE68(item, D_8019CBB8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019CBB8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019CB68[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019CB68; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018277C[])(void); - -void func_80162834(void *a0) { - D_8018277C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018276C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018276C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019C3C8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019C3C8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019C3C8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019C3C8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80182784[])(void); - -void func_80163A58(void *a0) { - D_80182784[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019C3D0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019C3D0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801827D8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801827D8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801827A0; -extern s16 D_801827D4; -extern s16 D_801827D2; -extern s16 D_801827D0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801827A0; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801827D4 = 0x80; - D_801827D2 = 0x80; - D_801827D0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801827D4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801827D4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801827D4 - 8; - D_801827D4 = nv; - D_801827D2 = nv; - D_801827D0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801827E4[])(void); - -void func_80164BA0(void *a0) { - D_801827E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019CBC8; -extern u8 D_8019CBC9; -extern u8 D_8019CBCA; -extern u8 D_8019CBCB; -extern u8 D_8019CBCC; -extern u8 D_8019CBCD; -extern u8 D_8019CBCE; -extern u8 D_8019CBCF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019CBC8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019CBC9 = 0xf0; - *(u8 *)base = 0xf0; - D_8019CBCA = 0xc0; - D_8019CBCE = 0; - D_8019CBCD = 0; - D_8019CBCC = 0; - D_8019CBCF = 0; - D_8019CBCB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019CBC8; -extern u8 D_8019CBC9; -extern u8 D_8019CBCA; - -s32 func_80164E40(void) { - u8 *p = &D_8019CBC8; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019CBC9 != 0) { - D_8019CBC9 -= 0x10; - } - if (D_8019CBCA != 0) { - D_8019CBCA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801827F4[])(void); - -void func_80164EA4(void *a0) { - D_801827F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019CC14[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019CC14[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019CC08[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019CC08[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019CC08[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019CC08; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019CC08; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80182808[]; - extern u32 D_80182828, D_8018282C, D_80182830, D_80182834; - extern u32 D_80182828, D_8018282C, D_80182830, D_80182834; - extern u32 D_80182828, D_8018282C, D_80182830, D_80182834; - extern u32 D_80182828, D_8018282C, D_80182830, D_80182834; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80182808[0x00], p); - ApplyMatrixSV(mat, &D_80182808[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80182808[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80182808[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80182830; - *(u32 *)(prim + 0x24) = D_80182828; - *(u32 *)(prim + 0x28) = D_80182834; - *(u32 *)(prim + 0x2c) = D_8018282C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80182838[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80182838[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80182838[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80182838[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801828B4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801828B4[a1 & 0x7F]; -} - - - -extern s32 D_801828D4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801828D4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80182950[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80182950[a1 & 0x7F]; -} - - - -extern u8 D_80182970[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182970[a1 & 0x7F]; -} - - - -extern u8 D_80182990[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182990[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801829B0[])(void); - D_801829B0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80182A2C[])(void); - -void func_80165AC8(void) { - D_80182A2C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80182AA8[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80182AA8[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019C3D8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019C3D8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80182AB4[])(void); - -void func_80166018(void *a0) { - D_80182AB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80182ABC[])(void); - -void func_801663FC(void *a0) { - D_80182ABC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182B84[])(void); - -void func_80166618(void *a0) { - D_80182B84[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182B94[])(void); - -void func_80166654(void *a0) { - D_80182B94[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019CC88[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019CC88[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019CC88). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019CC88[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019CC88)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019CC88[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019CC88[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80182AD8[]; - extern u8 D_80182AC4[]; - extern u8 D_80182AEC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80182AD8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80182AC4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182AEC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80167714); - - -extern void (*D_80182BA4[])(void); - -void func_801678B4(void *a0) { - D_80182BA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80182BB0[])(void); - -void func_80167A9C(void *a0) { - D_80182BB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80182CBC; - extern u8 D_80182CD0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80182CBC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182CD0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80182B10[]; -extern u8 D_80182B24[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80182B10; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80182B24; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80182BC8[])(void); - -void func_80168744(void *a0) { - D_80182BC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80182BB8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80182BB8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80182BB8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80182BD0[])(void); - -void func_801689D8(void *a0) { - D_80182BD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80182BD8[])(void); - -void func_80168AA8(void *a0) { - D_80182BD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80182BE0[])(void); - -void func_80168D58(void *a0) { - D_80182BE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80182BE8[])(void); - -void func_8016901C(void *a0) { - D_80182BE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015AE2C", func_80169228); - - -extern void (*D_80182BF0[])(void); - -void func_801693CC(void *a0) { - D_80182BF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80182BF8[])(void); - -void func_80169830(void *a0) { - D_80182BF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80182CAC[])(void); - -void func_80169B80(void *a0) { - D_80182CAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80182C00[]; - extern u8 D_80182C70[]; - extern u8 D_80182CA0[]; - extern u8 D_8019DC88[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80182CA0, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80182C00[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019DC88; - RotMatrixYXZ(rot, D_8019DC88); - func_80048D9C(D_8019DC88, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182C70); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80182CB4[])(void); - -void func_80169F00(void *a0) { - D_80182CB4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80182C64[]; -extern char D_80182C24[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80182C64, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182C24); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80182CEC[])(void); - -void func_8016A020(void *a0) { - D_80182CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80182CBC; - extern u8 D_80182CD0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80182CBC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182CD0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80182CF8[])(void); - -void func_8016A700(void *a0) { - D_80182CF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80182D40[])(void); - -void func_8016AB30(void *a0) { - D_80182D40[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c b/src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c new file mode 100644 index 000000000..0cc79d574 --- /dev/null +++ b/src/ov_SC04_006/ov_SC04_006_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018210C; +extern u8 D_8018207C; +extern u8 D_80182058; +extern u8 D_80182034; +extern u8 D_801820E8; +extern u8 D_801820C4; +extern u8 D_801820A0; +extern u8 D_80182010; +extern void func_80145934(void); +extern u8 D_8018219C; +extern u8 D_80182178; +extern u8 D_80182154; +extern u8 D_80182130; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80181594[]; +extern unsigned char D_801815C4[]; +extern unsigned char D_80181614[]; +extern unsigned char D_80181644[]; +extern unsigned char D_80181674[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801816C4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018178C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80181814[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018181C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019CAB8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019CABC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018184C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801818F4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80181918[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80181908; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018192C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80181938[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80181948[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181960[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80181950; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181974[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181990[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181980; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801819A4[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801819B8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801819CC; +extern void (*D_801819F4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801819D4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80181A40[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80181A44[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80181EA8[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80181EB8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019CAF0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80181EE0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80181EC0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80181ED0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80181F20[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80181F28[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80181EF4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80181F34[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80181F04; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019CAF8; +extern s32 D_8019CB04; +extern s32 D_8019CB08; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80181F70[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80181F44[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019CB00; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801821C0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80181FE0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80182264[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801823B8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801821D4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801823C0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801821E4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80182204; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801823C8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801823F0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80182270[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80182270[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80182270[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80182270[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80182270[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80182270[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80182270[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80182270[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801823FC[])(void); + +void func_8015C714(void *a0) { + D_801823FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80182270[])(void*); + extern int D_80182214; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80182270)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80182270)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182214); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80182270[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80182270[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80182270[])(void*); + extern int D_80182214; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80182270)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182214); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80182270)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018240C[])(void); + D_8018240C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80182270[])(struct Ent_8015CD20 *); + extern u8 D_80182224; + extern u8 D_80182414; + extern u8 D_80182424; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80182270[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182224); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182414); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182424); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80182270[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80182444[])(void); + D_80182444[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80182434; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80182434 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80182270[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801824A0; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801824A0, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80181584[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80181584; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801824A8[])(void); + D_801824A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801824B4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801824B4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801824B4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801824B4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80182270[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801824B4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80182234[]; + extern u8 D_80182244[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182234); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182244); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801824B4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801824B4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801824B4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801824E8[])(void); + D_801824E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182270[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801824F0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80182508[])(void); + D_80182508[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182270[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801824F0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801824F0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80182528[])(void); + D_80182528[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80182270[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182270)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80182538; +extern u16 D_8018253A; +extern u16 D_8018253C; +extern s32 D_80182540; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80182538 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018253A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018253C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182540, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80182548; + +void func_8015E588(void) { + func_8013C9C4(&D_80182548); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80182270[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182270)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018255C[])(void); + D_8018255C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80182270[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80182270[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80182564[])(void); + D_80182564[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80182254; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182254); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80182270[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018256C[])(void); + D_8018256C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80182270[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80182270[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80182574[])(void); + D_80182574[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80182270[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018257C; + extern s32 D_8018258C; + extern s32 D_8018259C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80182270[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018257C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018258C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80182270[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018259C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801825AC[])(void); + D_801825AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80182270[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80182270[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80182270[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182270[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801825B8[])(void); + D_801825B8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80182270[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182270[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80182270[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182270[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801825CC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801825CC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80182270[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80182270)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80182270[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182270[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80182648[])(void); + D_80182648[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80182270[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80182270)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80182658[])(void); + D_80182658[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80182270[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80182270[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80182270[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80182270[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80182270[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80182270[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80182270[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80182660[])(void); + D_80182660[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80182270[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80182270)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80182270[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80182270)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018266C[])(void); + D_8018266C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182270 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80182270[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80182270[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80182270[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018267C[])(void); + +void func_80160EA4(void *a0) { + D_8018267C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80182270[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80182270[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801826AC[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801826AC[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80182710; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80182710); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019CB10[]; + extern u8 D_801826DC[]; + extern u8 D_801826FC[]; + extern u8 D_8019CB1C[]; + extern u8 D_8019CB44[]; + extern u8 D_8019CB5C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019CB10[0] = p; + func_80024054(&D_801826DC, &D_8019CB1C); + func_8001CE28(p, &D_8019CB1C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019CB10[1] = p; + func_80024054(&D_801826FC, &D_8019CB44); + func_8001CE28(p, &D_8019CB44); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019CB10[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019CB5C, 0x84); + func_8001CE68(p, &D_8019CB5C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019CB5C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019CB10[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019CB10; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80182710; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80182710; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80182710; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80182710; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019CB10[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019CB10; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80182734[])(void); + +void func_80162330(void *a0) { + D_80182734[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019CB68[i] via `extern int D_8019CB68[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80182740[]; + extern s32 D_80182758; + extern u8 D_8019CB74[]; + extern u8 D_8019CB9C[]; + extern u8 D_8019CBB8[]; + extern int D_8019CB68[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019CB68[0] = (s32)item; + func_80024054(D_80182740, D_8019CB74); + func_8001CE28(item, D_8019CB74); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019CB68[1] = (s32)item; + func_80024054(((u8 *)&D_80182758), D_8019CB9C); + func_8001CE28(item, D_8019CB9C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019CB68[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019CBB8, 0x84); + func_8001CE68(item, D_8019CBB8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019CBB8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019CB68[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019CB68; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_801627E8); + + +extern void (*D_8018277C[])(void); + +void func_80162834(void *a0) { + D_8018277C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018276C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018276C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019C3C8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019C3C8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019C3C8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019C3C8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80182784[])(void); + +void func_80163A58(void *a0) { + D_80182784[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019C3D0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019C3D0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801827D8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801827D8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801827A0; +extern s16 D_801827D4; +extern s16 D_801827D2; +extern s16 D_801827D0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801827A0; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801827D4 = 0x80; + D_801827D2 = 0x80; + D_801827D0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801827D4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801827D4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801827D4 - 8; + D_801827D4 = nv; + D_801827D2 = nv; + D_801827D0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801827E4[])(void); + +void func_80164BA0(void *a0) { + D_801827E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019CBC8; +extern u8 D_8019CBC9; +extern u8 D_8019CBCA; +extern u8 D_8019CBCB; +extern u8 D_8019CBCC; +extern u8 D_8019CBCD; +extern u8 D_8019CBCE; +extern u8 D_8019CBCF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019CBC8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019CBC9 = 0xf0; + *(u8 *)base = 0xf0; + D_8019CBCA = 0xc0; + D_8019CBCE = 0; + D_8019CBCD = 0; + D_8019CBCC = 0; + D_8019CBCF = 0; + D_8019CBCB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019CBC8; +extern u8 D_8019CBC9; +extern u8 D_8019CBCA; + +s32 func_80164E40(void) { + u8 *p = &D_8019CBC8; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019CBC9 != 0) { + D_8019CBC9 -= 0x10; + } + if (D_8019CBCA != 0) { + D_8019CBCA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801827F4[])(void); + +void func_80164EA4(void *a0) { + D_801827F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019CC14[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019CC14[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019CC08[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019CC08[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019CC08[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019CC08; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019CC08; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80182808[]; + extern u32 D_80182828, D_8018282C, D_80182830, D_80182834; + extern u32 D_80182828, D_8018282C, D_80182830, D_80182834; + extern u32 D_80182828, D_8018282C, D_80182830, D_80182834; + extern u32 D_80182828, D_8018282C, D_80182830, D_80182834; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80182808[0x00], p); + ApplyMatrixSV(mat, &D_80182808[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80182808[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80182808[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80182830; + *(u32 *)(prim + 0x24) = D_80182828; + *(u32 *)(prim + 0x28) = D_80182834; + *(u32 *)(prim + 0x2c) = D_8018282C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80182838[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80182838[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80182838[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80182838[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801828B4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801828B4[a1 & 0x7F]; +} + + + +extern s32 D_801828D4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801828D4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80182950[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80182950[a1 & 0x7F]; +} + + + +extern u8 D_80182970[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182970[a1 & 0x7F]; +} + + + +extern u8 D_80182990[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182990[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801829B0[])(void); + D_801829B0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80182A2C[])(void); + +void func_80165AC8(void) { + D_80182A2C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80182AA8[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80182AA8[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019C3D8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019C3D8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80182AB4[])(void); + +void func_80166018(void *a0) { + D_80182AB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80182ABC[])(void); + +void func_801663FC(void *a0) { + D_80182ABC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182B84[])(void); + +void func_80166618(void *a0) { + D_80182B84[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182B94[])(void); + +void func_80166654(void *a0) { + D_80182B94[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019CC88[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019CC88[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019CC88). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019CC88[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019CC88)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019CC88[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019CC88[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80182AD8[]; + extern u8 D_80182AC4[]; + extern u8 D_80182AEC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80182AD8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80182AC4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182AEC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80167714); + + +extern void (*D_80182BA4[])(void); + +void func_801678B4(void *a0) { + D_80182BA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80182BB0[])(void); + +void func_80167A9C(void *a0) { + D_80182BB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80182CBC; + extern u8 D_80182CD0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80182CBC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182CD0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80182B10[]; +extern u8 D_80182B24[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80182B10; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80182B24; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80182BC8[])(void); + +void func_80168744(void *a0) { + D_80182BC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80182BB8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80182BB8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80182BB8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80182BD0[])(void); + +void func_801689D8(void *a0) { + D_80182BD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80182BD8[])(void); + +void func_80168AA8(void *a0) { + D_80182BD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80182BE0[])(void); + +void func_80168D58(void *a0) { + D_80182BE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80182BE8[])(void); + +void func_8016901C(void *a0) { + D_80182BE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_006/nonmatchings/ov_SC04_006_jr_8015C32C", func_80169228); + + +extern void (*D_80182BF0[])(void); + +void func_801693CC(void *a0) { + D_80182BF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80182BF8[])(void); + +void func_80169830(void *a0) { + D_80182BF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80182CAC[])(void); + +void func_80169B80(void *a0) { + D_80182CAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80182C00[]; + extern u8 D_80182C70[]; + extern u8 D_80182CA0[]; + extern u8 D_8019DC88[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80182CA0, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80182C00[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019DC88; + RotMatrixYXZ(rot, D_8019DC88); + func_80048D9C(D_8019DC88, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182C70); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80182CB4[])(void); + +void func_80169F00(void *a0) { + D_80182CB4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80182C64[]; +extern char D_80182C24[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80182C64, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182C24); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80182CEC[])(void); + +void func_8016A020(void *a0) { + D_80182CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80182CBC; + extern u8 D_80182CD0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80182CBC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182CD0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80182CF8[])(void); + +void func_8016A700(void *a0) { + D_80182CF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80182D40[])(void); + +void func_8016AB30(void *a0) { + D_80182D40[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_007/ov_SC04_007_jr_8015AE2C.c b/src/ov_SC04_007/ov_SC04_007_jr_8015AE2C.c index 2d74a5c55..71a8a0180 100644 --- a/src/ov_SC04_007/ov_SC04_007_jr_8015AE2C.c +++ b/src/ov_SC04_007/ov_SC04_007_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801883B4[])(void); - -void func_8015C714(void *a0) { - D_801883B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80188228[])(void*); - extern int D_801881CC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80188228)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80188228)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801881CC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80188228[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80188228[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80188228[])(void*); - extern int D_801881CC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80188228)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801881CC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80188228)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801883C4[])(void); - D_801883C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80188228[])(struct Ent_8015CD20 *); - extern u8 D_801881DC; - extern u8 D_801883CC; - extern u8 D_801883DC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80188228[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801881DC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801883CC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801883DC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80188228[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801883FC[])(void); - D_801883FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801883EC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801883EC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80188228[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80188458; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80188458, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018753C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018753C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80188460[])(void); - D_80188460[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018846C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018846C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018846C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018846C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80188228[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018846C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801881EC[]; - extern u8 D_801881FC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801881EC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801881FC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018846C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018846C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018846C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801884A0[])(void); - D_801884A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188228[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801884A8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801884C0[])(void); - D_801884C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188228[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801884A8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801884E0[])(void); - D_801884E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80188228[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188228)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801884F0; -extern u16 D_801884F2; -extern u16 D_801884F4; -extern s32 D_801884F8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801884F0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801884F2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801884F4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801884F8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80188500; - -void func_8015E588(void) { - func_8013C9C4(&D_80188500); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80188228[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188228)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80188514[])(void); - D_80188514[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80188228[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80188228[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018851C[])(void); - D_8018851C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018820C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018820C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80188228[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80188524[])(void); - D_80188524[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80188228[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80188228[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018852C[])(void); - D_8018852C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80188228[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80188534; - extern s32 D_80188544; - extern s32 D_80188554; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80188228[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188534); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188544); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80188228[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188554); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80188564[])(void); - D_80188564[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80188228[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80188228[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80188228[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188228[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80188570[])(void); - D_80188570[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80188228[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188228[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80188228[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188228[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80188584[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80188584[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80188228[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80188228)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80188228[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188228[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80188600[])(void); - D_80188600[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80188228[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80188228)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80188610[])(void); - D_80188610[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80188228[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80188228[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80188228[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80188228[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80188228[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80188228[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80188228[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80188618[])(void); - D_80188618[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80188228[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80188228)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80188228[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80188228)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80188624[])(void); - D_80188624[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188228 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80188228[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80188228[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80188228[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80188634[])(void); - -void func_80160EA4(void *a0) { - D_80188634[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80188228[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80188228[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80188664[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80188664[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801886C8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801886C8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B40C8[]; - extern u8 D_80188694[]; - extern u8 D_801886B4[]; - extern u8 D_801B40D4[]; - extern u8 D_801B40FC[]; - extern u8 D_801B4114[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B40C8[0] = p; - func_80024054(&D_80188694, &D_801B40D4); - func_8001CE28(p, &D_801B40D4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B40C8[1] = p; - func_80024054(&D_801886B4, &D_801B40FC); - func_8001CE28(p, &D_801B40FC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B40C8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B4114, 0x84); - func_8001CE68(p, &D_801B4114); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B4114, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B40C8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B40C8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801886C8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801886C8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801886C8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801886C8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B40C8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B40C8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801886EC[])(void); - -void func_80162330(void *a0) { - D_801886EC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B4120[i] via `extern int D_801B4120[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801886F8[]; - extern s32 D_80188710; - extern u8 D_801B412C[]; - extern u8 D_801B4154[]; - extern u8 D_801B4170[]; - extern int D_801B4120[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B4120[0] = (s32)item; - func_80024054(D_801886F8, D_801B412C); - func_8001CE28(item, D_801B412C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B4120[1] = (s32)item; - func_80024054(((u8 *)&D_80188710), D_801B4154); - func_8001CE28(item, D_801B4154); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B4120[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B4170, 0x84); - func_8001CE68(item, D_801B4170); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B4170, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B4120[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B4120; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_801627E8); - - -extern void (*D_80188734[])(void); - -void func_80162834(void *a0) { - D_80188734[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80188724; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80188724, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B3984[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B3984, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B3984[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B3984, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018873C[])(void); - -void func_80163A58(void *a0) { - D_8018873C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B398C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B398C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80188790[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80188790[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80188758; -extern s16 D_8018878C; -extern s16 D_8018878A; -extern s16 D_80188788; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80188758; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018878C = 0x80; - D_8018878A = 0x80; - D_80188788 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018878C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018878C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018878C - 8; - D_8018878C = nv; - D_8018878A = nv; - D_80188788 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018879C[])(void); - -void func_80164BA0(void *a0) { - D_8018879C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B4180; -extern u8 D_801B4181; -extern u8 D_801B4182; -extern u8 D_801B4183; -extern u8 D_801B4184; -extern u8 D_801B4185; -extern u8 D_801B4186; -extern u8 D_801B4187; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B4180; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B4181 = 0xf0; - *(u8 *)base = 0xf0; - D_801B4182 = 0xc0; - D_801B4186 = 0; - D_801B4185 = 0; - D_801B4184 = 0; - D_801B4187 = 0; - D_801B4183 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B4180; -extern u8 D_801B4181; -extern u8 D_801B4182; - -s32 func_80164E40(void) { - u8 *p = &D_801B4180; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B4181 != 0) { - D_801B4181 -= 0x10; - } - if (D_801B4182 != 0) { - D_801B4182 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801887AC[])(void); - -void func_80164EA4(void *a0) { - D_801887AC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B41CC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B41CC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B41C0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B41C0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B41C0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B41C0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B41C0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801887C0[]; - extern u32 D_801887E0, D_801887E4, D_801887E8, D_801887EC; - extern u32 D_801887E0, D_801887E4, D_801887E8, D_801887EC; - extern u32 D_801887E0, D_801887E4, D_801887E8, D_801887EC; - extern u32 D_801887E0, D_801887E4, D_801887E8, D_801887EC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801887C0[0x00], p); - ApplyMatrixSV(mat, &D_801887C0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801887C0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801887C0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801887E8; - *(u32 *)(prim + 0x24) = D_801887E0; - *(u32 *)(prim + 0x28) = D_801887EC; - *(u32 *)(prim + 0x2c) = D_801887E4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801887F0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801887F0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801887F0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801887F0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018886C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018886C[a1 & 0x7F]; -} - - - -extern s32 D_8018888C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018888C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80188908[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80188908[a1 & 0x7F]; -} - - - -extern u8 D_80188928[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80188928[a1 & 0x7F]; -} - - - -extern u8 D_80188948[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80188948[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80188968[])(void); - D_80188968[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801889E4[])(void); - -void func_80165AC8(void) { - D_801889E4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80188A60[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80188A60[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B3994; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B3994, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80188A6C[])(void); - -void func_80166018(void *a0) { - D_80188A6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80188A74[])(void); - -void func_801663FC(void *a0) { - D_80188A74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80188B3C[])(void); - -void func_80166618(void *a0) { - D_80188B3C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80188B4C[])(void); - -void func_80166654(void *a0) { - D_80188B4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B4240[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B4240[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B4240). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B4240[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B4240)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B4240[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B4240[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80188A90[]; - extern u8 D_80188A7C[]; - extern u8 D_80188AA4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80188A90; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80188A7C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80188AA4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80167714); - - -extern void (*D_80188B5C[])(void); - -void func_801678B4(void *a0) { - D_80188B5C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80188B68[])(void); - -void func_80167A9C(void *a0) { - D_80188B68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80188C74; - extern u8 D_80188C88[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80188C74); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188C88; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80188AC8[]; -extern u8 D_80188ADC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80188AC8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80188ADC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80188B80[])(void); - -void func_80168744(void *a0) { - D_80188B80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80188B70 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80188B70[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80188B70; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80188B88[])(void); - -void func_801689D8(void *a0) { - D_80188B88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80188B90[])(void); - -void func_80168AA8(void *a0) { - D_80188B90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80188B98[])(void); - -void func_80168D58(void *a0) { - D_80188B98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80188BA0[])(void); - -void func_8016901C(void *a0) { - D_80188BA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015AE2C", func_80169228); - - -extern void (*D_80188BA8[])(void); - -void func_801693CC(void *a0) { - D_80188BA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80188BB0[])(void); - -void func_80169830(void *a0) { - D_80188BB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80188C64[])(void); - -void func_80169B80(void *a0) { - D_80188C64[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80188BB8[]; - extern u8 D_80188C28[]; - extern u8 D_80188C58[]; - extern u8 D_801B5A48[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80188C58, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80188BB8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B5A48; - RotMatrixYXZ(rot, D_801B5A48); - func_80048D9C(D_801B5A48, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80188C28); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80188C6C[])(void); - -void func_80169F00(void *a0) { - D_80188C6C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80188C1C[]; -extern char D_80188BDC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80188C1C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188BDC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80188CA4[])(void); - -void func_8016A020(void *a0) { - D_80188CA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80188C74; - extern u8 D_80188C88[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80188C74); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188C88; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80188CB0[])(void); - -void func_8016A700(void *a0) { - D_80188CB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80188CF8[])(void); - -void func_8016AB30(void *a0) { - D_80188CF8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c b/src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c new file mode 100644 index 000000000..8c8188a70 --- /dev/null +++ b/src/ov_SC04_007/ov_SC04_007_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801880C4; +extern u8 D_80188034; +extern u8 D_80188010; +extern u8 D_80187FEC; +extern u8 D_801880A0; +extern u8 D_8018807C; +extern u8 D_80188058; +extern u8 D_80187FC8; +extern void func_80145934(void); +extern u8 D_80188154; +extern u8 D_80188130; +extern u8 D_8018810C; +extern u8 D_801880E8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018754C[]; +extern unsigned char D_8018757C[]; +extern unsigned char D_801875CC[]; +extern unsigned char D_801875FC[]; +extern unsigned char D_8018762C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018767C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80187744[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801877CC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801877D4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B4070; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B4074; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80187804; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801878AC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801878D0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801878C0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801878E4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801878F0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80187900[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80187918[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80187908; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018792C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80187948[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80187938; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018795C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80187970[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80187984; +extern void (*D_801879AC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018798C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801879F8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801879FC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80187E60[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80187E70[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B40A8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80187E98[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80187E78; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80187E88; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80187ED8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80187EE0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80187EAC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80187EEC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80187EBC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B40B0; +extern s32 D_801B40BC; +extern s32 D_801B40C0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80187F28[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80187EFC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B40B8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80188178[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80187F98[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018821C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80188370[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018818C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80188378[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018819C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801881BC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80188380[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801883A8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80188228[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80188228[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80188228[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80188228[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80188228[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80188228[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80188228[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80188228[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801883B4[])(void); + +void func_8015C714(void *a0) { + D_801883B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80188228[])(void*); + extern int D_801881CC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80188228)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80188228)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801881CC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80188228[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80188228[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80188228[])(void*); + extern int D_801881CC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80188228)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801881CC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80188228)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801883C4[])(void); + D_801883C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80188228[])(struct Ent_8015CD20 *); + extern u8 D_801881DC; + extern u8 D_801883CC; + extern u8 D_801883DC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80188228[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801881DC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801883CC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801883DC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80188228[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801883FC[])(void); + D_801883FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801883EC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801883EC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80188228[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80188458; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80188458, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018753C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018753C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80188460[])(void); + D_80188460[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018846C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018846C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018846C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018846C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80188228[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018846C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801881EC[]; + extern u8 D_801881FC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801881EC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801881FC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018846C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018846C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018846C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801884A0[])(void); + D_801884A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188228[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801884A8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801884C0[])(void); + D_801884C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188228[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801884A8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801884A8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801884E0[])(void); + D_801884E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80188228[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188228)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801884F0; +extern u16 D_801884F2; +extern u16 D_801884F4; +extern s32 D_801884F8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801884F0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801884F2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801884F4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801884F8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80188500; + +void func_8015E588(void) { + func_8013C9C4(&D_80188500); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80188228[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188228)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80188514[])(void); + D_80188514[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80188228[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80188228[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018851C[])(void); + D_8018851C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018820C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018820C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80188228[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80188524[])(void); + D_80188524[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80188228[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80188228[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018852C[])(void); + D_8018852C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80188228[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80188534; + extern s32 D_80188544; + extern s32 D_80188554; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80188228[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188534); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188544); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80188228[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188554); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80188564[])(void); + D_80188564[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80188228[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80188228[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80188228[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188228[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80188570[])(void); + D_80188570[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80188228[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188228[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80188228[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188228[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80188584[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80188584[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80188228[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80188228)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80188228[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188228[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80188600[])(void); + D_80188600[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80188228[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80188228)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80188610[])(void); + D_80188610[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80188228[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80188228[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80188228[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80188228[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80188228[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80188228[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80188228[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80188618[])(void); + D_80188618[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80188228[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80188228)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80188228[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80188228)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80188624[])(void); + D_80188624[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188228 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80188228[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80188228[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80188228[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80188634[])(void); + +void func_80160EA4(void *a0) { + D_80188634[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80188228[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80188228[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80188664[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80188664[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801886C8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801886C8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B40C8[]; + extern u8 D_80188694[]; + extern u8 D_801886B4[]; + extern u8 D_801B40D4[]; + extern u8 D_801B40FC[]; + extern u8 D_801B4114[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B40C8[0] = p; + func_80024054(&D_80188694, &D_801B40D4); + func_8001CE28(p, &D_801B40D4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B40C8[1] = p; + func_80024054(&D_801886B4, &D_801B40FC); + func_8001CE28(p, &D_801B40FC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B40C8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B4114, 0x84); + func_8001CE68(p, &D_801B4114); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B4114, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B40C8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B40C8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801886C8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801886C8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801886C8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801886C8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B40C8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B40C8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801886EC[])(void); + +void func_80162330(void *a0) { + D_801886EC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B4120[i] via `extern int D_801B4120[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801886F8[]; + extern s32 D_80188710; + extern u8 D_801B412C[]; + extern u8 D_801B4154[]; + extern u8 D_801B4170[]; + extern int D_801B4120[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B4120[0] = (s32)item; + func_80024054(D_801886F8, D_801B412C); + func_8001CE28(item, D_801B412C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B4120[1] = (s32)item; + func_80024054(((u8 *)&D_80188710), D_801B4154); + func_8001CE28(item, D_801B4154); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B4120[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B4170, 0x84); + func_8001CE68(item, D_801B4170); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B4170, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B4120[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B4120; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_801627E8); + + +extern void (*D_80188734[])(void); + +void func_80162834(void *a0) { + D_80188734[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80188724; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80188724, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B3984[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B3984, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B3984[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B3984, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018873C[])(void); + +void func_80163A58(void *a0) { + D_8018873C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B398C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B398C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80188790[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80188790[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80188758; +extern s16 D_8018878C; +extern s16 D_8018878A; +extern s16 D_80188788; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80188758; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018878C = 0x80; + D_8018878A = 0x80; + D_80188788 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018878C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018878C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018878C - 8; + D_8018878C = nv; + D_8018878A = nv; + D_80188788 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018879C[])(void); + +void func_80164BA0(void *a0) { + D_8018879C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B4180; +extern u8 D_801B4181; +extern u8 D_801B4182; +extern u8 D_801B4183; +extern u8 D_801B4184; +extern u8 D_801B4185; +extern u8 D_801B4186; +extern u8 D_801B4187; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B4180; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B4181 = 0xf0; + *(u8 *)base = 0xf0; + D_801B4182 = 0xc0; + D_801B4186 = 0; + D_801B4185 = 0; + D_801B4184 = 0; + D_801B4187 = 0; + D_801B4183 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B4180; +extern u8 D_801B4181; +extern u8 D_801B4182; + +s32 func_80164E40(void) { + u8 *p = &D_801B4180; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B4181 != 0) { + D_801B4181 -= 0x10; + } + if (D_801B4182 != 0) { + D_801B4182 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801887AC[])(void); + +void func_80164EA4(void *a0) { + D_801887AC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B41CC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B41CC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B41C0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B41C0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B41C0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B41C0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B41C0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801887C0[]; + extern u32 D_801887E0, D_801887E4, D_801887E8, D_801887EC; + extern u32 D_801887E0, D_801887E4, D_801887E8, D_801887EC; + extern u32 D_801887E0, D_801887E4, D_801887E8, D_801887EC; + extern u32 D_801887E0, D_801887E4, D_801887E8, D_801887EC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801887C0[0x00], p); + ApplyMatrixSV(mat, &D_801887C0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801887C0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801887C0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801887E8; + *(u32 *)(prim + 0x24) = D_801887E0; + *(u32 *)(prim + 0x28) = D_801887EC; + *(u32 *)(prim + 0x2c) = D_801887E4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801887F0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801887F0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801887F0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801887F0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018886C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018886C[a1 & 0x7F]; +} + + + +extern s32 D_8018888C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018888C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80188908[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80188908[a1 & 0x7F]; +} + + + +extern u8 D_80188928[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80188928[a1 & 0x7F]; +} + + + +extern u8 D_80188948[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80188948[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80188968[])(void); + D_80188968[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801889E4[])(void); + +void func_80165AC8(void) { + D_801889E4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80188A60[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80188A60[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B3994; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B3994, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80188A6C[])(void); + +void func_80166018(void *a0) { + D_80188A6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80188A74[])(void); + +void func_801663FC(void *a0) { + D_80188A74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80188B3C[])(void); + +void func_80166618(void *a0) { + D_80188B3C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80188B4C[])(void); + +void func_80166654(void *a0) { + D_80188B4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B4240[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B4240[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B4240). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B4240[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B4240)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B4240[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B4240[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80188A90[]; + extern u8 D_80188A7C[]; + extern u8 D_80188AA4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80188A90; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80188A7C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80188AA4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80167714); + + +extern void (*D_80188B5C[])(void); + +void func_801678B4(void *a0) { + D_80188B5C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80188B68[])(void); + +void func_80167A9C(void *a0) { + D_80188B68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80188C74; + extern u8 D_80188C88[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80188C74); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188C88; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80188AC8[]; +extern u8 D_80188ADC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80188AC8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80188ADC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80188B80[])(void); + +void func_80168744(void *a0) { + D_80188B80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80188B70 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80188B70[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80188B70; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80188B88[])(void); + +void func_801689D8(void *a0) { + D_80188B88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80188B90[])(void); + +void func_80168AA8(void *a0) { + D_80188B90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80188B98[])(void); + +void func_80168D58(void *a0) { + D_80188B98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80188BA0[])(void); + +void func_8016901C(void *a0) { + D_80188BA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_007/nonmatchings/ov_SC04_007_jr_8015C32C", func_80169228); + + +extern void (*D_80188BA8[])(void); + +void func_801693CC(void *a0) { + D_80188BA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80188BB0[])(void); + +void func_80169830(void *a0) { + D_80188BB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80188C64[])(void); + +void func_80169B80(void *a0) { + D_80188C64[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80188BB8[]; + extern u8 D_80188C28[]; + extern u8 D_80188C58[]; + extern u8 D_801B5A48[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80188C58, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80188BB8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B5A48; + RotMatrixYXZ(rot, D_801B5A48); + func_80048D9C(D_801B5A48, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80188C28); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80188C6C[])(void); + +void func_80169F00(void *a0) { + D_80188C6C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80188C1C[]; +extern char D_80188BDC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80188C1C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188BDC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80188CA4[])(void); + +void func_8016A020(void *a0) { + D_80188CA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80188C74; + extern u8 D_80188C88[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80188C74); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188C88; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80188CB0[])(void); + +void func_8016A700(void *a0) { + D_80188CB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80188CF8[])(void); + +void func_8016AB30(void *a0) { + D_80188CF8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_008/ov_SC04_008_jr_8015AE2C.c b/src/ov_SC04_008/ov_SC04_008_jr_8015AE2C.c index a9846207f..1505cde54 100644 --- a/src/ov_SC04_008/ov_SC04_008_jr_8015AE2C.c +++ b/src/ov_SC04_008/ov_SC04_008_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801812EC[])(void); - -void func_8015C714(void *a0) { - D_801812EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181160[])(void*); - extern int D_80181104; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181104); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181160[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181160[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181160[])(void*); - extern int D_80181104; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181104); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801812FC[])(void); - D_801812FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181160[])(struct Ent_8015CD20 *); - extern u8 D_80181114; - extern u8 D_80181304; - extern u8 D_80181314; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181160[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181114); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181304); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181314); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181160[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181334[])(void); - D_80181334[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181324; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181324 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181160[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181390; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181390, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180474[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180474; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80181398[])(void); - D_80181398[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801813A4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801813A4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801813A4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801813A4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181160[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801813A4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80181124[]; - extern u8 D_80181134[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181124); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181134); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801813D8[])(void); - D_801813D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181160[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801813E0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801813F8[])(void); - D_801813F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181160[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801813E0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181418[])(void); - D_80181418[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181160[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181160)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181428; -extern u16 D_8018142A; -extern u16 D_8018142C; -extern s32 D_80181430; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181428 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018142A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018142C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181430, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181438; - -void func_8015E588(void) { - func_8013C9C4(&D_80181438); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181160[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181160)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018144C[])(void); - D_8018144C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181160[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181160[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181454[])(void); - D_80181454[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80181144; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181144); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181160[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018145C[])(void); - D_8018145C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181160[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181160[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181464[])(void); - D_80181464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181160[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018146C; - extern s32 D_8018147C; - extern s32 D_8018148C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181160[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018146C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018147C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181160[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018148C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018149C[])(void); - D_8018149C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181160[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181160[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801814A8[])(void); - D_801814A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181160[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181160[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181160[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801814BC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801814BC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181160[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181160)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181160[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181160[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181538[])(void); - D_80181538[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181160[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181160)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181548[])(void); - D_80181548[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181160[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181160[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181160[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181160[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181160[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181160[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181160[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181550[])(void); - D_80181550[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181160[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181160)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181160[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018155C[])(void); - D_8018155C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181160 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181160[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181160[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181160[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018156C[])(void); - -void func_80160EA4(void *a0) { - D_8018156C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181160[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181160[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018159C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018159C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181600; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181600); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80190DA0[]; - extern u8 D_801815CC[]; - extern u8 D_801815EC[]; - extern u8 D_80190DAC[]; - extern u8 D_80190DD4[]; - extern u8 D_80190DEC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80190DA0[0] = p; - func_80024054(&D_801815CC, &D_80190DAC); - func_8001CE28(p, &D_80190DAC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80190DA0[1] = p; - func_80024054(&D_801815EC, &D_80190DD4); - func_8001CE28(p, &D_80190DD4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80190DA0[2] = p; - func_800242D0((s16)func_801620C4(), &D_80190DEC, 0x84); - func_8001CE68(p, &D_80190DEC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80190DEC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80190DA0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80190DA0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181600; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181600; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181600; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181600; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80190DA0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80190DA0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181624[])(void); - -void func_80162330(void *a0) { - D_80181624[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80190DF8[i] via `extern int D_80190DF8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181630[]; - extern s32 D_80181648; - extern u8 D_80190E04[]; - extern u8 D_80190E2C[]; - extern u8 D_80190E48[]; - extern int D_80190DF8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80190DF8[0] = (s32)item; - func_80024054(D_80181630, D_80190E04); - func_8001CE28(item, D_80190E04); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80190DF8[1] = (s32)item; - func_80024054(((u8 *)&D_80181648), D_80190E2C); - func_8001CE28(item, D_80190E2C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80190DF8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80190E48, 0x84); - func_8001CE68(item, D_80190E48); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80190E48, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80190DF8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80190DF8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018166C[])(void); - -void func_80162834(void *a0) { - D_8018166C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018165C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018165C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019066C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019066C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019066C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019066C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181674[])(void); - -void func_80163A58(void *a0) { - D_80181674[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80190674; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80190674; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801816C8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801816C8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181690; -extern s16 D_801816C4; -extern s16 D_801816C2; -extern s16 D_801816C0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181690; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801816C4 = 0x80; - D_801816C2 = 0x80; - D_801816C0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801816C4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801816C4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801816C4 - 8; - D_801816C4 = nv; - D_801816C2 = nv; - D_801816C0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801816D4[])(void); - -void func_80164BA0(void *a0) { - D_801816D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80190E58; -extern u8 D_80190E59; -extern u8 D_80190E5A; -extern u8 D_80190E5B; -extern u8 D_80190E5C; -extern u8 D_80190E5D; -extern u8 D_80190E5E; -extern u8 D_80190E5F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80190E58; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80190E59 = 0xf0; - *(u8 *)base = 0xf0; - D_80190E5A = 0xc0; - D_80190E5E = 0; - D_80190E5D = 0; - D_80190E5C = 0; - D_80190E5F = 0; - D_80190E5B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80190E58; -extern u8 D_80190E59; -extern u8 D_80190E5A; - -s32 func_80164E40(void) { - u8 *p = &D_80190E58; - if (*p != 0) { - *p -= 0x10; - } - if (D_80190E59 != 0) { - D_80190E59 -= 0x10; - } - if (D_80190E5A != 0) { - D_80190E5A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801816E4[])(void); - -void func_80164EA4(void *a0) { - D_801816E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80190EA4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80190EA4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80190E98[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80190E98[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80190E98[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80190E98; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80190E98; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801816F8[]; - extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; - extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; - extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; - extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801816F8[0x00], p); - ApplyMatrixSV(mat, &D_801816F8[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801816F8[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801816F8[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181720; - *(u32 *)(prim + 0x24) = D_80181718; - *(u32 *)(prim + 0x28) = D_80181724; - *(u32 *)(prim + 0x2c) = D_8018171C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181728[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181728[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181728[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181728[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801817A4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801817A4[a1 & 0x7F]; -} - - - -extern s32 D_801817C4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801817C4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181840[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181840[a1 & 0x7F]; -} - - - -extern u8 D_80181860[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80181860[a1 & 0x7F]; -} - - - -extern u8 D_80181880[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181880[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801818A0[])(void); - D_801818A0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018191C[])(void); - -void func_80165AC8(void) { - D_8018191C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181998[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181998[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019067C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019067C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801819A4[])(void); - -void func_80166018(void *a0) { - D_801819A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801819AC[])(void); - -void func_801663FC(void *a0) { - D_801819AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80181A74[])(void); - -void func_80166618(void *a0) { - D_80181A74[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181A84[])(void); - -void func_80166654(void *a0) { - D_80181A84[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80190F18[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80190F18[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80190F18). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80190F18[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80190F18)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80190F18[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80190F18[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801819C8[]; - extern u8 D_801819B4[]; - extern u8 D_801819DC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801819C8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801819B4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801819DC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80167714); - - -extern void (*D_80181A94[])(void); - -void func_801678B4(void *a0) { - D_80181A94[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181AA0[])(void); - -void func_80167A9C(void *a0) { - D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181BAC; - extern u8 D_80181BC0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181BAC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181BC0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80181A00[]; -extern u8 D_80181A14[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80181A00; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181A14; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181AB8[])(void); - -void func_80168744(void *a0) { - D_80181AB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181AA8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181AA8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181AA8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181AC0[])(void); - -void func_801689D8(void *a0) { - D_80181AC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181AC8[])(void); - -void func_80168AA8(void *a0) { - D_80181AC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181AD0[])(void); - -void func_80168D58(void *a0) { - D_80181AD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181AD8[])(void); - -void func_8016901C(void *a0) { - D_80181AD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015AE2C", func_80169228); - - -extern void (*D_80181AE0[])(void); - -void func_801693CC(void *a0) { - D_80181AE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181AE8[])(void); - -void func_80169830(void *a0) { - D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181B9C[])(void); - -void func_80169B80(void *a0) { - D_80181B9C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181AF0[]; - extern u8 D_80181B60[]; - extern u8 D_80181B90[]; - extern u8 D_80193378[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181B90, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181AF0[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80193378; - RotMatrixYXZ(rot, D_80193378); - func_80048D9C(D_80193378, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181B60); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181BA4[])(void); - -void func_80169F00(void *a0) { - D_80181BA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80181B54[]; -extern char D_80181B14[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80181B54, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181B14); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181BDC[])(void); - -void func_8016A020(void *a0) { - D_80181BDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181BAC; - extern u8 D_80181BC0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181BAC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181BC0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181BE8[])(void); - -void func_8016A700(void *a0) { - D_80181BE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80181C30[])(void); - -void func_8016AB30(void *a0) { - D_80181C30[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c b/src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c new file mode 100644 index 000000000..444bc21ec --- /dev/null +++ b/src/ov_SC04_008/ov_SC04_008_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180FFC; +extern u8 D_80180F6C; +extern u8 D_80180F48; +extern u8 D_80180F24; +extern u8 D_80180FD8; +extern u8 D_80180FB4; +extern u8 D_80180F90; +extern u8 D_80180F00; +extern void func_80145934(void); +extern u8 D_8018108C; +extern u8 D_80181068; +extern u8 D_80181044; +extern u8 D_80181020; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180484[]; +extern unsigned char D_801804B4[]; +extern unsigned char D_80180504[]; +extern unsigned char D_80180534[]; +extern unsigned char D_80180564[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801805B4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018067C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180704[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018070C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80190D48; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_80190D4C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018073C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801807E4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180808[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801807F8; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018081C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180828[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180838[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80180850[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180840; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80180864[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80180880[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80180870; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80180894[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801808A8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801808BC; +extern void (*D_801808E4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801808C4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80180930[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80180934[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180D98[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180DA8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80190D80; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180DD0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180DB0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180DC0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180E10[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180E18[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180DE4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80180E24[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180DF4; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80190D88; +extern s32 D_80190D94; +extern s32 D_80190D98; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180E60[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80180E34[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80190D90; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801810B0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180ED0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181154[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801812A8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801810C4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801812B0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801810D4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801810F4; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801812B8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801812E0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181160[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801812EC[])(void); + +void func_8015C714(void *a0) { + D_801812EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181160[])(void*); + extern int D_80181104; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181104); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181160[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181160[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181160[])(void*); + extern int D_80181104; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181104); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801812FC[])(void); + D_801812FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181160[])(struct Ent_8015CD20 *); + extern u8 D_80181114; + extern u8 D_80181304; + extern u8 D_80181314; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181160[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181114); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181304); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181314); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181160[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181334[])(void); + D_80181334[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181324; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181324 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181160[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181390; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181390, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180474[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180474; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80181398[])(void); + D_80181398[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801813A4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801813A4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801813A4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801813A4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181160[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801813A4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80181124[]; + extern u8 D_80181134[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181124); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181134); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801813D8[])(void); + D_801813D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181160[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801813E0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801813F8[])(void); + D_801813F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181160[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801813E0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181418[])(void); + D_80181418[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181160[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181160)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181428; +extern u16 D_8018142A; +extern u16 D_8018142C; +extern s32 D_80181430; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181428 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018142A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018142C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181430, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181438; + +void func_8015E588(void) { + func_8013C9C4(&D_80181438); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181160[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181160)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018144C[])(void); + D_8018144C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181160[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181160[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181454[])(void); + D_80181454[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80181144; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181144); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181160[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018145C[])(void); + D_8018145C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181160[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181160[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181464[])(void); + D_80181464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181160[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018146C; + extern s32 D_8018147C; + extern s32 D_8018148C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181160[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018146C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018147C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018148C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018149C[])(void); + D_8018149C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181160[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181160[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801814A8[])(void); + D_801814A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181160[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181160[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181160[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801814BC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801814BC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181160[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181160)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181160[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181160[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181538[])(void); + D_80181538[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181160[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181160)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181548[])(void); + D_80181548[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181160[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181160[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181160[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181160[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181160[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181160[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181160[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181550[])(void); + D_80181550[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181160[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181160)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181160[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018155C[])(void); + D_8018155C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181160 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181160[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181160[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181160[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018156C[])(void); + +void func_80160EA4(void *a0) { + D_8018156C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181160[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181160[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018159C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018159C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181600; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181600); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80190DA0[]; + extern u8 D_801815CC[]; + extern u8 D_801815EC[]; + extern u8 D_80190DAC[]; + extern u8 D_80190DD4[]; + extern u8 D_80190DEC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80190DA0[0] = p; + func_80024054(&D_801815CC, &D_80190DAC); + func_8001CE28(p, &D_80190DAC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80190DA0[1] = p; + func_80024054(&D_801815EC, &D_80190DD4); + func_8001CE28(p, &D_80190DD4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80190DA0[2] = p; + func_800242D0((s16)func_801620C4(), &D_80190DEC, 0x84); + func_8001CE68(p, &D_80190DEC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80190DEC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80190DA0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80190DA0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181600; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181600; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181600; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181600; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80190DA0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80190DA0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181624[])(void); + +void func_80162330(void *a0) { + D_80181624[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80190DF8[i] via `extern int D_80190DF8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181630[]; + extern s32 D_80181648; + extern u8 D_80190E04[]; + extern u8 D_80190E2C[]; + extern u8 D_80190E48[]; + extern int D_80190DF8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80190DF8[0] = (s32)item; + func_80024054(D_80181630, D_80190E04); + func_8001CE28(item, D_80190E04); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80190DF8[1] = (s32)item; + func_80024054(((u8 *)&D_80181648), D_80190E2C); + func_8001CE28(item, D_80190E2C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80190DF8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80190E48, 0x84); + func_8001CE68(item, D_80190E48); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80190E48, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80190DF8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80190DF8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_801627E8); + + +extern void (*D_8018166C[])(void); + +void func_80162834(void *a0) { + D_8018166C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018165C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018165C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019066C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019066C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019066C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019066C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181674[])(void); + +void func_80163A58(void *a0) { + D_80181674[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80190674; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80190674; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801816C8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801816C8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181690; +extern s16 D_801816C4; +extern s16 D_801816C2; +extern s16 D_801816C0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181690; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801816C4 = 0x80; + D_801816C2 = 0x80; + D_801816C0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801816C4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801816C4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801816C4 - 8; + D_801816C4 = nv; + D_801816C2 = nv; + D_801816C0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801816D4[])(void); + +void func_80164BA0(void *a0) { + D_801816D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80190E58; +extern u8 D_80190E59; +extern u8 D_80190E5A; +extern u8 D_80190E5B; +extern u8 D_80190E5C; +extern u8 D_80190E5D; +extern u8 D_80190E5E; +extern u8 D_80190E5F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80190E58; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80190E59 = 0xf0; + *(u8 *)base = 0xf0; + D_80190E5A = 0xc0; + D_80190E5E = 0; + D_80190E5D = 0; + D_80190E5C = 0; + D_80190E5F = 0; + D_80190E5B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80190E58; +extern u8 D_80190E59; +extern u8 D_80190E5A; + +s32 func_80164E40(void) { + u8 *p = &D_80190E58; + if (*p != 0) { + *p -= 0x10; + } + if (D_80190E59 != 0) { + D_80190E59 -= 0x10; + } + if (D_80190E5A != 0) { + D_80190E5A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801816E4[])(void); + +void func_80164EA4(void *a0) { + D_801816E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80190EA4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80190EA4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80190E98[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80190E98[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80190E98[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80190E98; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80190E98; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801816F8[]; + extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; + extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; + extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; + extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801816F8[0x00], p); + ApplyMatrixSV(mat, &D_801816F8[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801816F8[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801816F8[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181720; + *(u32 *)(prim + 0x24) = D_80181718; + *(u32 *)(prim + 0x28) = D_80181724; + *(u32 *)(prim + 0x2c) = D_8018171C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181728[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181728[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181728[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181728[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801817A4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801817A4[a1 & 0x7F]; +} + + + +extern s32 D_801817C4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801817C4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181840[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181840[a1 & 0x7F]; +} + + + +extern u8 D_80181860[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80181860[a1 & 0x7F]; +} + + + +extern u8 D_80181880[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181880[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801818A0[])(void); + D_801818A0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018191C[])(void); + +void func_80165AC8(void) { + D_8018191C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181998[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181998[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019067C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019067C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801819A4[])(void); + +void func_80166018(void *a0) { + D_801819A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801819AC[])(void); + +void func_801663FC(void *a0) { + D_801819AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80181A74[])(void); + +void func_80166618(void *a0) { + D_80181A74[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181A84[])(void); + +void func_80166654(void *a0) { + D_80181A84[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80190F18[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80190F18[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80190F18). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80190F18[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80190F18)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80190F18[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80190F18[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801819C8[]; + extern u8 D_801819B4[]; + extern u8 D_801819DC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801819C8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801819B4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801819DC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80167714); + + +extern void (*D_80181A94[])(void); + +void func_801678B4(void *a0) { + D_80181A94[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181AA0[])(void); + +void func_80167A9C(void *a0) { + D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181BAC; + extern u8 D_80181BC0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181BAC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181BC0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80181A00[]; +extern u8 D_80181A14[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80181A00; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181A14; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181AB8[])(void); + +void func_80168744(void *a0) { + D_80181AB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181AA8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181AA8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181AA8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181AC0[])(void); + +void func_801689D8(void *a0) { + D_80181AC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181AC8[])(void); + +void func_80168AA8(void *a0) { + D_80181AC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181AD0[])(void); + +void func_80168D58(void *a0) { + D_80181AD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181AD8[])(void); + +void func_8016901C(void *a0) { + D_80181AD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_008/nonmatchings/ov_SC04_008_jr_8015C32C", func_80169228); + + +extern void (*D_80181AE0[])(void); + +void func_801693CC(void *a0) { + D_80181AE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181AE8[])(void); + +void func_80169830(void *a0) { + D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181B9C[])(void); + +void func_80169B80(void *a0) { + D_80181B9C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181AF0[]; + extern u8 D_80181B60[]; + extern u8 D_80181B90[]; + extern u8 D_80193378[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181B90, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181AF0[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80193378; + RotMatrixYXZ(rot, D_80193378); + func_80048D9C(D_80193378, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181B60); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181BA4[])(void); + +void func_80169F00(void *a0) { + D_80181BA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80181B54[]; +extern char D_80181B14[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80181B54, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181B14); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181BDC[])(void); + +void func_8016A020(void *a0) { + D_80181BDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181BAC; + extern u8 D_80181BC0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181BAC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181BC0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181BE8[])(void); + +void func_8016A700(void *a0) { + D_80181BE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80181C30[])(void); + +void func_8016AB30(void *a0) { + D_80181C30[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_009/ov_SC04_009_jr_8015AE2C.c b/src/ov_SC04_009/ov_SC04_009_jr_8015AE2C.c index 4e84b8422..8bd016d15 100644 --- a/src/ov_SC04_009/ov_SC04_009_jr_8015AE2C.c +++ b/src/ov_SC04_009/ov_SC04_009_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181318[])(void); - -void func_8015C714(void *a0) { - D_80181318[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018118C[])(void*); - extern int D_80181130; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018118C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018118C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181130); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018118C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018118C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018118C[])(void*); - extern int D_80181130; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018118C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181130); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018118C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181328[])(void); - D_80181328[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018118C[])(struct Ent_8015CD20 *); - extern u8 D_80181140; - extern u8 D_80181330; - extern u8 D_80181340; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018118C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181140); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181330); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181340); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018118C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181360[])(void); - D_80181360[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181350; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181350 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018118C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801813BC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801813BC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801804A0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801804A0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801813C4[])(void); - D_801813C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801813D0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801813D0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801813D0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801813D0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018118C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801813D0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80181150[]; - extern u8 D_80181160[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181150); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181160); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801813D0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801813D0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801813D0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80181404[])(void); - D_80181404[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018118C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018140C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181424[])(void); - D_80181424[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018118C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018140C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181444[])(void); - D_80181444[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018118C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018118C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181454; -extern u16 D_80181456; -extern u16 D_80181458; -extern s32 D_8018145C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181454 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80181456 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181458 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018145C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181464; - -void func_8015E588(void) { - func_8013C9C4(&D_80181464); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018118C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018118C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181478[])(void); - D_80181478[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018118C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018118C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181480[])(void); - D_80181480[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80181170; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181170); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018118C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181488[])(void); - D_80181488[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018118C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018118C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181490[])(void); - D_80181490[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018118C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181498; - extern s32 D_801814A8; - extern s32 D_801814B8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018118C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181498); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801814A8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018118C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801814B8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801814C8[])(void); - D_801814C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018118C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018118C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018118C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018118C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801814D4[])(void); - D_801814D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018118C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018118C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018118C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018118C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801814E8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801814E8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018118C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018118C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018118C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018118C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181564[])(void); - D_80181564[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018118C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018118C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181574[])(void); - D_80181574[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018118C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018118C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018118C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018118C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018118C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018118C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018118C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018157C[])(void); - D_8018157C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018118C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018118C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018118C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018118C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181588[])(void); - D_80181588[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018118C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018118C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018118C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018118C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181598[])(void); - -void func_80160EA4(void *a0) { - D_80181598[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018118C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018118C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801815C8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801815C8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018162C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018162C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80196FB0[]; - extern u8 D_801815F8[]; - extern u8 D_80181618[]; - extern u8 D_80196FBC[]; - extern u8 D_80196FE4[]; - extern u8 D_80196FFC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80196FB0[0] = p; - func_80024054(&D_801815F8, &D_80196FBC); - func_8001CE28(p, &D_80196FBC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80196FB0[1] = p; - func_80024054(&D_80181618, &D_80196FE4); - func_8001CE28(p, &D_80196FE4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80196FB0[2] = p; - func_800242D0((s16)func_801620C4(), &D_80196FFC, 0x84); - func_8001CE68(p, &D_80196FFC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80196FFC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80196FB0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80196FB0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018162C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018162C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018162C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018162C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80196FB0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80196FB0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181650[])(void); - -void func_80162330(void *a0) { - D_80181650[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80197008[i] via `extern int D_80197008[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018165C[]; - extern s32 D_80181674; - extern u8 D_80197014[]; - extern u8 D_8019703C[]; - extern u8 D_80197058[]; - extern int D_80197008[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80197008[0] = (s32)item; - func_80024054(D_8018165C, D_80197014); - func_8001CE28(item, D_80197014); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80197008[1] = (s32)item; - func_80024054(((u8 *)&D_80181674), D_8019703C); - func_8001CE28(item, D_8019703C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80197008[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80197058, 0x84); - func_8001CE68(item, D_80197058); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80197058, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80197008[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80197008; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181698[])(void); - -void func_80162834(void *a0) { - D_80181698[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181688; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181688, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80196880[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80196880, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80196880[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80196880, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801816A0[])(void); - -void func_80163A58(void *a0) { - D_801816A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80196888; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80196888; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801816F4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801816F4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801816BC; -extern s16 D_801816F0; -extern s16 D_801816EE; -extern s16 D_801816EC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801816BC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801816F0 = 0x80; - D_801816EE = 0x80; - D_801816EC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801816F0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801816F0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801816F0 - 8; - D_801816F0 = nv; - D_801816EE = nv; - D_801816EC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181700[])(void); - -void func_80164BA0(void *a0) { - D_80181700[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80197068; -extern u8 D_80197069; -extern u8 D_8019706A; -extern u8 D_8019706B; -extern u8 D_8019706C; -extern u8 D_8019706D; -extern u8 D_8019706E; -extern u8 D_8019706F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80197068; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80197069 = 0xf0; - *(u8 *)base = 0xf0; - D_8019706A = 0xc0; - D_8019706E = 0; - D_8019706D = 0; - D_8019706C = 0; - D_8019706F = 0; - D_8019706B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80197068; -extern u8 D_80197069; -extern u8 D_8019706A; - -s32 func_80164E40(void) { - u8 *p = &D_80197068; - if (*p != 0) { - *p -= 0x10; - } - if (D_80197069 != 0) { - D_80197069 -= 0x10; - } - if (D_8019706A != 0) { - D_8019706A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181710[])(void); - -void func_80164EA4(void *a0) { - D_80181710[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801970B4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801970B4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801970A8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801970A8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801970A8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801970A8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801970A8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181724[]; - extern u32 D_80181744, D_80181748, D_8018174C, D_80181750; - extern u32 D_80181744, D_80181748, D_8018174C, D_80181750; - extern u32 D_80181744, D_80181748, D_8018174C, D_80181750; - extern u32 D_80181744, D_80181748, D_8018174C, D_80181750; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181724[0x00], p); - ApplyMatrixSV(mat, &D_80181724[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181724[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181724[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018174C; - *(u32 *)(prim + 0x24) = D_80181744; - *(u32 *)(prim + 0x28) = D_80181750; - *(u32 *)(prim + 0x2c) = D_80181748; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181754[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181754[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181754[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181754[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801817D0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801817D0[a1 & 0x7F]; -} - - - -extern s32 D_801817F0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801817F0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018186C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018186C[a1 & 0x7F]; -} - - - -extern u8 D_8018188C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018188C[a1 & 0x7F]; -} - - - -extern u8 D_801818AC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801818AC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801818CC[])(void); - D_801818CC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80181948[])(void); - -void func_80165AC8(void) { - D_80181948[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801819C4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801819C4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80196890; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80196890, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801819D0[])(void); - -void func_80166018(void *a0) { - D_801819D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801819D8[])(void); - -void func_801663FC(void *a0) { - D_801819D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80181AA0[])(void); - -void func_80166618(void *a0) { - D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181AB0[])(void); - -void func_80166654(void *a0) { - D_80181AB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80197128[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80197128[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80197128). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80197128[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80197128)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80197128[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80197128[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801819F4[]; - extern u8 D_801819E0[]; - extern u8 D_80181A08[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801819F4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801819E0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80181A08; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80167714); - - -extern void (*D_80181AC0[])(void); - -void func_801678B4(void *a0) { - D_80181AC0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181ACC[])(void); - -void func_80167A9C(void *a0) { - D_80181ACC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181BD8; - extern u8 D_80181BEC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181BD8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181BEC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80181A2C[]; -extern u8 D_80181A40[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80181A2C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181A40; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181AE4[])(void); - -void func_80168744(void *a0) { - D_80181AE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181AD4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181AD4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181AD4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181AEC[])(void); - -void func_801689D8(void *a0) { - D_80181AEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181AF4[])(void); - -void func_80168AA8(void *a0) { - D_80181AF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181AFC[])(void); - -void func_80168D58(void *a0) { - D_80181AFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181B04[])(void); - -void func_8016901C(void *a0) { - D_80181B04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015AE2C", func_80169228); - - -extern void (*D_80181B0C[])(void); - -void func_801693CC(void *a0) { - D_80181B0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181B14[])(void); - -void func_80169830(void *a0) { - D_80181B14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181BC8[])(void); - -void func_80169B80(void *a0) { - D_80181BC8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181B1C[]; - extern u8 D_80181B8C[]; - extern u8 D_80181BBC[]; - extern u8 D_80198128[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181BBC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181B1C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80198128; - RotMatrixYXZ(rot, D_80198128); - func_80048D9C(D_80198128, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181B8C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181BD0[])(void); - -void func_80169F00(void *a0) { - D_80181BD0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80181B80[]; -extern char D_80181B40[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80181B80, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181B40); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181C08[])(void); - -void func_8016A020(void *a0) { - D_80181C08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181BD8; - extern u8 D_80181BEC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181BD8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181BEC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181C14[])(void); - -void func_8016A700(void *a0) { - D_80181C14[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80181C5C[])(void); - -void func_8016AB30(void *a0) { - D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c b/src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c new file mode 100644 index 000000000..d80360cce --- /dev/null +++ b/src/ov_SC04_009/ov_SC04_009_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80181028; +extern u8 D_80180F98; +extern u8 D_80180F74; +extern u8 D_80180F50; +extern u8 D_80181004; +extern u8 D_80180FE0; +extern u8 D_80180FBC; +extern u8 D_80180F2C; +extern void func_80145934(void); +extern u8 D_801810B8; +extern u8 D_80181094; +extern u8 D_80181070; +extern u8 D_8018104C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801804B0[]; +extern unsigned char D_801804E0[]; +extern unsigned char D_80180530[]; +extern unsigned char D_80180560[]; +extern unsigned char D_80180590[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801805E0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801806A8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180730[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180738; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80196F58; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_80196F5C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180768; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180810[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180834[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180824; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180848[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180854[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180864[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018087C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018086C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80180890[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801808AC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018089C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801808C0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801808D4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801808E8; +extern void (*D_80180910[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801808F0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018095C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80180960[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180DC4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180DD4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80196F90; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180DFC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180DDC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180DEC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180E3C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180E44[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180E10; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80180E50[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180E20; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80196F98; +extern s32 D_80196FA4; +extern s32 D_80196FA8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180E8C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80180E60[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80196FA0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801810DC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180EFC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181180[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801812D4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801810F0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801812DC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80181100; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80181120; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801812E4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018130C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018118C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181318[])(void); + +void func_8015C714(void *a0) { + D_80181318[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018118C[])(void*); + extern int D_80181130; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018118C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018118C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181130); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018118C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018118C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018118C[])(void*); + extern int D_80181130; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018118C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181130); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018118C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181328[])(void); + D_80181328[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018118C[])(struct Ent_8015CD20 *); + extern u8 D_80181140; + extern u8 D_80181330; + extern u8 D_80181340; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018118C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181140); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181330); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181340); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018118C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181360[])(void); + D_80181360[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181350; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181350 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018118C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801813BC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801813BC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801804A0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801804A0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801813C4[])(void); + D_801813C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801813D0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801813D0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801813D0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801813D0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018118C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801813D0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80181150[]; + extern u8 D_80181160[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181150); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181160); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801813D0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801813D0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801813D0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80181404[])(void); + D_80181404[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018118C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018140C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181424[])(void); + D_80181424[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018118C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018140C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018140C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181444[])(void); + D_80181444[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018118C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018118C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181454; +extern u16 D_80181456; +extern u16 D_80181458; +extern s32 D_8018145C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181454 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80181456 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181458 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018145C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181464; + +void func_8015E588(void) { + func_8013C9C4(&D_80181464); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018118C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018118C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181478[])(void); + D_80181478[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018118C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018118C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181480[])(void); + D_80181480[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80181170; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181170); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018118C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181488[])(void); + D_80181488[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018118C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018118C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181490[])(void); + D_80181490[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018118C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181498; + extern s32 D_801814A8; + extern s32 D_801814B8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181498); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801814A8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018118C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801814B8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801814C8[])(void); + D_801814C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018118C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018118C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018118C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018118C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801814D4[])(void); + D_801814D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018118C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018118C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018118C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018118C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801814E8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801814E8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018118C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018118C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018118C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018118C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181564[])(void); + D_80181564[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018118C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018118C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181574[])(void); + D_80181574[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018118C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018118C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018118C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018118C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018118C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018118C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018118C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018157C[])(void); + D_8018157C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018118C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018118C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018118C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018118C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181588[])(void); + D_80181588[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018118C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018118C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018118C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018118C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181598[])(void); + +void func_80160EA4(void *a0) { + D_80181598[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018118C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018118C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801815C8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801815C8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018162C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018162C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80196FB0[]; + extern u8 D_801815F8[]; + extern u8 D_80181618[]; + extern u8 D_80196FBC[]; + extern u8 D_80196FE4[]; + extern u8 D_80196FFC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80196FB0[0] = p; + func_80024054(&D_801815F8, &D_80196FBC); + func_8001CE28(p, &D_80196FBC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80196FB0[1] = p; + func_80024054(&D_80181618, &D_80196FE4); + func_8001CE28(p, &D_80196FE4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80196FB0[2] = p; + func_800242D0((s16)func_801620C4(), &D_80196FFC, 0x84); + func_8001CE68(p, &D_80196FFC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80196FFC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80196FB0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80196FB0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018162C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018162C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018162C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018162C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80196FB0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80196FB0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181650[])(void); + +void func_80162330(void *a0) { + D_80181650[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80197008[i] via `extern int D_80197008[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018165C[]; + extern s32 D_80181674; + extern u8 D_80197014[]; + extern u8 D_8019703C[]; + extern u8 D_80197058[]; + extern int D_80197008[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80197008[0] = (s32)item; + func_80024054(D_8018165C, D_80197014); + func_8001CE28(item, D_80197014); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80197008[1] = (s32)item; + func_80024054(((u8 *)&D_80181674), D_8019703C); + func_8001CE28(item, D_8019703C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80197008[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80197058, 0x84); + func_8001CE68(item, D_80197058); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80197058, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80197008[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80197008; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_801627E8); + + +extern void (*D_80181698[])(void); + +void func_80162834(void *a0) { + D_80181698[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181688; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181688, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80196880[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80196880, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80196880[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80196880, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801816A0[])(void); + +void func_80163A58(void *a0) { + D_801816A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80196888; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80196888; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801816F4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801816F4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801816BC; +extern s16 D_801816F0; +extern s16 D_801816EE; +extern s16 D_801816EC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801816BC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801816F0 = 0x80; + D_801816EE = 0x80; + D_801816EC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801816F0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801816F0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801816F0 - 8; + D_801816F0 = nv; + D_801816EE = nv; + D_801816EC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181700[])(void); + +void func_80164BA0(void *a0) { + D_80181700[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80197068; +extern u8 D_80197069; +extern u8 D_8019706A; +extern u8 D_8019706B; +extern u8 D_8019706C; +extern u8 D_8019706D; +extern u8 D_8019706E; +extern u8 D_8019706F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80197068; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80197069 = 0xf0; + *(u8 *)base = 0xf0; + D_8019706A = 0xc0; + D_8019706E = 0; + D_8019706D = 0; + D_8019706C = 0; + D_8019706F = 0; + D_8019706B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80197068; +extern u8 D_80197069; +extern u8 D_8019706A; + +s32 func_80164E40(void) { + u8 *p = &D_80197068; + if (*p != 0) { + *p -= 0x10; + } + if (D_80197069 != 0) { + D_80197069 -= 0x10; + } + if (D_8019706A != 0) { + D_8019706A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181710[])(void); + +void func_80164EA4(void *a0) { + D_80181710[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801970B4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801970B4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801970A8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801970A8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801970A8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801970A8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801970A8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181724[]; + extern u32 D_80181744, D_80181748, D_8018174C, D_80181750; + extern u32 D_80181744, D_80181748, D_8018174C, D_80181750; + extern u32 D_80181744, D_80181748, D_8018174C, D_80181750; + extern u32 D_80181744, D_80181748, D_8018174C, D_80181750; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181724[0x00], p); + ApplyMatrixSV(mat, &D_80181724[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181724[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181724[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018174C; + *(u32 *)(prim + 0x24) = D_80181744; + *(u32 *)(prim + 0x28) = D_80181750; + *(u32 *)(prim + 0x2c) = D_80181748; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181754[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181754[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181754[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181754[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801817D0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801817D0[a1 & 0x7F]; +} + + + +extern s32 D_801817F0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801817F0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018186C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018186C[a1 & 0x7F]; +} + + + +extern u8 D_8018188C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018188C[a1 & 0x7F]; +} + + + +extern u8 D_801818AC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801818AC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801818CC[])(void); + D_801818CC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80181948[])(void); + +void func_80165AC8(void) { + D_80181948[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801819C4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801819C4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80196890; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80196890, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801819D0[])(void); + +void func_80166018(void *a0) { + D_801819D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801819D8[])(void); + +void func_801663FC(void *a0) { + D_801819D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80181AA0[])(void); + +void func_80166618(void *a0) { + D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181AB0[])(void); + +void func_80166654(void *a0) { + D_80181AB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80197128[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80197128[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80197128). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80197128[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80197128)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80197128[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80197128[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801819F4[]; + extern u8 D_801819E0[]; + extern u8 D_80181A08[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801819F4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801819E0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80181A08; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80167714); + + +extern void (*D_80181AC0[])(void); + +void func_801678B4(void *a0) { + D_80181AC0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181ACC[])(void); + +void func_80167A9C(void *a0) { + D_80181ACC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181BD8; + extern u8 D_80181BEC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181BD8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181BEC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80181A2C[]; +extern u8 D_80181A40[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80181A2C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181A40; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181AE4[])(void); + +void func_80168744(void *a0) { + D_80181AE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181AD4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181AD4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181AD4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181AEC[])(void); + +void func_801689D8(void *a0) { + D_80181AEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181AF4[])(void); + +void func_80168AA8(void *a0) { + D_80181AF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181AFC[])(void); + +void func_80168D58(void *a0) { + D_80181AFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181B04[])(void); + +void func_8016901C(void *a0) { + D_80181B04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_009/nonmatchings/ov_SC04_009_jr_8015C32C", func_80169228); + + +extern void (*D_80181B0C[])(void); + +void func_801693CC(void *a0) { + D_80181B0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181B14[])(void); + +void func_80169830(void *a0) { + D_80181B14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181BC8[])(void); + +void func_80169B80(void *a0) { + D_80181BC8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181B1C[]; + extern u8 D_80181B8C[]; + extern u8 D_80181BBC[]; + extern u8 D_80198128[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181BBC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181B1C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80198128; + RotMatrixYXZ(rot, D_80198128); + func_80048D9C(D_80198128, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181B8C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181BD0[])(void); + +void func_80169F00(void *a0) { + D_80181BD0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80181B80[]; +extern char D_80181B40[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80181B80, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181B40); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181C08[])(void); + +void func_8016A020(void *a0) { + D_80181C08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181BD8; + extern u8 D_80181BEC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181BD8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181BEC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181C14[])(void); + +void func_8016A700(void *a0) { + D_80181C14[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80181C5C[])(void); + +void func_8016AB30(void *a0) { + D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_010/ov_SC04_010_jr_8015AE2C.c b/src/ov_SC04_010/ov_SC04_010_jr_8015AE2C.c index 4c574b01c..feb718530 100644 --- a/src/ov_SC04_010/ov_SC04_010_jr_8015AE2C.c +++ b/src/ov_SC04_010/ov_SC04_010_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801809C4[])(void); - -void func_8015C714(void *a0) { - D_801809C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80180838[])(void*); - extern int D_801807DC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80180838)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80180838)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801807DC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80180838[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80180838[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80180838[])(void*); - extern int D_801807DC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80180838)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801807DC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80180838)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801809D4[])(void); - D_801809D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80180838[])(struct Ent_8015CD20 *); - extern u8 D_801807EC; - extern u8 D_801809DC; - extern u8 D_801809EC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80180838[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801807EC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801809DC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801809EC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80180838[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80180A0C[])(void); - D_80180A0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801809FC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801809FC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80180838[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80180A68; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80180A68, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8017FB4C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8017FB4C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80180A70[])(void); - D_80180A70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80180A7C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80180A7C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80180A7C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80180A7C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80180838[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80180A7C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801807FC[]; - extern u8 D_8018080C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801807FC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018080C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80180A7C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180A7C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180A7C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80180AB0[])(void); - D_80180AB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80180838[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180AB8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80180AD0[])(void); - D_80180AD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80180838[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180AB8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80180AF0[])(void); - D_80180AF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80180838[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80180838)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80180B00; -extern u16 D_80180B02; -extern u16 D_80180B04; -extern s32 D_80180B08; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80180B00 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80180B02 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80180B04 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180B08, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80180B10; - -void func_8015E588(void) { - func_8013C9C4(&D_80180B10); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80180838[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80180838)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80180B24[])(void); - D_80180B24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80180838[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80180838[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80180B2C[])(void); - D_80180B2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018081C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018081C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80180838[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80180B34[])(void); - D_80180B34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80180838[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80180838[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80180B3C[])(void); - D_80180B3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80180838[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80180B44; - extern s32 D_80180B54; - extern s32 D_80180B64; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80180838[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B44); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B54); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80180838[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B64); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80180B74[])(void); - D_80180B74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80180838[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80180838[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80180838[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80180838[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80180B80[])(void); - D_80180B80[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80180838[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80180838[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80180838[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80180838[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80180B94[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80180B94[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80180838[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80180838)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80180838[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80180838[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80180C10[])(void); - D_80180C10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80180838[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80180838)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80180C20[])(void); - D_80180C20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80180838[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80180838[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80180838[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80180838[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80180838[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80180838[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80180838[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80180C28[])(void); - D_80180C28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80180838[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80180838)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80180838[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80180838)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80180C34[])(void); - D_80180C34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80180838 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80180838[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80180838[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80180838[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80180C44[])(void); - -void func_80160EA4(void *a0) { - D_80180C44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80180838[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80180838[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80180C74[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80180C74[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80180CD8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80180CD8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8018E448[]; - extern u8 D_80180CA4[]; - extern u8 D_80180CC4[]; - extern u8 D_8018E454[]; - extern u8 D_8018E47C[]; - extern u8 D_8018E494[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8018E448[0] = p; - func_80024054(&D_80180CA4, &D_8018E454); - func_8001CE28(p, &D_8018E454); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8018E448[1] = p; - func_80024054(&D_80180CC4, &D_8018E47C); - func_8001CE28(p, &D_8018E47C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8018E448[2] = p; - func_800242D0((s16)func_801620C4(), &D_8018E494, 0x84); - func_8001CE68(p, &D_8018E494); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8018E494, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E448[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8018E448; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80180CD8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80180CD8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80180CD8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80180CD8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8018E448[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8018E448; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80180CFC[])(void); - -void func_80162330(void *a0) { - D_80180CFC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8018E4A0[i] via `extern int D_8018E4A0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80180D08[]; - extern s32 D_80180D20; - extern u8 D_8018E4AC[]; - extern u8 D_8018E4D4[]; - extern u8 D_8018E4F0[]; - extern int D_8018E4A0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8018E4A0[0] = (s32)item; - func_80024054(D_80180D08, D_8018E4AC); - func_8001CE28(item, D_8018E4AC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8018E4A0[1] = (s32)item; - func_80024054(((u8 *)&D_80180D20), D_8018E4D4); - func_8001CE28(item, D_8018E4D4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8018E4A0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8018E4F0, 0x84); - func_8001CE68(item, D_8018E4F0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8018E4F0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E4A0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8018E4A0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_801627E8); - - -extern void (*D_80180D44[])(void); - -void func_80162834(void *a0) { - D_80180D44[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80180D34; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80180D34, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8018DD0C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8018DD0C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8018DD0C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8018DD0C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80180D4C[])(void); - -void func_80163A58(void *a0) { - D_80180D4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8018DD14; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8018DD14; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80180DA0[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80180DA0[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80180D68; -extern s16 D_80180D9C; -extern s16 D_80180D9A; -extern s16 D_80180D98; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80180D68; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80180D9C = 0x80; - D_80180D9A = 0x80; - D_80180D98 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80180D9C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180D9C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80180D9C - 8; - D_80180D9C = nv; - D_80180D9A = nv; - D_80180D98 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80180DAC[])(void); - -void func_80164BA0(void *a0) { - D_80180DAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8018E500; -extern u8 D_8018E501; -extern u8 D_8018E502; -extern u8 D_8018E503; -extern u8 D_8018E504; -extern u8 D_8018E505; -extern u8 D_8018E506; -extern u8 D_8018E507; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8018E500; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8018E501 = 0xf0; - *(u8 *)base = 0xf0; - D_8018E502 = 0xc0; - D_8018E506 = 0; - D_8018E505 = 0; - D_8018E504 = 0; - D_8018E507 = 0; - D_8018E503 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8018E500; -extern u8 D_8018E501; -extern u8 D_8018E502; - -s32 func_80164E40(void) { - u8 *p = &D_8018E500; - if (*p != 0) { - *p -= 0x10; - } - if (D_8018E501 != 0) { - D_8018E501 -= 0x10; - } - if (D_8018E502 != 0) { - D_8018E502 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80180DBC[])(void); - -void func_80164EA4(void *a0) { - D_80180DBC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8018E54C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8018E54C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8018E540[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8018E540[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8018E540[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8018E540; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8018E540; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80180DD0[]; - extern u32 D_80180DF0, D_80180DF4, D_80180DF8, D_80180DFC; - extern u32 D_80180DF0, D_80180DF4, D_80180DF8, D_80180DFC; - extern u32 D_80180DF0, D_80180DF4, D_80180DF8, D_80180DFC; - extern u32 D_80180DF0, D_80180DF4, D_80180DF8, D_80180DFC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80180DD0[0x00], p); - ApplyMatrixSV(mat, &D_80180DD0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80180DD0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80180DD0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80180DF8; - *(u32 *)(prim + 0x24) = D_80180DF0; - *(u32 *)(prim + 0x28) = D_80180DFC; - *(u32 *)(prim + 0x2c) = D_80180DF4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80180E00[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80180E00[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80180E00[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80180E00[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80180E7C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80180E7C[a1 & 0x7F]; -} - - - -extern s32 D_80180E9C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80180E9C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80180F18[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80180F18[a1 & 0x7F]; -} - - - -extern u8 D_80180F38[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80180F38[a1 & 0x7F]; -} - - - -extern u8 D_80180F58[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80180F58[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80180F78[])(void); - D_80180F78[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80180FF4[])(void); - -void func_80165AC8(void) { - D_80180FF4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181070[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181070[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8018DD1C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8018DD1C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018107C[])(void); - -void func_80166018(void *a0) { - D_8018107C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181084[])(void); - -void func_801663FC(void *a0) { - D_80181084[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018114C[])(void); - -void func_80166618(void *a0) { - D_8018114C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018115C[])(void); - -void func_80166654(void *a0) { - D_8018115C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8018E5C0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8018E5C0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018E5C0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8018E5C0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8018E5C0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8018E5C0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8018E5C0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801810A0[]; - extern u8 D_8018108C[]; - extern u8 D_801810B4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801810A0; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018108C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801810B4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80167714); - - -extern void (*D_8018116C[])(void); - -void func_801678B4(void *a0) { - D_8018116C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181178[])(void); - -void func_80167A9C(void *a0) { - D_80181178[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181284; - extern u8 D_80181298[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181284); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181298; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801810D8[]; -extern u8 D_801810EC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801810D8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801810EC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181190[])(void); - -void func_80168744(void *a0) { - D_80181190[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181180 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181180[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181180; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181198[])(void); - -void func_801689D8(void *a0) { - D_80181198[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801811A0[])(void); - -void func_80168AA8(void *a0) { - D_801811A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801811A8[])(void); - -void func_80168D58(void *a0) { - D_801811A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801811B0[])(void); - -void func_8016901C(void *a0) { - D_801811B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015AE2C", func_80169228); - - -extern void (*D_801811B8[])(void); - -void func_801693CC(void *a0) { - D_801811B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801811C0[])(void); - -void func_80169830(void *a0) { - D_801811C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181274[])(void); - -void func_80169B80(void *a0) { - D_80181274[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801811C8[]; - extern u8 D_80181238[]; - extern u8 D_80181268[]; - extern u8 D_8018F600[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181268, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801811C8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8018F600; - RotMatrixYXZ(rot, D_8018F600); - func_80048D9C(D_8018F600, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181238); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018127C[])(void); - -void func_80169F00(void *a0) { - D_8018127C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018122C[]; -extern char D_801811EC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018122C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801811EC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801812B4[])(void); - -void func_8016A020(void *a0) { - D_801812B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181284; - extern u8 D_80181298[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181284); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181298; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801812C0[])(void); - -void func_8016A700(void *a0) { - D_801812C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80181308[])(void); - -void func_8016AB30(void *a0) { - D_80181308[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c b/src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c new file mode 100644 index 000000000..7d93a5c06 --- /dev/null +++ b/src/ov_SC04_010/ov_SC04_010_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801806D4; +extern u8 D_80180644; +extern u8 D_80180620; +extern u8 D_801805FC; +extern u8 D_801806B0; +extern u8 D_8018068C; +extern u8 D_80180668; +extern u8 D_801805D8; +extern void func_80145934(void); +extern u8 D_80180764; +extern u8 D_80180740; +extern u8 D_8018071C; +extern u8 D_801806F8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8017FB5C[]; +extern unsigned char D_8017FB8C[]; +extern unsigned char D_8017FBDC[]; +extern unsigned char D_8017FC0C[]; +extern unsigned char D_8017FC3C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8017FC8C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8017FD54[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8017FDDC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8017FDE4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8018E3F0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8018E3F4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8017FE14; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8017FEBC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8017FEE0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8017FED0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8017FEF4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8017FF00[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8017FF10[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8017FF28[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8017FF18; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8017FF3C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8017FF58[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8017FF48; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8017FF6C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8017FF80[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8017FF94; +extern void (*D_8017FFBC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8017FF9C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80180008[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018000C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180470[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180480[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8018E428; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801804A8[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180488; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180498; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801804E8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801804F0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801804BC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801804FC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801804CC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8018E430; +extern s32 D_8018E43C; +extern s32 D_8018E440; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180538[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018050C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8018E438; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80180788[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801805A8[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018082C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80180980[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018079C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80180988[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801807AC; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801807CC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80180990[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801809B8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80180838[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80180838[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80180838[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80180838[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80180838[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80180838[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80180838[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80180838[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801809C4[])(void); + +void func_8015C714(void *a0) { + D_801809C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80180838[])(void*); + extern int D_801807DC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80180838)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80180838)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801807DC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80180838[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80180838[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80180838[])(void*); + extern int D_801807DC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80180838)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801807DC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80180838)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801809D4[])(void); + D_801809D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80180838[])(struct Ent_8015CD20 *); + extern u8 D_801807EC; + extern u8 D_801809DC; + extern u8 D_801809EC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80180838[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801807EC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801809DC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801809EC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80180838[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80180A0C[])(void); + D_80180A0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801809FC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801809FC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80180838[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80180A68; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80180A68, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8017FB4C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8017FB4C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80180A70[])(void); + D_80180A70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80180A7C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80180A7C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80180A7C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80180A7C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80180838[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80180A7C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801807FC[]; + extern u8 D_8018080C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801807FC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018080C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80180A7C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180A7C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180A7C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80180AB0[])(void); + D_80180AB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80180838[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180AB8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80180AD0[])(void); + D_80180AD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80180838[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180AB8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180AB8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80180AF0[])(void); + D_80180AF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80180838[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80180838)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80180B00; +extern u16 D_80180B02; +extern u16 D_80180B04; +extern s32 D_80180B08; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80180B00 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80180B02 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80180B04 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180B08, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80180B10; + +void func_8015E588(void) { + func_8013C9C4(&D_80180B10); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80180838[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80180838)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80180B24[])(void); + D_80180B24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80180838[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80180838[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80180B2C[])(void); + D_80180B2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018081C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018081C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80180838[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80180B34[])(void); + D_80180B34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80180838[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80180838[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80180B3C[])(void); + D_80180B3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80180838[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80180B44; + extern s32 D_80180B54; + extern s32 D_80180B64; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80180838[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B44); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B54); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80180838[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180B64); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80180B74[])(void); + D_80180B74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80180838[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80180838[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80180838[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80180838[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80180B80[])(void); + D_80180B80[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80180838[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80180838[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80180838[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80180838[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80180B94[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80180B94[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80180838[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80180838)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80180838[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80180838[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80180C10[])(void); + D_80180C10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80180838[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80180838)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80180C20[])(void); + D_80180C20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80180838[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80180838[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80180838[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80180838[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80180838[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80180838[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80180838[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80180C28[])(void); + D_80180C28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80180838[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80180838)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80180838[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80180838)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80180C34[])(void); + D_80180C34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80180838 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80180838[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80180838[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80180838[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80180C44[])(void); + +void func_80160EA4(void *a0) { + D_80180C44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80180838[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80180838[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80180C74[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80180C74[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80180CD8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80180CD8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8018E448[]; + extern u8 D_80180CA4[]; + extern u8 D_80180CC4[]; + extern u8 D_8018E454[]; + extern u8 D_8018E47C[]; + extern u8 D_8018E494[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8018E448[0] = p; + func_80024054(&D_80180CA4, &D_8018E454); + func_8001CE28(p, &D_8018E454); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8018E448[1] = p; + func_80024054(&D_80180CC4, &D_8018E47C); + func_8001CE28(p, &D_8018E47C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8018E448[2] = p; + func_800242D0((s16)func_801620C4(), &D_8018E494, 0x84); + func_8001CE68(p, &D_8018E494); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8018E494, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E448[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8018E448; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80180CD8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80180CD8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80180CD8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80180CD8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8018E448[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8018E448; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80180CFC[])(void); + +void func_80162330(void *a0) { + D_80180CFC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8018E4A0[i] via `extern int D_8018E4A0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80180D08[]; + extern s32 D_80180D20; + extern u8 D_8018E4AC[]; + extern u8 D_8018E4D4[]; + extern u8 D_8018E4F0[]; + extern int D_8018E4A0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8018E4A0[0] = (s32)item; + func_80024054(D_80180D08, D_8018E4AC); + func_8001CE28(item, D_8018E4AC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8018E4A0[1] = (s32)item; + func_80024054(((u8 *)&D_80180D20), D_8018E4D4); + func_8001CE28(item, D_8018E4D4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8018E4A0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8018E4F0, 0x84); + func_8001CE68(item, D_8018E4F0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8018E4F0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E4A0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8018E4A0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_801627E8); + + +extern void (*D_80180D44[])(void); + +void func_80162834(void *a0) { + D_80180D44[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80180D34; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80180D34, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8018DD0C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8018DD0C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8018DD0C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8018DD0C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80180D4C[])(void); + +void func_80163A58(void *a0) { + D_80180D4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8018DD14; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8018DD14; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80180DA0[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80180DA0[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80180D68; +extern s16 D_80180D9C; +extern s16 D_80180D9A; +extern s16 D_80180D98; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80180D68; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80180D9C = 0x80; + D_80180D9A = 0x80; + D_80180D98 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80180D9C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180D9C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80180D9C - 8; + D_80180D9C = nv; + D_80180D9A = nv; + D_80180D98 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80180DAC[])(void); + +void func_80164BA0(void *a0) { + D_80180DAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8018E500; +extern u8 D_8018E501; +extern u8 D_8018E502; +extern u8 D_8018E503; +extern u8 D_8018E504; +extern u8 D_8018E505; +extern u8 D_8018E506; +extern u8 D_8018E507; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8018E500; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8018E501 = 0xf0; + *(u8 *)base = 0xf0; + D_8018E502 = 0xc0; + D_8018E506 = 0; + D_8018E505 = 0; + D_8018E504 = 0; + D_8018E507 = 0; + D_8018E503 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8018E500; +extern u8 D_8018E501; +extern u8 D_8018E502; + +s32 func_80164E40(void) { + u8 *p = &D_8018E500; + if (*p != 0) { + *p -= 0x10; + } + if (D_8018E501 != 0) { + D_8018E501 -= 0x10; + } + if (D_8018E502 != 0) { + D_8018E502 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80180DBC[])(void); + +void func_80164EA4(void *a0) { + D_80180DBC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8018E54C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8018E54C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8018E540[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8018E540[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8018E540[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8018E540; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8018E540; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80180DD0[]; + extern u32 D_80180DF0, D_80180DF4, D_80180DF8, D_80180DFC; + extern u32 D_80180DF0, D_80180DF4, D_80180DF8, D_80180DFC; + extern u32 D_80180DF0, D_80180DF4, D_80180DF8, D_80180DFC; + extern u32 D_80180DF0, D_80180DF4, D_80180DF8, D_80180DFC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80180DD0[0x00], p); + ApplyMatrixSV(mat, &D_80180DD0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80180DD0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80180DD0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80180DF8; + *(u32 *)(prim + 0x24) = D_80180DF0; + *(u32 *)(prim + 0x28) = D_80180DFC; + *(u32 *)(prim + 0x2c) = D_80180DF4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80180E00[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80180E00[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80180E00[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80180E00[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80180E7C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80180E7C[a1 & 0x7F]; +} + + + +extern s32 D_80180E9C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80180E9C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80180F18[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80180F18[a1 & 0x7F]; +} + + + +extern u8 D_80180F38[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80180F38[a1 & 0x7F]; +} + + + +extern u8 D_80180F58[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80180F58[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80180F78[])(void); + D_80180F78[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80180FF4[])(void); + +void func_80165AC8(void) { + D_80180FF4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181070[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181070[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8018DD1C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8018DD1C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018107C[])(void); + +void func_80166018(void *a0) { + D_8018107C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181084[])(void); + +void func_801663FC(void *a0) { + D_80181084[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018114C[])(void); + +void func_80166618(void *a0) { + D_8018114C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018115C[])(void); + +void func_80166654(void *a0) { + D_8018115C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8018E5C0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8018E5C0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018E5C0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8018E5C0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8018E5C0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8018E5C0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8018E5C0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801810A0[]; + extern u8 D_8018108C[]; + extern u8 D_801810B4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801810A0; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018108C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801810B4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80167714); + + +extern void (*D_8018116C[])(void); + +void func_801678B4(void *a0) { + D_8018116C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181178[])(void); + +void func_80167A9C(void *a0) { + D_80181178[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181284; + extern u8 D_80181298[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181284); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181298; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801810D8[]; +extern u8 D_801810EC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801810D8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801810EC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181190[])(void); + +void func_80168744(void *a0) { + D_80181190[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181180 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181180[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181180; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181198[])(void); + +void func_801689D8(void *a0) { + D_80181198[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801811A0[])(void); + +void func_80168AA8(void *a0) { + D_801811A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801811A8[])(void); + +void func_80168D58(void *a0) { + D_801811A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801811B0[])(void); + +void func_8016901C(void *a0) { + D_801811B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_010/nonmatchings/ov_SC04_010_jr_8015C32C", func_80169228); + + +extern void (*D_801811B8[])(void); + +void func_801693CC(void *a0) { + D_801811B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801811C0[])(void); + +void func_80169830(void *a0) { + D_801811C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181274[])(void); + +void func_80169B80(void *a0) { + D_80181274[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801811C8[]; + extern u8 D_80181238[]; + extern u8 D_80181268[]; + extern u8 D_8018F600[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181268, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801811C8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8018F600; + RotMatrixYXZ(rot, D_8018F600); + func_80048D9C(D_8018F600, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181238); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018127C[])(void); + +void func_80169F00(void *a0) { + D_8018127C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018122C[]; +extern char D_801811EC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018122C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801811EC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801812B4[])(void); + +void func_8016A020(void *a0) { + D_801812B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181284; + extern u8 D_80181298[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181284); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181298; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801812C0[])(void); + +void func_8016A700(void *a0) { + D_801812C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80181308[])(void); + +void func_8016AB30(void *a0) { + D_80181308[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_011/ov_SC04_011_jr_8015AE2C.c b/src/ov_SC04_011/ov_SC04_011_jr_8015AE2C.c index 2f785c42d..115eb7ecb 100644 --- a/src/ov_SC04_011/ov_SC04_011_jr_8015AE2C.c +++ b/src/ov_SC04_011/ov_SC04_011_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80192C54[])(void); - -void func_8015C714(void *a0) { - D_80192C54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80192AC8[])(void*); - extern int D_80192A6C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80192AC8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80192AC8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80192A6C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80192AC8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80192AC8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80192AC8[])(void*); - extern int D_80192A6C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80192AC8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80192A6C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80192AC8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80192C64[])(void); - D_80192C64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80192AC8[])(struct Ent_8015CD20 *); - extern u8 D_80192A7C; - extern u8 D_80192C6C; - extern u8 D_80192C7C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80192AC8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80192A7C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80192C6C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80192C7C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80192AC8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80192C9C[])(void); - D_80192C9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80192C8C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80192C8C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80192AC8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80192CF8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80192CF8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80191DDC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80191DDC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80192D00[])(void); - D_80192D00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80192D0C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80192D0C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80192D0C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80192D0C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80192AC8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80192D0C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80192A8C[]; - extern u8 D_80192A9C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80192A8C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80192A9C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80192D0C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80192D0C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80192D0C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80192D40[])(void); - D_80192D40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80192AC8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80192D48[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80192D60[])(void); - D_80192D60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80192AC8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80192D48[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80192D80[])(void); - D_80192D80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80192AC8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80192AC8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80192D90; -extern u16 D_80192D92; -extern u16 D_80192D94; -extern s32 D_80192D98; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80192D90 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80192D92 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80192D94 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80192D98, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80192DA0; - -void func_8015E588(void) { - func_8013C9C4(&D_80192DA0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80192AC8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80192AC8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80192DB4[])(void); - D_80192DB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80192AC8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80192AC8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80192DBC[])(void); - D_80192DBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80192AAC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80192AAC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80192AC8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80192DC4[])(void); - D_80192DC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80192AC8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80192AC8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80192DCC[])(void); - D_80192DCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80192AC8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80192DD4; - extern s32 D_80192DE4; - extern s32 D_80192DF4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80192AC8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80192DD4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80192DE4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80192AC8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80192DF4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80192E04[])(void); - D_80192E04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80192AC8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80192AC8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80192AC8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80192AC8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80192E10[])(void); - D_80192E10[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80192AC8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80192AC8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80192AC8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80192AC8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80192E24[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80192E24[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80192AC8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80192AC8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80192AC8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80192AC8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80192EA0[])(void); - D_80192EA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80192AC8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80192AC8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80192EB0[])(void); - D_80192EB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80192AC8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80192AC8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80192AC8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80192AC8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80192AC8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80192AC8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80192AC8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80192EB8[])(void); - D_80192EB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80192AC8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80192AC8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80192AC8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80192AC8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80192EC4[])(void); - D_80192EC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80192AC8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80192AC8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80192AC8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80192AC8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80192ED4[])(void); - -void func_80160EA4(void *a0) { - D_80192ED4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80192AC8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80192AC8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80192F04[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80192F04[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80192F68; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80192F68); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801EDBB0[]; - extern u8 D_80192F34[]; - extern u8 D_80192F54[]; - extern u8 D_801EDBBC[]; - extern u8 D_801EDBE4[]; - extern u8 D_801EDBFC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801EDBB0[0] = p; - func_80024054(&D_80192F34, &D_801EDBBC); - func_8001CE28(p, &D_801EDBBC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801EDBB0[1] = p; - func_80024054(&D_80192F54, &D_801EDBE4); - func_8001CE28(p, &D_801EDBE4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801EDBB0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801EDBFC, 0x84); - func_8001CE68(p, &D_801EDBFC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801EDBFC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EDBB0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801EDBB0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80192F68; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80192F68; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80192F68; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80192F68; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801EDBB0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801EDBB0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80192F8C[])(void); - -void func_80162330(void *a0) { - D_80192F8C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801EDC08[i] via `extern int D_801EDC08[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80192F98[]; - extern s32 D_80192FB0; - extern u8 D_801EDC14[]; - extern u8 D_801EDC3C[]; - extern u8 D_801EDC58[]; - extern int D_801EDC08[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801EDC08[0] = (s32)item; - func_80024054(D_80192F98, D_801EDC14); - func_8001CE28(item, D_801EDC14); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801EDC08[1] = (s32)item; - func_80024054(((u8 *)&D_80192FB0), D_801EDC3C); - func_8001CE28(item, D_801EDC3C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801EDC08[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801EDC58, 0x84); - func_8001CE68(item, D_801EDC58); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801EDC58, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EDC08[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801EDC08; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_801627E8); - - -extern void (*D_80192FD4[])(void); - -void func_80162834(void *a0) { - D_80192FD4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80192FC4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80192FC4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801ED2A8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801ED2A8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801ED2A8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801ED2A8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80192FDC[])(void); - -void func_80163A58(void *a0) { - D_80192FDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801ED2B0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801ED2B0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80193030[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80193030[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80192FF8; -extern s16 D_8019302C; -extern s16 D_8019302A; -extern s16 D_80193028; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80192FF8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8019302C = 0x80; - D_8019302A = 0x80; - D_80193028 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8019302C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8019302C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8019302C - 8; - D_8019302C = nv; - D_8019302A = nv; - D_80193028 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8019303C[])(void); - -void func_80164BA0(void *a0) { - D_8019303C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801EDC68; -extern u8 D_801EDC69; -extern u8 D_801EDC6A; -extern u8 D_801EDC6B; -extern u8 D_801EDC6C; -extern u8 D_801EDC6D; -extern u8 D_801EDC6E; -extern u8 D_801EDC6F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801EDC68; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801EDC69 = 0xf0; - *(u8 *)base = 0xf0; - D_801EDC6A = 0xc0; - D_801EDC6E = 0; - D_801EDC6D = 0; - D_801EDC6C = 0; - D_801EDC6F = 0; - D_801EDC6B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801EDC68; -extern u8 D_801EDC69; -extern u8 D_801EDC6A; - -s32 func_80164E40(void) { - u8 *p = &D_801EDC68; - if (*p != 0) { - *p -= 0x10; - } - if (D_801EDC69 != 0) { - D_801EDC69 -= 0x10; - } - if (D_801EDC6A != 0) { - D_801EDC6A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8019304C[])(void); - -void func_80164EA4(void *a0) { - D_8019304C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801EDCB4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801EDCB4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801EDCA8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801EDCA8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801EDCA8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801EDCA8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801EDCA8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80193060[]; - extern u32 D_80193080, D_80193084, D_80193088, D_8019308C; - extern u32 D_80193080, D_80193084, D_80193088, D_8019308C; - extern u32 D_80193080, D_80193084, D_80193088, D_8019308C; - extern u32 D_80193080, D_80193084, D_80193088, D_8019308C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80193060[0x00], p); - ApplyMatrixSV(mat, &D_80193060[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80193060[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80193060[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80193088; - *(u32 *)(prim + 0x24) = D_80193080; - *(u32 *)(prim + 0x28) = D_8019308C; - *(u32 *)(prim + 0x2c) = D_80193084; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80193090[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80193090[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80193090[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80193090[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8019310C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8019310C[a1 & 0x7F]; -} - - - -extern s32 D_8019312C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8019312C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801931A8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801931A8[a1 & 0x7F]; -} - - - -extern u8 D_801931C8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801931C8[a1 & 0x7F]; -} - - - -extern u8 D_801931E8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801931E8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80193208[])(void); - D_80193208[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80193284[])(void); - -void func_80165AC8(void) { - D_80193284[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80193300[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80193300[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801ED2B8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801ED2B8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8019330C[])(void); - -void func_80166018(void *a0) { - D_8019330C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80193314[])(void); - -void func_801663FC(void *a0) { - D_80193314[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801933DC[])(void); - -void func_80166618(void *a0) { - D_801933DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801933EC[])(void); - -void func_80166654(void *a0) { - D_801933EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801EDD28[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801EDD28[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EDD28). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801EDD28[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801EDD28)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801EDD28[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801EDD28[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80193330[]; - extern u8 D_8019331C[]; - extern u8 D_80193344[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80193330; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8019331C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80193344; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80167714); - - -extern void (*D_801933FC[])(void); - -void func_801678B4(void *a0) { - D_801933FC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80193408[])(void); - -void func_80167A9C(void *a0) { - D_80193408[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80193514; - extern u8 D_80193528[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80193514); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80193528; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80193368[]; -extern u8 D_8019337C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80193368; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8019337C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80193420[])(void); - -void func_80168744(void *a0) { - D_80193420[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80193410 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80193410[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80193410; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80193428[])(void); - -void func_801689D8(void *a0) { - D_80193428[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80193430[])(void); - -void func_80168AA8(void *a0) { - D_80193430[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80193438[])(void); - -void func_80168D58(void *a0) { - D_80193438[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80193440[])(void); - -void func_8016901C(void *a0) { - D_80193440[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015AE2C", func_80169228); - - -extern void (*D_80193448[])(void); - -void func_801693CC(void *a0) { - D_80193448[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80193450[])(void); - -void func_80169830(void *a0) { - D_80193450[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80193504[])(void); - -void func_80169B80(void *a0) { - D_80193504[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80193458[]; - extern u8 D_801934C8[]; - extern u8 D_801934F8[]; - extern u8 D_801F1568[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801934F8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80193458[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801F1568; - RotMatrixYXZ(rot, D_801F1568); - func_80048D9C(D_801F1568, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801934C8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8019350C[])(void); - -void func_80169F00(void *a0) { - D_8019350C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801934BC[]; -extern char D_8019347C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801934BC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8019347C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80193544[])(void); - -void func_8016A020(void *a0) { - D_80193544[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80193514; - extern u8 D_80193528[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80193514); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80193528; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80193550[])(void); - -void func_8016A700(void *a0) { - D_80193550[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80193598[])(void); - -void func_8016AB30(void *a0) { - D_80193598[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c b/src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c new file mode 100644 index 000000000..5c29e47e6 --- /dev/null +++ b/src/ov_SC04_011/ov_SC04_011_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80192964; +extern u8 D_801928D4; +extern u8 D_801928B0; +extern u8 D_8019288C; +extern u8 D_80192940; +extern u8 D_8019291C; +extern u8 D_801928F8; +extern u8 D_80192868; +extern void func_80145934(void); +extern u8 D_801929F4; +extern u8 D_801929D0; +extern u8 D_801929AC; +extern u8 D_80192988; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80191DEC[]; +extern unsigned char D_80191E1C[]; +extern unsigned char D_80191E6C[]; +extern unsigned char D_80191E9C[]; +extern unsigned char D_80191ECC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80191F1C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80191FE4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8019206C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80192074; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801EDB58; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801EDB5C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801920A4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8019214C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80192170[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80192160; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80192184[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80192190[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801921A0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801921B8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801921A8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801921CC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801921E8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801921D8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801921FC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80192210[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80192224; +extern void (*D_8019224C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8019222C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80192298[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8019229C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80192700[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80192710[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801EDB90; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80192738[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80192718; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80192728; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80192778[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80192780[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8019274C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8019278C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8019275C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801EDB98; +extern s32 D_801EDBA4; +extern s32 D_801EDBA8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801927C8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8019279C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801EDBA0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80192A18[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80192838[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80192ABC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80192C10[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80192A2C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80192C18[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80192A3C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80192A5C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80192C20[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80192C48[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80192AC8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80192C54[])(void); + +void func_8015C714(void *a0) { + D_80192C54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80192AC8[])(void*); + extern int D_80192A6C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80192AC8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80192AC8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80192A6C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80192AC8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80192AC8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80192AC8[])(void*); + extern int D_80192A6C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80192AC8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80192A6C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80192AC8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80192C64[])(void); + D_80192C64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80192AC8[])(struct Ent_8015CD20 *); + extern u8 D_80192A7C; + extern u8 D_80192C6C; + extern u8 D_80192C7C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80192AC8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80192A7C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80192C6C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80192C7C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80192AC8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80192C9C[])(void); + D_80192C9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80192C8C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80192C8C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80192AC8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80192CF8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80192CF8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80191DDC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80191DDC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80192D00[])(void); + D_80192D00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80192D0C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80192D0C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80192D0C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80192D0C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80192AC8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80192D0C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80192A8C[]; + extern u8 D_80192A9C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80192A8C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80192A9C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80192D0C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80192D0C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80192D0C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80192D40[])(void); + D_80192D40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80192AC8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80192D48[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80192D60[])(void); + D_80192D60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80192AC8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80192D48[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80192D48[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80192D80[])(void); + D_80192D80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80192AC8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80192AC8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80192D90; +extern u16 D_80192D92; +extern u16 D_80192D94; +extern s32 D_80192D98; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80192D90 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80192D92 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80192D94 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80192D98, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80192DA0; + +void func_8015E588(void) { + func_8013C9C4(&D_80192DA0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80192AC8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80192AC8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80192DB4[])(void); + D_80192DB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80192AC8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80192AC8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80192DBC[])(void); + D_80192DBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80192AAC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80192AAC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80192AC8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80192DC4[])(void); + D_80192DC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80192AC8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80192AC8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80192DCC[])(void); + D_80192DCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80192AC8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80192DD4; + extern s32 D_80192DE4; + extern s32 D_80192DF4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80192DD4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80192DE4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80192AC8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80192DF4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80192E04[])(void); + D_80192E04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80192AC8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80192AC8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80192AC8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80192AC8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80192E10[])(void); + D_80192E10[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80192AC8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80192AC8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80192AC8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80192AC8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80192E24[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80192E24[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80192AC8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80192AC8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80192AC8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80192AC8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80192EA0[])(void); + D_80192EA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80192AC8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80192AC8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80192EB0[])(void); + D_80192EB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80192AC8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80192AC8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80192AC8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80192AC8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80192AC8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80192AC8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80192AC8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80192EB8[])(void); + D_80192EB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80192AC8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80192AC8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80192AC8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80192AC8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80192EC4[])(void); + D_80192EC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80192AC8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80192AC8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80192AC8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80192AC8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80192ED4[])(void); + +void func_80160EA4(void *a0) { + D_80192ED4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80192AC8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80192AC8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80192F04[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80192F04[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80192F68; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80192F68); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801EDBB0[]; + extern u8 D_80192F34[]; + extern u8 D_80192F54[]; + extern u8 D_801EDBBC[]; + extern u8 D_801EDBE4[]; + extern u8 D_801EDBFC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801EDBB0[0] = p; + func_80024054(&D_80192F34, &D_801EDBBC); + func_8001CE28(p, &D_801EDBBC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801EDBB0[1] = p; + func_80024054(&D_80192F54, &D_801EDBE4); + func_8001CE28(p, &D_801EDBE4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801EDBB0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801EDBFC, 0x84); + func_8001CE68(p, &D_801EDBFC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801EDBFC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EDBB0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801EDBB0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80192F68; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80192F68; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80192F68; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80192F68; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801EDBB0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801EDBB0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80192F8C[])(void); + +void func_80162330(void *a0) { + D_80192F8C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801EDC08[i] via `extern int D_801EDC08[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80192F98[]; + extern s32 D_80192FB0; + extern u8 D_801EDC14[]; + extern u8 D_801EDC3C[]; + extern u8 D_801EDC58[]; + extern int D_801EDC08[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801EDC08[0] = (s32)item; + func_80024054(D_80192F98, D_801EDC14); + func_8001CE28(item, D_801EDC14); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801EDC08[1] = (s32)item; + func_80024054(((u8 *)&D_80192FB0), D_801EDC3C); + func_8001CE28(item, D_801EDC3C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801EDC08[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801EDC58, 0x84); + func_8001CE68(item, D_801EDC58); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801EDC58, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EDC08[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801EDC08; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_801627E8); + + +extern void (*D_80192FD4[])(void); + +void func_80162834(void *a0) { + D_80192FD4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80192FC4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80192FC4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801ED2A8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801ED2A8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801ED2A8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801ED2A8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80192FDC[])(void); + +void func_80163A58(void *a0) { + D_80192FDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801ED2B0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801ED2B0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80193030[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80193030[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80192FF8; +extern s16 D_8019302C; +extern s16 D_8019302A; +extern s16 D_80193028; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80192FF8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8019302C = 0x80; + D_8019302A = 0x80; + D_80193028 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8019302C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8019302C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8019302C - 8; + D_8019302C = nv; + D_8019302A = nv; + D_80193028 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8019303C[])(void); + +void func_80164BA0(void *a0) { + D_8019303C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801EDC68; +extern u8 D_801EDC69; +extern u8 D_801EDC6A; +extern u8 D_801EDC6B; +extern u8 D_801EDC6C; +extern u8 D_801EDC6D; +extern u8 D_801EDC6E; +extern u8 D_801EDC6F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801EDC68; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801EDC69 = 0xf0; + *(u8 *)base = 0xf0; + D_801EDC6A = 0xc0; + D_801EDC6E = 0; + D_801EDC6D = 0; + D_801EDC6C = 0; + D_801EDC6F = 0; + D_801EDC6B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801EDC68; +extern u8 D_801EDC69; +extern u8 D_801EDC6A; + +s32 func_80164E40(void) { + u8 *p = &D_801EDC68; + if (*p != 0) { + *p -= 0x10; + } + if (D_801EDC69 != 0) { + D_801EDC69 -= 0x10; + } + if (D_801EDC6A != 0) { + D_801EDC6A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8019304C[])(void); + +void func_80164EA4(void *a0) { + D_8019304C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801EDCB4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801EDCB4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801EDCA8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801EDCA8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801EDCA8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801EDCA8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801EDCA8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80193060[]; + extern u32 D_80193080, D_80193084, D_80193088, D_8019308C; + extern u32 D_80193080, D_80193084, D_80193088, D_8019308C; + extern u32 D_80193080, D_80193084, D_80193088, D_8019308C; + extern u32 D_80193080, D_80193084, D_80193088, D_8019308C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80193060[0x00], p); + ApplyMatrixSV(mat, &D_80193060[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80193060[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80193060[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80193088; + *(u32 *)(prim + 0x24) = D_80193080; + *(u32 *)(prim + 0x28) = D_8019308C; + *(u32 *)(prim + 0x2c) = D_80193084; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80193090[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80193090[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80193090[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80193090[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8019310C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8019310C[a1 & 0x7F]; +} + + + +extern s32 D_8019312C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8019312C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801931A8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801931A8[a1 & 0x7F]; +} + + + +extern u8 D_801931C8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801931C8[a1 & 0x7F]; +} + + + +extern u8 D_801931E8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801931E8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80193208[])(void); + D_80193208[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80193284[])(void); + +void func_80165AC8(void) { + D_80193284[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80193300[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80193300[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801ED2B8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801ED2B8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8019330C[])(void); + +void func_80166018(void *a0) { + D_8019330C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80193314[])(void); + +void func_801663FC(void *a0) { + D_80193314[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801933DC[])(void); + +void func_80166618(void *a0) { + D_801933DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801933EC[])(void); + +void func_80166654(void *a0) { + D_801933EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801EDD28[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801EDD28[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EDD28). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801EDD28[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801EDD28)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801EDD28[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801EDD28[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80193330[]; + extern u8 D_8019331C[]; + extern u8 D_80193344[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80193330; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8019331C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80193344; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80167714); + + +extern void (*D_801933FC[])(void); + +void func_801678B4(void *a0) { + D_801933FC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80193408[])(void); + +void func_80167A9C(void *a0) { + D_80193408[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80193514; + extern u8 D_80193528[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80193514); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80193528; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80193368[]; +extern u8 D_8019337C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80193368; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8019337C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80193420[])(void); + +void func_80168744(void *a0) { + D_80193420[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80193410 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80193410[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80193410; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80193428[])(void); + +void func_801689D8(void *a0) { + D_80193428[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80193430[])(void); + +void func_80168AA8(void *a0) { + D_80193430[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80193438[])(void); + +void func_80168D58(void *a0) { + D_80193438[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80193440[])(void); + +void func_8016901C(void *a0) { + D_80193440[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_011/nonmatchings/ov_SC04_011_jr_8015C32C", func_80169228); + + +extern void (*D_80193448[])(void); + +void func_801693CC(void *a0) { + D_80193448[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80193450[])(void); + +void func_80169830(void *a0) { + D_80193450[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80193504[])(void); + +void func_80169B80(void *a0) { + D_80193504[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80193458[]; + extern u8 D_801934C8[]; + extern u8 D_801934F8[]; + extern u8 D_801F1568[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801934F8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80193458[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801F1568; + RotMatrixYXZ(rot, D_801F1568); + func_80048D9C(D_801F1568, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801934C8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8019350C[])(void); + +void func_80169F00(void *a0) { + D_8019350C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801934BC[]; +extern char D_8019347C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801934BC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8019347C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80193544[])(void); + +void func_8016A020(void *a0) { + D_80193544[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80193514; + extern u8 D_80193528[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80193514); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80193528; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80193550[])(void); + +void func_8016A700(void *a0) { + D_80193550[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80193598[])(void); + +void func_8016AB30(void *a0) { + D_80193598[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_012/ov_SC04_012_jr_8015AE2C.c b/src/ov_SC04_012/ov_SC04_012_jr_8015AE2C.c index 1472c9b23..17e3e553a 100644 --- a/src/ov_SC04_012/ov_SC04_012_jr_8015AE2C.c +++ b/src/ov_SC04_012/ov_SC04_012_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80180E28[])(void); - -void func_8015C714(void *a0) { - D_80180E28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80180C9C[])(void*); - extern int D_80180C40; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80180C9C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80180C9C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180C40); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80180C9C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80180C9C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80180C9C[])(void*); - extern int D_80180C40; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80180C9C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180C40); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80180C9C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80180E38[])(void); - D_80180E38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80180C9C[])(struct Ent_8015CD20 *); - extern u8 D_80180C50; - extern u8 D_80180E40; - extern u8 D_80180E50; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80180C9C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180C50); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180E40); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180E50); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80180C9C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80180E70[])(void); - D_80180E70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80180E60; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80180E60 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80180C9C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80180ECC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80180ECC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8017FFB0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8017FFB0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80180ED4[])(void); - D_80180ED4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80180EE0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80180EE0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80180EE0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80180EE0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80180C9C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80180EE0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80180C60[]; - extern u8 D_80180C70[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80180C60); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80180C70); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80180EE0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180EE0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180EE0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80180F14[])(void); - D_80180F14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80180C9C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180F1C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80180F34[])(void); - D_80180F34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80180C9C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180F1C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80180F54[])(void); - D_80180F54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80180C9C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80180C9C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80180F64; -extern u16 D_80180F66; -extern u16 D_80180F68; -extern s32 D_80180F6C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80180F64 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80180F66 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80180F68 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180F6C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80180F74; - -void func_8015E588(void) { - func_8013C9C4(&D_80180F74); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80180C9C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80180C9C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80180F88[])(void); - D_80180F88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80180C9C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80180C9C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80180F90[])(void); - D_80180F90[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80180C80; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80180C80); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80180C9C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80180F98[])(void); - D_80180F98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80180C9C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80180C9C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80180FA0[])(void); - D_80180FA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80180C9C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80180FA8; - extern s32 D_80180FB8; - extern s32 D_80180FC8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80180C9C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180FA8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180FB8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80180C9C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180FC8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80180FD8[])(void); - D_80180FD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80180C9C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80180C9C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80180C9C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80180C9C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80180FE4[])(void); - D_80180FE4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80180C9C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80180C9C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80180C9C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80180C9C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80180FF8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80180FF8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80180C9C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80180C9C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80180C9C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80180C9C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181074[])(void); - D_80181074[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80180C9C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80180C9C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181084[])(void); - D_80181084[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80180C9C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80180C9C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80180C9C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80180C9C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80180C9C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80180C9C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80180C9C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018108C[])(void); - D_8018108C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80180C9C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80180C9C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80180C9C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80180C9C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181098[])(void); - D_80181098[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80180C9C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80180C9C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80180C9C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80180C9C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801810A8[])(void); - -void func_80160EA4(void *a0) { - D_801810A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80180C9C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80180C9C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801810D8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801810D8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018113C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018113C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80190B20[]; - extern u8 D_80181108[]; - extern u8 D_80181128[]; - extern u8 D_80190B2C[]; - extern u8 D_80190B54[]; - extern u8 D_80190B6C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80190B20[0] = p; - func_80024054(&D_80181108, &D_80190B2C); - func_8001CE28(p, &D_80190B2C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80190B20[1] = p; - func_80024054(&D_80181128, &D_80190B54); - func_8001CE28(p, &D_80190B54); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80190B20[2] = p; - func_800242D0((s16)func_801620C4(), &D_80190B6C, 0x84); - func_8001CE68(p, &D_80190B6C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_80190B6C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80190B20[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80190B20; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018113C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018113C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018113C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018113C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80190B20[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80190B20; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181160[])(void); - -void func_80162330(void *a0) { - D_80181160[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80190B78[i] via `extern int D_80190B78[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018116C[]; - extern s32 D_80181184; - extern u8 D_80190B84[]; - extern u8 D_80190BAC[]; - extern u8 D_80190BC8[]; - extern int D_80190B78[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80190B78[0] = (s32)item; - func_80024054(D_8018116C, D_80190B84); - func_8001CE28(item, D_80190B84); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80190B78[1] = (s32)item; - func_80024054(((u8 *)&D_80181184), D_80190BAC); - func_8001CE28(item, D_80190BAC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80190B78[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80190BC8, 0x84); - func_8001CE68(item, D_80190BC8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80190BC8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80190B78[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80190B78; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_801627E8); - - -extern void (*D_801811A8[])(void); - -void func_80162834(void *a0) { - D_801811A8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181198; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181198, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801903EC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801903EC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801903EC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801903EC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801811B0[])(void); - -void func_80163A58(void *a0) { - D_801811B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801903F4; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801903F4; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80181204[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80181204[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801811CC; -extern s16 D_80181200; -extern s16 D_801811FE; -extern s16 D_801811FC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801811CC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181200 = 0x80; - D_801811FE = 0x80; - D_801811FC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181200 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181200` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181200 - 8; - D_80181200 = nv; - D_801811FE = nv; - D_801811FC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181210[])(void); - -void func_80164BA0(void *a0) { - D_80181210[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80190BD8; -extern u8 D_80190BD9; -extern u8 D_80190BDA; -extern u8 D_80190BDB; -extern u8 D_80190BDC; -extern u8 D_80190BDD; -extern u8 D_80190BDE; -extern u8 D_80190BDF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80190BD8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80190BD9 = 0xf0; - *(u8 *)base = 0xf0; - D_80190BDA = 0xc0; - D_80190BDE = 0; - D_80190BDD = 0; - D_80190BDC = 0; - D_80190BDF = 0; - D_80190BDB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80190BD8; -extern u8 D_80190BD9; -extern u8 D_80190BDA; - -s32 func_80164E40(void) { - u8 *p = &D_80190BD8; - if (*p != 0) { - *p -= 0x10; - } - if (D_80190BD9 != 0) { - D_80190BD9 -= 0x10; - } - if (D_80190BDA != 0) { - D_80190BDA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181220[])(void); - -void func_80164EA4(void *a0) { - D_80181220[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80190C24[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80190C24[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80190C18[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80190C18[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80190C18[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80190C18; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80190C18; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181234[]; - extern u32 D_80181254, D_80181258, D_8018125C, D_80181260; - extern u32 D_80181254, D_80181258, D_8018125C, D_80181260; - extern u32 D_80181254, D_80181258, D_8018125C, D_80181260; - extern u32 D_80181254, D_80181258, D_8018125C, D_80181260; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181234[0x00], p); - ApplyMatrixSV(mat, &D_80181234[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181234[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181234[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018125C; - *(u32 *)(prim + 0x24) = D_80181254; - *(u32 *)(prim + 0x28) = D_80181260; - *(u32 *)(prim + 0x2c) = D_80181258; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181264[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181264[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181264[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181264[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801812E0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801812E0[a1 & 0x7F]; -} - - - -extern s32 D_80181300[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181300[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018137C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018137C[a1 & 0x7F]; -} - - - -extern u8 D_8018139C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018139C[a1 & 0x7F]; -} - - - -extern u8 D_801813BC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801813BC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801813DC[])(void); - D_801813DC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80181458[])(void); - -void func_80165AC8(void) { - D_80181458[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801814D4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801814D4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801903FC; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801903FC, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801814E0[])(void); - -void func_80166018(void *a0) { - D_801814E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801814E8[])(void); - -void func_801663FC(void *a0) { - D_801814E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801815B0[])(void); - -void func_80166618(void *a0) { - D_801815B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801815C0[])(void); - -void func_80166654(void *a0) { - D_801815C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80190C98[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80190C98[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80190C98). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80190C98[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80190C98)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80190C98[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80190C98[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80181504[]; - extern u8 D_801814F0[]; - extern u8 D_80181518[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80181504; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801814F0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80181518; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80167714); - - -extern void (*D_801815D0[])(void); - -void func_801678B4(void *a0) { - D_801815D0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801815DC[])(void); - -void func_80167A9C(void *a0) { - D_801815DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801816E8; - extern u8 D_801816FC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801816E8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801816FC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018153C[]; -extern u8 D_80181550[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018153C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181550; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801815F4[])(void); - -void func_80168744(void *a0) { - D_801815F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801815E4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801815E4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801815E4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801815FC[])(void); - -void func_801689D8(void *a0) { - D_801815FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181604[])(void); - -void func_80168AA8(void *a0) { - D_80181604[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018160C[])(void); - -void func_80168D58(void *a0) { - D_8018160C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181614[])(void); - -void func_8016901C(void *a0) { - D_80181614[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015AE2C", func_80169228); - - -extern void (*D_8018161C[])(void); - -void func_801693CC(void *a0) { - D_8018161C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181624[])(void); - -void func_80169830(void *a0) { - D_80181624[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801816D8[])(void); - -void func_80169B80(void *a0) { - D_801816D8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018162C[]; - extern u8 D_8018169C[]; - extern u8 D_801816CC[]; - extern u8 D_801930F8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801816CC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018162C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801930F8; - RotMatrixYXZ(rot, D_801930F8); - func_80048D9C(D_801930F8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018169C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801816E0[])(void); - -void func_80169F00(void *a0) { - D_801816E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80181690[]; -extern char D_80181650[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80181690, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181650); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181718[])(void); - -void func_8016A020(void *a0) { - D_80181718[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801816E8; - extern u8 D_801816FC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801816E8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801816FC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181724[])(void); - -void func_8016A700(void *a0) { - D_80181724[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018176C[])(void); - -void func_8016AB30(void *a0) { - D_8018176C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c b/src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c new file mode 100644 index 000000000..8824deb8e --- /dev/null +++ b/src/ov_SC04_012/ov_SC04_012_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180B38; +extern u8 D_80180AA8; +extern u8 D_80180A84; +extern u8 D_80180A60; +extern u8 D_80180B14; +extern u8 D_80180AF0; +extern u8 D_80180ACC; +extern u8 D_80180A3C; +extern void func_80145934(void); +extern u8 D_80180BC8; +extern u8 D_80180BA4; +extern u8 D_80180B80; +extern u8 D_80180B5C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8017FFC0[]; +extern unsigned char D_8017FFF0[]; +extern unsigned char D_80180040[]; +extern unsigned char D_80180070[]; +extern unsigned char D_801800A0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801800F0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801801B8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180240[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180248; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80190AC8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_80190ACC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180278; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180320[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180344[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180334; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180358[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180364[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180374[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018038C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018037C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801803A0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801803BC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801803AC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801803D0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801803E4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801803F8; +extern void (*D_80180420[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80180400; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018046C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80180470[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801808D4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801808E4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80190B00; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018090C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801808EC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801808FC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018094C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180954[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180920; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80180960[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180930; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80190B08; +extern s32 D_80190B14; +extern s32 D_80190B18; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018099C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80180970[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80190B10; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80180BEC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180A0C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80180C90[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80180DE4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80180C00; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80180DEC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80180C10; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80180C30; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80180DF4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80180E1C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80180C9C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80180E28[])(void); + +void func_8015C714(void *a0) { + D_80180E28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80180C9C[])(void*); + extern int D_80180C40; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80180C9C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80180C9C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180C40); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80180C9C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80180C9C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80180C9C[])(void*); + extern int D_80180C40; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80180C9C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180C40); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80180C9C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80180E38[])(void); + D_80180E38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80180C9C[])(struct Ent_8015CD20 *); + extern u8 D_80180C50; + extern u8 D_80180E40; + extern u8 D_80180E50; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80180C9C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180C50); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180E40); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180E50); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80180C9C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80180E70[])(void); + D_80180E70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80180E60; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80180E60 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80180C9C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80180ECC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80180ECC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8017FFB0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8017FFB0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80180ED4[])(void); + D_80180ED4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80180EE0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80180EE0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80180EE0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80180EE0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80180C9C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80180EE0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80180C60[]; + extern u8 D_80180C70[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80180C60); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80180C70); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80180EE0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180EE0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180EE0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80180F14[])(void); + D_80180F14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80180C9C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180F1C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80180F34[])(void); + D_80180F34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80180C9C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180F1C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180F1C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80180F54[])(void); + D_80180F54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80180C9C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80180C9C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80180F64; +extern u16 D_80180F66; +extern u16 D_80180F68; +extern s32 D_80180F6C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80180F64 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80180F66 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80180F68 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180F6C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80180F74; + +void func_8015E588(void) { + func_8013C9C4(&D_80180F74); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80180C9C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80180C9C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80180F88[])(void); + D_80180F88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80180C9C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80180C9C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80180F90[])(void); + D_80180F90[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80180C80; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80180C80); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80180C9C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80180F98[])(void); + D_80180F98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80180C9C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80180C9C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80180FA0[])(void); + D_80180FA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80180C9C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80180FA8; + extern s32 D_80180FB8; + extern s32 D_80180FC8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180FA8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180FB8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80180C9C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180FC8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80180FD8[])(void); + D_80180FD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80180C9C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80180C9C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80180C9C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80180C9C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80180FE4[])(void); + D_80180FE4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80180C9C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80180C9C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80180C9C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80180C9C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80180FF8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80180FF8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80180C9C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80180C9C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80180C9C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80180C9C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181074[])(void); + D_80181074[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80180C9C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80180C9C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181084[])(void); + D_80181084[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80180C9C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80180C9C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80180C9C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80180C9C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80180C9C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80180C9C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80180C9C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018108C[])(void); + D_8018108C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80180C9C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80180C9C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80180C9C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80180C9C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181098[])(void); + D_80181098[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80180C9C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80180C9C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80180C9C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80180C9C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801810A8[])(void); + +void func_80160EA4(void *a0) { + D_801810A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80180C9C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80180C9C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801810D8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801810D8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018113C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018113C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80190B20[]; + extern u8 D_80181108[]; + extern u8 D_80181128[]; + extern u8 D_80190B2C[]; + extern u8 D_80190B54[]; + extern u8 D_80190B6C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80190B20[0] = p; + func_80024054(&D_80181108, &D_80190B2C); + func_8001CE28(p, &D_80190B2C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80190B20[1] = p; + func_80024054(&D_80181128, &D_80190B54); + func_8001CE28(p, &D_80190B54); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80190B20[2] = p; + func_800242D0((s16)func_801620C4(), &D_80190B6C, 0x84); + func_8001CE68(p, &D_80190B6C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_80190B6C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80190B20[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80190B20; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018113C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018113C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018113C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018113C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80190B20[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80190B20; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181160[])(void); + +void func_80162330(void *a0) { + D_80181160[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80190B78[i] via `extern int D_80190B78[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018116C[]; + extern s32 D_80181184; + extern u8 D_80190B84[]; + extern u8 D_80190BAC[]; + extern u8 D_80190BC8[]; + extern int D_80190B78[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80190B78[0] = (s32)item; + func_80024054(D_8018116C, D_80190B84); + func_8001CE28(item, D_80190B84); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80190B78[1] = (s32)item; + func_80024054(((u8 *)&D_80181184), D_80190BAC); + func_8001CE28(item, D_80190BAC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80190B78[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80190BC8, 0x84); + func_8001CE68(item, D_80190BC8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80190BC8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80190B78[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80190B78; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_801627E8); + + +extern void (*D_801811A8[])(void); + +void func_80162834(void *a0) { + D_801811A8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181198; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181198, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801903EC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801903EC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801903EC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801903EC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801811B0[])(void); + +void func_80163A58(void *a0) { + D_801811B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801903F4; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801903F4; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80181204[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80181204[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801811CC; +extern s16 D_80181200; +extern s16 D_801811FE; +extern s16 D_801811FC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801811CC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181200 = 0x80; + D_801811FE = 0x80; + D_801811FC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181200 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181200` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181200 - 8; + D_80181200 = nv; + D_801811FE = nv; + D_801811FC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181210[])(void); + +void func_80164BA0(void *a0) { + D_80181210[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80190BD8; +extern u8 D_80190BD9; +extern u8 D_80190BDA; +extern u8 D_80190BDB; +extern u8 D_80190BDC; +extern u8 D_80190BDD; +extern u8 D_80190BDE; +extern u8 D_80190BDF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80190BD8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80190BD9 = 0xf0; + *(u8 *)base = 0xf0; + D_80190BDA = 0xc0; + D_80190BDE = 0; + D_80190BDD = 0; + D_80190BDC = 0; + D_80190BDF = 0; + D_80190BDB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80190BD8; +extern u8 D_80190BD9; +extern u8 D_80190BDA; + +s32 func_80164E40(void) { + u8 *p = &D_80190BD8; + if (*p != 0) { + *p -= 0x10; + } + if (D_80190BD9 != 0) { + D_80190BD9 -= 0x10; + } + if (D_80190BDA != 0) { + D_80190BDA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181220[])(void); + +void func_80164EA4(void *a0) { + D_80181220[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80190C24[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80190C24[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80190C18[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80190C18[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80190C18[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80190C18; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80190C18; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181234[]; + extern u32 D_80181254, D_80181258, D_8018125C, D_80181260; + extern u32 D_80181254, D_80181258, D_8018125C, D_80181260; + extern u32 D_80181254, D_80181258, D_8018125C, D_80181260; + extern u32 D_80181254, D_80181258, D_8018125C, D_80181260; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181234[0x00], p); + ApplyMatrixSV(mat, &D_80181234[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181234[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181234[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018125C; + *(u32 *)(prim + 0x24) = D_80181254; + *(u32 *)(prim + 0x28) = D_80181260; + *(u32 *)(prim + 0x2c) = D_80181258; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181264[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181264[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181264[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181264[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801812E0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801812E0[a1 & 0x7F]; +} + + + +extern s32 D_80181300[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181300[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018137C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018137C[a1 & 0x7F]; +} + + + +extern u8 D_8018139C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018139C[a1 & 0x7F]; +} + + + +extern u8 D_801813BC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801813BC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801813DC[])(void); + D_801813DC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80181458[])(void); + +void func_80165AC8(void) { + D_80181458[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801814D4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801814D4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801903FC; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801903FC, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801814E0[])(void); + +void func_80166018(void *a0) { + D_801814E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801814E8[])(void); + +void func_801663FC(void *a0) { + D_801814E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801815B0[])(void); + +void func_80166618(void *a0) { + D_801815B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801815C0[])(void); + +void func_80166654(void *a0) { + D_801815C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80190C98[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80190C98[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80190C98). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80190C98[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80190C98)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80190C98[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80190C98[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80181504[]; + extern u8 D_801814F0[]; + extern u8 D_80181518[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80181504; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801814F0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80181518; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80167714); + + +extern void (*D_801815D0[])(void); + +void func_801678B4(void *a0) { + D_801815D0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801815DC[])(void); + +void func_80167A9C(void *a0) { + D_801815DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801816E8; + extern u8 D_801816FC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801816E8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801816FC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018153C[]; +extern u8 D_80181550[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018153C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181550; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801815F4[])(void); + +void func_80168744(void *a0) { + D_801815F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801815E4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801815E4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801815E4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801815FC[])(void); + +void func_801689D8(void *a0) { + D_801815FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181604[])(void); + +void func_80168AA8(void *a0) { + D_80181604[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018160C[])(void); + +void func_80168D58(void *a0) { + D_8018160C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181614[])(void); + +void func_8016901C(void *a0) { + D_80181614[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_012/nonmatchings/ov_SC04_012_jr_8015C32C", func_80169228); + + +extern void (*D_8018161C[])(void); + +void func_801693CC(void *a0) { + D_8018161C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181624[])(void); + +void func_80169830(void *a0) { + D_80181624[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801816D8[])(void); + +void func_80169B80(void *a0) { + D_801816D8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018162C[]; + extern u8 D_8018169C[]; + extern u8 D_801816CC[]; + extern u8 D_801930F8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801816CC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018162C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801930F8; + RotMatrixYXZ(rot, D_801930F8); + func_80048D9C(D_801930F8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018169C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801816E0[])(void); + +void func_80169F00(void *a0) { + D_801816E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80181690[]; +extern char D_80181650[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80181690, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181650); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181718[])(void); + +void func_8016A020(void *a0) { + D_80181718[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801816E8; + extern u8 D_801816FC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801816E8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801816FC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181724[])(void); + +void func_8016A700(void *a0) { + D_80181724[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018176C[])(void); + +void func_8016AB30(void *a0) { + D_8018176C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_015/ov_SC04_015_jr_8015AE2C.c b/src/ov_SC04_015/ov_SC04_015_jr_8015AE2C.c index 6ef513ec4..1fcc0a82c 100644 --- a/src/ov_SC04_015/ov_SC04_015_jr_8015AE2C.c +++ b/src/ov_SC04_015/ov_SC04_015_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80186D60[])(void); - -void func_8015C714(void *a0) { - D_80186D60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80186BD4[])(void*); - extern int D_80186B78; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80186BD4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80186BD4)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186B78); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80186BD4[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80186BD4[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80186BD4[])(void*); - extern int D_80186B78; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80186BD4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186B78); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80186BD4)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80186D70[])(void); - D_80186D70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80186BD4[])(struct Ent_8015CD20 *); - extern u8 D_80186B88; - extern u8 D_80186D78; - extern u8 D_80186D88; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80186BD4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186B88); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D78); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D88); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80186BD4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80186DA8[])(void); - D_80186DA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80186D98; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80186D98 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80186BD4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80186E04; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80186E04, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80185EE8[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80185EE8; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80186E0C[])(void); - D_80186E0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80186E18[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80186E18[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80186E18[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80186E18[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80186BD4[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80186E18[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80186B98[]; - extern u8 D_80186BA8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186B98); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186BA8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80186E18[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186E18[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186E18[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80186E4C[])(void); - D_80186E4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186BD4[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186E54[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80186E6C[])(void); - D_80186E6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80186BD4[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80186E54[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80186E8C[])(void); - D_80186E8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80186BD4[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186BD4)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80186E9C; -extern u16 D_80186E9E; -extern u16 D_80186EA0; -extern s32 D_80186EA4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80186E9C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80186E9E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80186EA0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186EA4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80186EAC; - -void func_8015E588(void) { - func_8013C9C4(&D_80186EAC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80186BD4[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80186BD4)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80186EC0[])(void); - D_80186EC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80186BD4[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80186BD4[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80186EC8[])(void); - D_80186EC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80186BB8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186BB8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80186BD4[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80186ED0[])(void); - D_80186ED0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80186BD4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80186BD4[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80186ED8[])(void); - D_80186ED8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80186BD4[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80186EE0; - extern s32 D_80186EF0; - extern s32 D_80186F00; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80186BD4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186EE0); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186EF0); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80186BD4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186F00); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80186F10[])(void); - D_80186F10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80186BD4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80186BD4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80186BD4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80186BD4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80186F1C[])(void); - D_80186F1C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80186BD4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80186BD4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80186BD4[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186BD4[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80186F30[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80186F30[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80186BD4[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80186BD4)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80186BD4[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80186BD4[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80186FAC[])(void); - D_80186FAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80186BD4[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80186BD4)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80186FBC[])(void); - D_80186FBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80186BD4[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80186BD4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80186BD4[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80186BD4[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80186BD4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80186BD4[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80186BD4[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80186FC4[])(void); - D_80186FC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80186BD4[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80186BD4)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80186BD4[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80186BD4)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80186FD0[])(void); - D_80186FD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186BD4 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80186BD4[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80186BD4[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80186BD4[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80186FE0[])(void); - -void func_80160EA4(void *a0) { - D_80186FE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80186BD4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80186BD4[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80187010[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80187010[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80187074; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80187074); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C7808[]; - extern u8 D_80187040[]; - extern u8 D_80187060[]; - extern u8 D_801C7814[]; - extern u8 D_801C783C[]; - extern u8 D_801C7854[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C7808[0] = p; - func_80024054(&D_80187040, &D_801C7814); - func_8001CE28(p, &D_801C7814); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C7808[1] = p; - func_80024054(&D_80187060, &D_801C783C); - func_8001CE28(p, &D_801C783C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C7808[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C7854, 0x84); - func_8001CE68(p, &D_801C7854); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C7854, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C7808[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C7808; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80187074; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80187074; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80187074; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80187074; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C7808[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C7808; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80187098[])(void); - -void func_80162330(void *a0) { - D_80187098[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C7860[i] via `extern int D_801C7860[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801870A4[]; - extern s32 D_801870BC; - extern u8 D_801C786C[]; - extern u8 D_801C7894[]; - extern u8 D_801C78B0[]; - extern int D_801C7860[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C7860[0] = (s32)item; - func_80024054(D_801870A4, D_801C786C); - func_8001CE28(item, D_801C786C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C7860[1] = (s32)item; - func_80024054(((u8 *)&D_801870BC), D_801C7894); - func_8001CE28(item, D_801C7894); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C7860[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C78B0, 0x84); - func_8001CE68(item, D_801C78B0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C78B0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C7860[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C7860; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_801627E8); - - -extern void (*D_801870E0[])(void); - -void func_80162834(void *a0) { - D_801870E0[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801870D0; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801870D0, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C7084[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C7084, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C7084[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C7084, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801870E8[])(void); - -void func_80163A58(void *a0) { - D_801870E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C708C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C708C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018713C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018713C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80187104; -extern s16 D_80187138; -extern s16 D_80187136; -extern s16 D_80187134; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80187104; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80187138 = 0x80; - D_80187136 = 0x80; - D_80187134 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80187138 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187138` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80187138 - 8; - D_80187138 = nv; - D_80187136 = nv; - D_80187134 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80187148[])(void); - -void func_80164BA0(void *a0) { - D_80187148[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C78C0; -extern u8 D_801C78C1; -extern u8 D_801C78C2; -extern u8 D_801C78C3; -extern u8 D_801C78C4; -extern u8 D_801C78C5; -extern u8 D_801C78C6; -extern u8 D_801C78C7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C78C0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C78C1 = 0xf0; - *(u8 *)base = 0xf0; - D_801C78C2 = 0xc0; - D_801C78C6 = 0; - D_801C78C5 = 0; - D_801C78C4 = 0; - D_801C78C7 = 0; - D_801C78C3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C78C0; -extern u8 D_801C78C1; -extern u8 D_801C78C2; - -s32 func_80164E40(void) { - u8 *p = &D_801C78C0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C78C1 != 0) { - D_801C78C1 -= 0x10; - } - if (D_801C78C2 != 0) { - D_801C78C2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80187158[])(void); - -void func_80164EA4(void *a0) { - D_80187158[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C790C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C790C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C7900[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C7900[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C7900[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C7900; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C7900; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018716C[]; - extern u32 D_8018718C, D_80187190, D_80187194, D_80187198; - extern u32 D_8018718C, D_80187190, D_80187194, D_80187198; - extern u32 D_8018718C, D_80187190, D_80187194, D_80187198; - extern u32 D_8018718C, D_80187190, D_80187194, D_80187198; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018716C[0x00], p); - ApplyMatrixSV(mat, &D_8018716C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018716C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018716C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80187194; - *(u32 *)(prim + 0x24) = D_8018718C; - *(u32 *)(prim + 0x28) = D_80187198; - *(u32 *)(prim + 0x2c) = D_80187190; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018719C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018719C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018719C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018719C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80187218[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80187218[a1 & 0x7F]; -} - - - -extern s32 D_80187238[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80187238[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801872B4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801872B4[a1 & 0x7F]; -} - - - -extern u8 D_801872D4[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801872D4[a1 & 0x7F]; -} - - - -extern u8 D_801872F4[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801872F4[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80187314[])(void); - D_80187314[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187390[])(void); - -void func_80165AC8(void) { - D_80187390[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018740C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018740C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C7094; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C7094, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80187418[])(void); - -void func_80166018(void *a0) { - D_80187418[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80187420[])(void); - -void func_801663FC(void *a0) { - D_80187420[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801874E8[])(void); - -void func_80166618(void *a0) { - D_801874E8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801874F8[])(void); - -void func_80166654(void *a0) { - D_801874F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C7980[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C7980[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C7980). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C7980[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C7980)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C7980[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C7980[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018743C[]; - extern u8 D_80187428[]; - extern u8 D_80187450[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018743C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80187428; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187450; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80167714); - - -extern void (*D_80187508[])(void); - -void func_801678B4(void *a0) { - D_80187508[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80187514[])(void); - -void func_80167A9C(void *a0) { - D_80187514[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80187620; - extern u8 D_80187634[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80187620); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187634; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80187474[]; -extern u8 D_80187488[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80187474; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187488; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018752C[])(void); - -void func_80168744(void *a0) { - D_8018752C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018751C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018751C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018751C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80187534[])(void); - -void func_801689D8(void *a0) { - D_80187534[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018753C[])(void); - -void func_80168AA8(void *a0) { - D_8018753C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80187544[])(void); - -void func_80168D58(void *a0) { - D_80187544[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018754C[])(void); - -void func_8016901C(void *a0) { - D_8018754C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015AE2C", func_80169228); - - -extern void (*D_80187554[])(void); - -void func_801693CC(void *a0) { - D_80187554[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018755C[])(void); - -void func_80169830(void *a0) { - D_8018755C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187610[])(void); - -void func_80169B80(void *a0) { - D_80187610[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80187564[]; - extern u8 D_801875D4[]; - extern u8 D_80187604[]; - extern u8 D_801C9270[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80187604, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80187564[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C9270; - RotMatrixYXZ(rot, D_801C9270); - func_80048D9C(D_801C9270, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801875D4); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80187618[])(void); - -void func_80169F00(void *a0) { - D_80187618[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801875C8[]; -extern char D_80187588[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801875C8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187588); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187650[])(void); - -void func_8016A020(void *a0) { - D_80187650[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80187620; - extern u8 D_80187634[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80187620); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187634; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018765C[])(void); - -void func_8016A700(void *a0) { - D_8018765C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801876A4[])(void); - -void func_8016AB30(void *a0) { - D_801876A4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c b/src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c new file mode 100644 index 000000000..b8e78d359 --- /dev/null +++ b/src/ov_SC04_015/ov_SC04_015_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80186A70; +extern u8 D_801869E0; +extern u8 D_801869BC; +extern u8 D_80186998; +extern u8 D_80186A4C; +extern u8 D_80186A28; +extern u8 D_80186A04; +extern u8 D_80186974; +extern void func_80145934(void); +extern u8 D_80186B00; +extern u8 D_80186ADC; +extern u8 D_80186AB8; +extern u8 D_80186A94; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80185EF8[]; +extern unsigned char D_80185F28[]; +extern unsigned char D_80185F78[]; +extern unsigned char D_80185FA8[]; +extern unsigned char D_80185FD8[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80186028[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801860F0[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80186178[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186180; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C77B0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C77B4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801861B0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80186258[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018627C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018626C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186290[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018629C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801862AC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801862C4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801862B4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801862D8[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801862F4[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801862E4; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80186308[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018631C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80186330; +extern void (*D_80186358[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80186338; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801863A4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801863A8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018680C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018681C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C77E8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80186844[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80186824; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80186834; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80186884[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018688C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80186858; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80186898[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80186868; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C77F0; +extern s32 D_801C77FC; +extern s32 D_801C7800; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801868D4[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801868A8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C77F8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80186B24[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80186944[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80186BC8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80186D1C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80186B38; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80186D24[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80186B48; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80186B68; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80186D2C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80186D54[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80186BD4[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80186D60[])(void); + +void func_8015C714(void *a0) { + D_80186D60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80186BD4[])(void*); + extern int D_80186B78; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80186BD4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80186BD4)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186B78); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80186BD4[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80186BD4[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80186BD4[])(void*); + extern int D_80186B78; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80186BD4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80186B78); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80186BD4)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80186D70[])(void); + D_80186D70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80186BD4[])(struct Ent_8015CD20 *); + extern u8 D_80186B88; + extern u8 D_80186D78; + extern u8 D_80186D88; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80186BD4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186B88); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D78); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80186D88); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80186BD4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80186DA8[])(void); + D_80186DA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80186D98; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80186D98 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80186BD4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80186E04; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80186E04, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80185EE8[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80185EE8; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80186E0C[])(void); + D_80186E0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80186E18[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80186E18[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80186E18[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80186E18[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80186BD4[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80186E18[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80186B98[]; + extern u8 D_80186BA8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186B98); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80186BA8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80186E18[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80186E18[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80186E18[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80186E4C[])(void); + D_80186E4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186BD4[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186E54[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80186E6C[])(void); + D_80186E6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80186BD4[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80186E54[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80186E54[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80186E8C[])(void); + D_80186E8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80186BD4[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186BD4)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80186E9C; +extern u16 D_80186E9E; +extern u16 D_80186EA0; +extern s32 D_80186EA4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80186E9C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80186E9E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80186EA0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80186EA4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80186EAC; + +void func_8015E588(void) { + func_8013C9C4(&D_80186EAC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80186BD4[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80186BD4)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80186EC0[])(void); + D_80186EC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80186BD4[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80186BD4[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80186EC8[])(void); + D_80186EC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80186BB8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80186BB8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80186BD4[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80186ED0[])(void); + D_80186ED0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80186BD4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80186BD4[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80186ED8[])(void); + D_80186ED8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80186BD4[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80186EE0; + extern s32 D_80186EF0; + extern s32 D_80186F00; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186EE0); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186EF0); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80186BD4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80186F00); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80186F10[])(void); + D_80186F10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80186BD4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80186BD4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80186BD4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80186BD4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80186F1C[])(void); + D_80186F1C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80186BD4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80186BD4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80186BD4[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186BD4[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80186F30[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80186F30[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80186BD4[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80186BD4)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80186BD4[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80186BD4[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80186FAC[])(void); + D_80186FAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80186BD4[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80186BD4)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80186FBC[])(void); + D_80186FBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80186BD4[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80186BD4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80186BD4[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80186BD4[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80186BD4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80186BD4[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80186BD4[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80186FC4[])(void); + D_80186FC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80186BD4[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80186BD4)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80186BD4[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80186BD4)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80186FD0[])(void); + D_80186FD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80186BD4 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80186BD4[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80186BD4[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80186BD4[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80186FE0[])(void); + +void func_80160EA4(void *a0) { + D_80186FE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80186BD4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80186BD4[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80187010[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80187010[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80187074; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80187074); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C7808[]; + extern u8 D_80187040[]; + extern u8 D_80187060[]; + extern u8 D_801C7814[]; + extern u8 D_801C783C[]; + extern u8 D_801C7854[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C7808[0] = p; + func_80024054(&D_80187040, &D_801C7814); + func_8001CE28(p, &D_801C7814); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C7808[1] = p; + func_80024054(&D_80187060, &D_801C783C); + func_8001CE28(p, &D_801C783C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C7808[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C7854, 0x84); + func_8001CE68(p, &D_801C7854); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C7854, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C7808[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C7808; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80187074; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80187074; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80187074; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80187074; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C7808[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C7808; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80187098[])(void); + +void func_80162330(void *a0) { + D_80187098[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C7860[i] via `extern int D_801C7860[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801870A4[]; + extern s32 D_801870BC; + extern u8 D_801C786C[]; + extern u8 D_801C7894[]; + extern u8 D_801C78B0[]; + extern int D_801C7860[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C7860[0] = (s32)item; + func_80024054(D_801870A4, D_801C786C); + func_8001CE28(item, D_801C786C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C7860[1] = (s32)item; + func_80024054(((u8 *)&D_801870BC), D_801C7894); + func_8001CE28(item, D_801C7894); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C7860[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C78B0, 0x84); + func_8001CE68(item, D_801C78B0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C78B0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C7860[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C7860; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_801627E8); + + +extern void (*D_801870E0[])(void); + +void func_80162834(void *a0) { + D_801870E0[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801870D0; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801870D0, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C7084[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C7084, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C7084[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C7084, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801870E8[])(void); + +void func_80163A58(void *a0) { + D_801870E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C708C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C708C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018713C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018713C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80187104; +extern s16 D_80187138; +extern s16 D_80187136; +extern s16 D_80187134; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80187104; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80187138 = 0x80; + D_80187136 = 0x80; + D_80187134 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80187138 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187138` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80187138 - 8; + D_80187138 = nv; + D_80187136 = nv; + D_80187134 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80187148[])(void); + +void func_80164BA0(void *a0) { + D_80187148[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C78C0; +extern u8 D_801C78C1; +extern u8 D_801C78C2; +extern u8 D_801C78C3; +extern u8 D_801C78C4; +extern u8 D_801C78C5; +extern u8 D_801C78C6; +extern u8 D_801C78C7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C78C0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C78C1 = 0xf0; + *(u8 *)base = 0xf0; + D_801C78C2 = 0xc0; + D_801C78C6 = 0; + D_801C78C5 = 0; + D_801C78C4 = 0; + D_801C78C7 = 0; + D_801C78C3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C78C0; +extern u8 D_801C78C1; +extern u8 D_801C78C2; + +s32 func_80164E40(void) { + u8 *p = &D_801C78C0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C78C1 != 0) { + D_801C78C1 -= 0x10; + } + if (D_801C78C2 != 0) { + D_801C78C2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80187158[])(void); + +void func_80164EA4(void *a0) { + D_80187158[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C790C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C790C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C7900[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C7900[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C7900[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C7900; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C7900; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018716C[]; + extern u32 D_8018718C, D_80187190, D_80187194, D_80187198; + extern u32 D_8018718C, D_80187190, D_80187194, D_80187198; + extern u32 D_8018718C, D_80187190, D_80187194, D_80187198; + extern u32 D_8018718C, D_80187190, D_80187194, D_80187198; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018716C[0x00], p); + ApplyMatrixSV(mat, &D_8018716C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018716C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018716C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80187194; + *(u32 *)(prim + 0x24) = D_8018718C; + *(u32 *)(prim + 0x28) = D_80187198; + *(u32 *)(prim + 0x2c) = D_80187190; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018719C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018719C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018719C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018719C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80187218[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80187218[a1 & 0x7F]; +} + + + +extern s32 D_80187238[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80187238[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801872B4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801872B4[a1 & 0x7F]; +} + + + +extern u8 D_801872D4[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801872D4[a1 & 0x7F]; +} + + + +extern u8 D_801872F4[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801872F4[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80187314[])(void); + D_80187314[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187390[])(void); + +void func_80165AC8(void) { + D_80187390[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018740C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018740C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C7094; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C7094, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80187418[])(void); + +void func_80166018(void *a0) { + D_80187418[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80187420[])(void); + +void func_801663FC(void *a0) { + D_80187420[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801874E8[])(void); + +void func_80166618(void *a0) { + D_801874E8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801874F8[])(void); + +void func_80166654(void *a0) { + D_801874F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C7980[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C7980[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C7980). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C7980[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C7980)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C7980[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C7980[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018743C[]; + extern u8 D_80187428[]; + extern u8 D_80187450[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018743C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80187428; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187450; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80167714); + + +extern void (*D_80187508[])(void); + +void func_801678B4(void *a0) { + D_80187508[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80187514[])(void); + +void func_80167A9C(void *a0) { + D_80187514[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80187620; + extern u8 D_80187634[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80187620); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187634; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80187474[]; +extern u8 D_80187488[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80187474; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187488; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018752C[])(void); + +void func_80168744(void *a0) { + D_8018752C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018751C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018751C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018751C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80187534[])(void); + +void func_801689D8(void *a0) { + D_80187534[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018753C[])(void); + +void func_80168AA8(void *a0) { + D_8018753C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80187544[])(void); + +void func_80168D58(void *a0) { + D_80187544[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018754C[])(void); + +void func_8016901C(void *a0) { + D_8018754C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_015/nonmatchings/ov_SC04_015_jr_8015C32C", func_80169228); + + +extern void (*D_80187554[])(void); + +void func_801693CC(void *a0) { + D_80187554[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018755C[])(void); + +void func_80169830(void *a0) { + D_8018755C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187610[])(void); + +void func_80169B80(void *a0) { + D_80187610[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80187564[]; + extern u8 D_801875D4[]; + extern u8 D_80187604[]; + extern u8 D_801C9270[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80187604, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80187564[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C9270; + RotMatrixYXZ(rot, D_801C9270); + func_80048D9C(D_801C9270, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801875D4); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80187618[])(void); + +void func_80169F00(void *a0) { + D_80187618[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801875C8[]; +extern char D_80187588[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801875C8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187588); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187650[])(void); + +void func_8016A020(void *a0) { + D_80187650[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80187620; + extern u8 D_80187634[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80187620); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187634; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018765C[])(void); + +void func_8016A700(void *a0) { + D_8018765C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801876A4[])(void); + +void func_8016AB30(void *a0) { + D_801876A4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_016/ov_SC04_016_jr_8015AE2C.c b/src/ov_SC04_016/ov_SC04_016_jr_8015AE2C.c index 5523f8396..5f0b04678 100644 --- a/src/ov_SC04_016/ov_SC04_016_jr_8015AE2C.c +++ b/src/ov_SC04_016/ov_SC04_016_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80182824[])(void); - -void func_8015C714(void *a0) { - D_80182824[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80182698[])(void*); - extern int D_8018263C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80182698)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80182698)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018263C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80182698[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80182698[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80182698[])(void*); - extern int D_8018263C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80182698)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018263C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80182698)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80182834[])(void); - D_80182834[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80182698[])(struct Ent_8015CD20 *); - extern u8 D_8018264C; - extern u8 D_8018283C; - extern u8 D_8018284C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80182698[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018264C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018283C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018284C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80182698[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018286C[])(void); - D_8018286C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018285C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018285C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80182698[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801828C8; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801828C8, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801819AC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801819AC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801828D0[])(void); - D_801828D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801828DC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801828DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801828DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801828DC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80182698[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801828DC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018265C[]; - extern u8 D_8018266C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018265C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018266C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801828DC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801828DC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801828DC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80182910[])(void); - D_80182910[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182698[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182918[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80182930[])(void); - D_80182930[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182698[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182918[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80182950[])(void); - D_80182950[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80182698[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182698)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80182960; -extern u16 D_80182962; -extern u16 D_80182964; -extern s32 D_80182968; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80182960 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80182962 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80182964 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182968, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80182970; - -void func_8015E588(void) { - func_8013C9C4(&D_80182970); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80182698[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182698)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80182984[])(void); - D_80182984[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80182698[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80182698[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018298C[])(void); - D_8018298C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018267C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018267C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80182698[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80182994[])(void); - D_80182994[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80182698[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80182698[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018299C[])(void); - D_8018299C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80182698[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801829A4; - extern s32 D_801829B4; - extern s32 D_801829C4; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80182698[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801829A4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801829B4); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80182698[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801829C4); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801829D4[])(void); - D_801829D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80182698[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80182698[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80182698[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182698[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801829E0[])(void); - D_801829E0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80182698[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182698[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80182698[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182698[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801829F4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801829F4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80182698[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80182698)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80182698[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182698[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80182A70[])(void); - D_80182A70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80182698[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80182698)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80182A80[])(void); - D_80182A80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80182698[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80182698[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80182698[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80182698[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80182698[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80182698[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80182698[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80182A88[])(void); - D_80182A88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80182698[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80182698)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80182698[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80182698)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80182A94[])(void); - D_80182A94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182698 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80182698[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80182698[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80182698[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80182AA4[])(void); - -void func_80160EA4(void *a0) { - D_80182AA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80182698[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80182698[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80182AD4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80182AD4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80182B38; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80182B38); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A59B0[]; - extern u8 D_80182B04[]; - extern u8 D_80182B24[]; - extern u8 D_801A59BC[]; - extern u8 D_801A59E4[]; - extern u8 D_801A59FC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A59B0[0] = p; - func_80024054(&D_80182B04, &D_801A59BC); - func_8001CE28(p, &D_801A59BC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A59B0[1] = p; - func_80024054(&D_80182B24, &D_801A59E4); - func_8001CE28(p, &D_801A59E4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A59B0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A59FC, 0x84); - func_8001CE68(p, &D_801A59FC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A59FC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A59B0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A59B0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80182B38; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80182B38; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80182B38; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80182B38; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A59B0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A59B0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80182B5C[])(void); - -void func_80162330(void *a0) { - D_80182B5C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A5A08[i] via `extern int D_801A5A08[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80182B68[]; - extern s32 D_80182B80; - extern u8 D_801A5A14[]; - extern u8 D_801A5A3C[]; - extern u8 D_801A5A58[]; - extern int D_801A5A08[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A5A08[0] = (s32)item; - func_80024054(D_80182B68, D_801A5A14); - func_8001CE28(item, D_801A5A14); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A5A08[1] = (s32)item; - func_80024054(((u8 *)&D_80182B80), D_801A5A3C); - func_8001CE28(item, D_801A5A3C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A5A08[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A5A58, 0x84); - func_8001CE68(item, D_801A5A58); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A5A58, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A5A08[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A5A08; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_801627E8); - - -extern void (*D_80182BA4[])(void); - -void func_80162834(void *a0) { - D_80182BA4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80182B94; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80182B94, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801A523C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801A523C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801A523C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801A523C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80182BAC[])(void); - -void func_80163A58(void *a0) { - D_80182BAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801A5244; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801A5244; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80182C00[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80182C00[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80182BC8; -extern s16 D_80182BFC; -extern s16 D_80182BFA; -extern s16 D_80182BF8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80182BC8; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80182BFC = 0x80; - D_80182BFA = 0x80; - D_80182BF8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80182BFC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182BFC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80182BFC - 8; - D_80182BFC = nv; - D_80182BFA = nv; - D_80182BF8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80182C0C[])(void); - -void func_80164BA0(void *a0) { - D_80182C0C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A5A68; -extern u8 D_801A5A69; -extern u8 D_801A5A6A; -extern u8 D_801A5A6B; -extern u8 D_801A5A6C; -extern u8 D_801A5A6D; -extern u8 D_801A5A6E; -extern u8 D_801A5A6F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A5A68; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A5A69 = 0xf0; - *(u8 *)base = 0xf0; - D_801A5A6A = 0xc0; - D_801A5A6E = 0; - D_801A5A6D = 0; - D_801A5A6C = 0; - D_801A5A6F = 0; - D_801A5A6B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A5A68; -extern u8 D_801A5A69; -extern u8 D_801A5A6A; - -s32 func_80164E40(void) { - u8 *p = &D_801A5A68; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A5A69 != 0) { - D_801A5A69 -= 0x10; - } - if (D_801A5A6A != 0) { - D_801A5A6A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80182C1C[])(void); - -void func_80164EA4(void *a0) { - D_80182C1C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A5AB4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A5AB4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A5AA8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A5AA8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A5AA8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A5AA8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A5AA8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80182C30[]; - extern u32 D_80182C50, D_80182C54, D_80182C58, D_80182C5C; - extern u32 D_80182C50, D_80182C54, D_80182C58, D_80182C5C; - extern u32 D_80182C50, D_80182C54, D_80182C58, D_80182C5C; - extern u32 D_80182C50, D_80182C54, D_80182C58, D_80182C5C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80182C30[0x00], p); - ApplyMatrixSV(mat, &D_80182C30[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80182C30[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80182C30[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80182C58; - *(u32 *)(prim + 0x24) = D_80182C50; - *(u32 *)(prim + 0x28) = D_80182C5C; - *(u32 *)(prim + 0x2c) = D_80182C54; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80182C60[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80182C60[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80182C60[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80182C60[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80182CDC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80182CDC[a1 & 0x7F]; -} - - - -extern s32 D_80182CFC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80182CFC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80182D78[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80182D78[a1 & 0x7F]; -} - - - -extern u8 D_80182D98[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182D98[a1 & 0x7F]; -} - - - -extern u8 D_80182DB8[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182DB8[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80182DD8[])(void); - D_80182DD8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80182E54[])(void); - -void func_80165AC8(void) { - D_80182E54[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80182ED0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80182ED0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801A524C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801A524C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80182EDC[])(void); - -void func_80166018(void *a0) { - D_80182EDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80182EE4[])(void); - -void func_801663FC(void *a0) { - D_80182EE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182FAC[])(void); - -void func_80166618(void *a0) { - D_80182FAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182FBC[])(void); - -void func_80166654(void *a0) { - D_80182FBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A5B28[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A5B28[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A5B28). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A5B28[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A5B28)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A5B28[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A5B28[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80182F00[]; - extern u8 D_80182EEC[]; - extern u8 D_80182F14[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80182F00; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80182EEC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182F14; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80167714); - - -extern void (*D_80182FCC[])(void); - -void func_801678B4(void *a0) { - D_80182FCC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80182FD8[])(void); - -void func_80167A9C(void *a0) { - D_80182FD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801830E4; - extern u8 D_801830F8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801830E4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801830F8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80182F38[]; -extern u8 D_80182F4C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80182F38; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80182F4C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80182FF0[])(void); - -void func_80168744(void *a0) { - D_80182FF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80182FE0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80182FE0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80182FE0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80182FF8[])(void); - -void func_801689D8(void *a0) { - D_80182FF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80183000[])(void); - -void func_80168AA8(void *a0) { - D_80183000[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80183008[])(void); - -void func_80168D58(void *a0) { - D_80183008[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80183010[])(void); - -void func_8016901C(void *a0) { - D_80183010[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015AE2C", func_80169228); - - -extern void (*D_80183018[])(void); - -void func_801693CC(void *a0) { - D_80183018[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80183020[])(void); - -void func_80169830(void *a0) { - D_80183020[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801830D4[])(void); - -void func_80169B80(void *a0) { - D_801830D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80183028[]; - extern u8 D_80183098[]; - extern u8 D_801830C8[]; - extern u8 D_801AC198[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801830C8, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80183028[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801AC198; - RotMatrixYXZ(rot, D_801AC198); - func_80048D9C(D_801AC198, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80183098); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801830DC[])(void); - -void func_80169F00(void *a0) { - D_801830DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018308C[]; -extern char D_8018304C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018308C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018304C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80183114[])(void); - -void func_8016A020(void *a0) { - D_80183114[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801830E4; - extern u8 D_801830F8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801830E4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801830F8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80183120[])(void); - -void func_8016A700(void *a0) { - D_80183120[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80183168[])(void); - -void func_8016AB30(void *a0) { - D_80183168[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c b/src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c new file mode 100644 index 000000000..d073520e7 --- /dev/null +++ b/src/ov_SC04_016/ov_SC04_016_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80182534; +extern u8 D_801824A4; +extern u8 D_80182480; +extern u8 D_8018245C; +extern u8 D_80182510; +extern u8 D_801824EC; +extern u8 D_801824C8; +extern u8 D_80182438; +extern void func_80145934(void); +extern u8 D_801825C4; +extern u8 D_801825A0; +extern u8 D_8018257C; +extern u8 D_80182558; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801819BC[]; +extern unsigned char D_801819EC[]; +extern unsigned char D_80181A3C[]; +extern unsigned char D_80181A6C[]; +extern unsigned char D_80181A9C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80181AEC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80181BB4[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80181C3C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80181C44; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A5958; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A595C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80181C74; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80181D1C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80181D40[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80181D30; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80181D54[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80181D60[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80181D70[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181D88[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80181D78; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181D9C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181DB8[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181DA8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181DCC[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80181DE0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80181DF4; +extern void (*D_80181E1C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80181DFC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80181E68[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80181E6C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801822D0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_801822E0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A5990; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80182308[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_801822E8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801822F8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80182348[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80182350[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018231C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018235C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018232C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A5998; +extern s32 D_801A59A4; +extern s32 D_801A59A8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80182398[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018236C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A59A0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801825E8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80182408[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018268C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801827E0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801825FC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801827E8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018260C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018262C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801827F0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80182818[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80182698[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80182698[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80182698[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80182698[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80182698[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80182698[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80182698[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80182698[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80182824[])(void); + +void func_8015C714(void *a0) { + D_80182824[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80182698[])(void*); + extern int D_8018263C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80182698)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80182698)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018263C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80182698[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80182698[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80182698[])(void*); + extern int D_8018263C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80182698)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018263C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80182698)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80182834[])(void); + D_80182834[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80182698[])(struct Ent_8015CD20 *); + extern u8 D_8018264C; + extern u8 D_8018283C; + extern u8 D_8018284C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80182698[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018264C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018283C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018284C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80182698[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018286C[])(void); + D_8018286C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018285C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018285C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80182698[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801828C8; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801828C8, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801819AC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801819AC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801828D0[])(void); + D_801828D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801828DC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801828DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801828DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801828DC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80182698[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801828DC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018265C[]; + extern u8 D_8018266C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018265C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018266C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801828DC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801828DC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801828DC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80182910[])(void); + D_80182910[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182698[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182918[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80182930[])(void); + D_80182930[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182698[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182918[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182918[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80182950[])(void); + D_80182950[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80182698[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182698)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80182960; +extern u16 D_80182962; +extern u16 D_80182964; +extern s32 D_80182968; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80182960 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80182962 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80182964 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182968, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80182970; + +void func_8015E588(void) { + func_8013C9C4(&D_80182970); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80182698[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182698)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80182984[])(void); + D_80182984[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80182698[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80182698[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018298C[])(void); + D_8018298C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018267C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018267C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80182698[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80182994[])(void); + D_80182994[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80182698[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80182698[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018299C[])(void); + D_8018299C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80182698[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801829A4; + extern s32 D_801829B4; + extern s32 D_801829C4; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80182698[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801829A4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801829B4); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80182698[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801829C4); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801829D4[])(void); + D_801829D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80182698[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80182698[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80182698[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182698[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801829E0[])(void); + D_801829E0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80182698[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182698[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80182698[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182698[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801829F4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801829F4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80182698[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80182698)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80182698[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182698[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80182A70[])(void); + D_80182A70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80182698[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80182698)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80182A80[])(void); + D_80182A80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80182698[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80182698[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80182698[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80182698[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80182698[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80182698[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80182698[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80182A88[])(void); + D_80182A88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80182698[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80182698)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80182698[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80182698)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80182A94[])(void); + D_80182A94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182698 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80182698[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80182698[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80182698[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80182AA4[])(void); + +void func_80160EA4(void *a0) { + D_80182AA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80182698[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80182698[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80182AD4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80182AD4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80182B38; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80182B38); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A59B0[]; + extern u8 D_80182B04[]; + extern u8 D_80182B24[]; + extern u8 D_801A59BC[]; + extern u8 D_801A59E4[]; + extern u8 D_801A59FC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A59B0[0] = p; + func_80024054(&D_80182B04, &D_801A59BC); + func_8001CE28(p, &D_801A59BC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A59B0[1] = p; + func_80024054(&D_80182B24, &D_801A59E4); + func_8001CE28(p, &D_801A59E4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A59B0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A59FC, 0x84); + func_8001CE68(p, &D_801A59FC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A59FC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A59B0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A59B0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80182B38; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80182B38; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80182B38; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80182B38; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A59B0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A59B0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80182B5C[])(void); + +void func_80162330(void *a0) { + D_80182B5C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A5A08[i] via `extern int D_801A5A08[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80182B68[]; + extern s32 D_80182B80; + extern u8 D_801A5A14[]; + extern u8 D_801A5A3C[]; + extern u8 D_801A5A58[]; + extern int D_801A5A08[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A5A08[0] = (s32)item; + func_80024054(D_80182B68, D_801A5A14); + func_8001CE28(item, D_801A5A14); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A5A08[1] = (s32)item; + func_80024054(((u8 *)&D_80182B80), D_801A5A3C); + func_8001CE28(item, D_801A5A3C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A5A08[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A5A58, 0x84); + func_8001CE68(item, D_801A5A58); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A5A58, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A5A08[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A5A08; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_801627E8); + + +extern void (*D_80182BA4[])(void); + +void func_80162834(void *a0) { + D_80182BA4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80182B94; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80182B94, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801A523C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801A523C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801A523C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801A523C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80182BAC[])(void); + +void func_80163A58(void *a0) { + D_80182BAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801A5244; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801A5244; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80182C00[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80182C00[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80182BC8; +extern s16 D_80182BFC; +extern s16 D_80182BFA; +extern s16 D_80182BF8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80182BC8; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80182BFC = 0x80; + D_80182BFA = 0x80; + D_80182BF8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80182BFC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182BFC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80182BFC - 8; + D_80182BFC = nv; + D_80182BFA = nv; + D_80182BF8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80182C0C[])(void); + +void func_80164BA0(void *a0) { + D_80182C0C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A5A68; +extern u8 D_801A5A69; +extern u8 D_801A5A6A; +extern u8 D_801A5A6B; +extern u8 D_801A5A6C; +extern u8 D_801A5A6D; +extern u8 D_801A5A6E; +extern u8 D_801A5A6F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A5A68; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A5A69 = 0xf0; + *(u8 *)base = 0xf0; + D_801A5A6A = 0xc0; + D_801A5A6E = 0; + D_801A5A6D = 0; + D_801A5A6C = 0; + D_801A5A6F = 0; + D_801A5A6B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A5A68; +extern u8 D_801A5A69; +extern u8 D_801A5A6A; + +s32 func_80164E40(void) { + u8 *p = &D_801A5A68; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A5A69 != 0) { + D_801A5A69 -= 0x10; + } + if (D_801A5A6A != 0) { + D_801A5A6A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80182C1C[])(void); + +void func_80164EA4(void *a0) { + D_80182C1C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A5AB4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A5AB4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A5AA8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A5AA8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A5AA8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A5AA8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A5AA8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80182C30[]; + extern u32 D_80182C50, D_80182C54, D_80182C58, D_80182C5C; + extern u32 D_80182C50, D_80182C54, D_80182C58, D_80182C5C; + extern u32 D_80182C50, D_80182C54, D_80182C58, D_80182C5C; + extern u32 D_80182C50, D_80182C54, D_80182C58, D_80182C5C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80182C30[0x00], p); + ApplyMatrixSV(mat, &D_80182C30[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80182C30[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80182C30[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80182C58; + *(u32 *)(prim + 0x24) = D_80182C50; + *(u32 *)(prim + 0x28) = D_80182C5C; + *(u32 *)(prim + 0x2c) = D_80182C54; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80182C60[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80182C60[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80182C60[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80182C60[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80182CDC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80182CDC[a1 & 0x7F]; +} + + + +extern s32 D_80182CFC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80182CFC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80182D78[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80182D78[a1 & 0x7F]; +} + + + +extern u8 D_80182D98[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182D98[a1 & 0x7F]; +} + + + +extern u8 D_80182DB8[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182DB8[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80182DD8[])(void); + D_80182DD8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80182E54[])(void); + +void func_80165AC8(void) { + D_80182E54[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80182ED0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80182ED0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801A524C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801A524C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80182EDC[])(void); + +void func_80166018(void *a0) { + D_80182EDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80182EE4[])(void); + +void func_801663FC(void *a0) { + D_80182EE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182FAC[])(void); + +void func_80166618(void *a0) { + D_80182FAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182FBC[])(void); + +void func_80166654(void *a0) { + D_80182FBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A5B28[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A5B28[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A5B28). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A5B28[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A5B28)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A5B28[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A5B28[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80182F00[]; + extern u8 D_80182EEC[]; + extern u8 D_80182F14[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80182F00; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80182EEC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182F14; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80167714); + + +extern void (*D_80182FCC[])(void); + +void func_801678B4(void *a0) { + D_80182FCC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80182FD8[])(void); + +void func_80167A9C(void *a0) { + D_80182FD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801830E4; + extern u8 D_801830F8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801830E4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801830F8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80182F38[]; +extern u8 D_80182F4C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80182F38; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80182F4C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80182FF0[])(void); + +void func_80168744(void *a0) { + D_80182FF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80182FE0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80182FE0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80182FE0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80182FF8[])(void); + +void func_801689D8(void *a0) { + D_80182FF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80183000[])(void); + +void func_80168AA8(void *a0) { + D_80183000[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80183008[])(void); + +void func_80168D58(void *a0) { + D_80183008[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80183010[])(void); + +void func_8016901C(void *a0) { + D_80183010[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_016/nonmatchings/ov_SC04_016_jr_8015C32C", func_80169228); + + +extern void (*D_80183018[])(void); + +void func_801693CC(void *a0) { + D_80183018[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80183020[])(void); + +void func_80169830(void *a0) { + D_80183020[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801830D4[])(void); + +void func_80169B80(void *a0) { + D_801830D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80183028[]; + extern u8 D_80183098[]; + extern u8 D_801830C8[]; + extern u8 D_801AC198[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801830C8, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80183028[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801AC198; + RotMatrixYXZ(rot, D_801AC198); + func_80048D9C(D_801AC198, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80183098); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801830DC[])(void); + +void func_80169F00(void *a0) { + D_801830DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018308C[]; +extern char D_8018304C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018308C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018304C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80183114[])(void); + +void func_8016A020(void *a0) { + D_80183114[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801830E4; + extern u8 D_801830F8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801830E4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801830F8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80183120[])(void); + +void func_8016A700(void *a0) { + D_80183120[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80183168[])(void); + +void func_8016AB30(void *a0) { + D_80183168[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_018/ov_SC04_018_jr_8015AE2C.c b/src/ov_SC04_018/ov_SC04_018_jr_8015AE2C.c index a8197b173..69e5a67f6 100644 --- a/src/ov_SC04_018/ov_SC04_018_jr_8015AE2C.c +++ b/src/ov_SC04_018/ov_SC04_018_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018FA3C[])(void); - -void func_8015C714(void *a0) { - D_8018FA3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018F8B0[])(void*); - extern int D_8018F854; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F854); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018F8B0[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018F8B0[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018F8B0[])(void*); - extern int D_8018F854; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F854); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018FA4C[])(void); - D_8018FA4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018F8B0[])(struct Ent_8015CD20 *); - extern u8 D_8018F864; - extern u8 D_8018FA54; - extern u8 D_8018FA64; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018F8B0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F864); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA54); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA64); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018F8B0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018FA84[])(void); - D_8018FA84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018FA74; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018FA74 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018F8B0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018FAE0; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018FAE0, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018EBC4[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018EBC4; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018FAE8[])(void); - D_8018FAE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018FAF4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018FAF4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018FAF4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018FAF4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018F8B0[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018FAF4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018F874[]; - extern u8 D_8018F884[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F874); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F884); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018FB28[])(void); - D_8018FB28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018F8B0[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018FB30[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018FB48[])(void); - D_8018FB48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018F8B0[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018FB30[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018FB68[])(void); - D_8018FB68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018F8B0[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018F8B0)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018FB78; -extern u16 D_8018FB7A; -extern u16 D_8018FB7C; -extern s32 D_8018FB80; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018FB78 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018FB7A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018FB7C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018FB80, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018FB88; - -void func_8015E588(void) { - func_8013C9C4(&D_8018FB88); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018F8B0[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018F8B0)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018FB9C[])(void); - D_8018FB9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018F8B0[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018F8B0[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018FBA4[])(void); - D_8018FBA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018F894; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018F894); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018F8B0[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018FBAC[])(void); - D_8018FBAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018F8B0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018F8B0[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018FBB4[])(void); - D_8018FBB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018F8B0[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018FBBC; - extern s32 D_8018FBCC; - extern s32 D_8018FBDC; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018F8B0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBBC); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBCC); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018F8B0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBDC); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018FBEC[])(void); - D_8018FBEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018F8B0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018F8B0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018FBF8[])(void); - D_8018FBF8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018F8B0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018F8B0[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018F8B0[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018FC0C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018FC0C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018F8B0[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018F8B0)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018F8B0[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018F8B0[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018FC88[])(void); - D_8018FC88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018F8B0[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018F8B0)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018FC98[])(void); - D_8018FC98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018F8B0[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018F8B0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018F8B0[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018F8B0[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018F8B0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018F8B0[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018F8B0[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018FCA0[])(void); - D_8018FCA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018F8B0[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018F8B0)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018F8B0[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018FCAC[])(void); - D_8018FCAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018F8B0 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018F8B0[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018F8B0[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018F8B0[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018FCBC[])(void); - -void func_80160EA4(void *a0) { - D_8018FCBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018F8B0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018F8B0[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018FCEC[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018FCEC[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018FD50; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018FD50); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E5C00[]; - extern u8 D_8018FD1C[]; - extern u8 D_8018FD3C[]; - extern u8 D_801E5C0C[]; - extern u8 D_801E5C34[]; - extern u8 D_801E5C4C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E5C00[0] = p; - func_80024054(&D_8018FD1C, &D_801E5C0C); - func_8001CE28(p, &D_801E5C0C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E5C00[1] = p; - func_80024054(&D_8018FD3C, &D_801E5C34); - func_8001CE28(p, &D_801E5C34); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E5C00[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E5C4C, 0x84); - func_8001CE68(p, &D_801E5C4C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E5C4C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E5C00[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E5C00; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018FD50; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018FD50; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018FD50; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018FD50; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E5C00[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E5C00; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018FD74[])(void); - -void func_80162330(void *a0) { - D_8018FD74[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E5C58[i] via `extern int D_801E5C58[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018FD80[]; - extern s32 D_8018FD98; - extern u8 D_801E5C64[]; - extern u8 D_801E5C8C[]; - extern u8 D_801E5CA8[]; - extern int D_801E5C58[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E5C58[0] = (s32)item; - func_80024054(D_8018FD80, D_801E5C64); - func_8001CE28(item, D_801E5C64); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E5C58[1] = (s32)item; - func_80024054(((u8 *)&D_8018FD98), D_801E5C8C); - func_8001CE28(item, D_801E5C8C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E5C58[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E5CA8, 0x84); - func_8001CE68(item, D_801E5CA8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E5CA8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E5C58[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E5C58; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018FDBC[])(void); - -void func_80162834(void *a0) { - D_8018FDBC[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018FDAC; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018FDAC, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E5054[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E5054, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E5054[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E5054, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018FDC4[])(void); - -void func_80163A58(void *a0) { - D_8018FDC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E505C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E505C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018FE18[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018FE18[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018FDE0; -extern s16 D_8018FE14; -extern s16 D_8018FE12; -extern s16 D_8018FE10; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018FDE0; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018FE14 = 0x80; - D_8018FE12 = 0x80; - D_8018FE10 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018FE14 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018FE14` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018FE14 - 8; - D_8018FE14 = nv; - D_8018FE12 = nv; - D_8018FE10 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018FE24[])(void); - -void func_80164BA0(void *a0) { - D_8018FE24[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E5CB8; -extern u8 D_801E5CB9; -extern u8 D_801E5CBA; -extern u8 D_801E5CBB; -extern u8 D_801E5CBC; -extern u8 D_801E5CBD; -extern u8 D_801E5CBE; -extern u8 D_801E5CBF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E5CB8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E5CB9 = 0xf0; - *(u8 *)base = 0xf0; - D_801E5CBA = 0xc0; - D_801E5CBE = 0; - D_801E5CBD = 0; - D_801E5CBC = 0; - D_801E5CBF = 0; - D_801E5CBB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E5CB8; -extern u8 D_801E5CB9; -extern u8 D_801E5CBA; - -s32 func_80164E40(void) { - u8 *p = &D_801E5CB8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E5CB9 != 0) { - D_801E5CB9 -= 0x10; - } - if (D_801E5CBA != 0) { - D_801E5CBA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018FE34[])(void); - -void func_80164EA4(void *a0) { - D_8018FE34[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E5D04[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E5D04[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E5CF8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E5CF8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E5CF8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E5CF8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E5CF8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018FE48[]; - extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; - extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; - extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; - extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018FE48[0x00], p); - ApplyMatrixSV(mat, &D_8018FE48[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018FE48[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018FE48[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018FE70; - *(u32 *)(prim + 0x24) = D_8018FE68; - *(u32 *)(prim + 0x28) = D_8018FE74; - *(u32 *)(prim + 0x2c) = D_8018FE6C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018FE78[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018FE78[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018FE78[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018FE78[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018FEF4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018FEF4[a1 & 0x7F]; -} - - - -extern s32 D_8018FF14[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018FF14[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018FF90[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018FF90[a1 & 0x7F]; -} - - - -extern u8 D_8018FFB0[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018FFB0[a1 & 0x7F]; -} - - - -extern u8 D_8018FFD0[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018FFD0[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018FFF0[])(void); - D_8018FFF0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8019006C[])(void); - -void func_80165AC8(void) { - D_8019006C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801900E8[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801900E8[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E5064; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E5064, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801900F4[])(void); - -void func_80166018(void *a0) { - D_801900F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801900FC[])(void); - -void func_801663FC(void *a0) { - D_801900FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801901C4[])(void); - -void func_80166618(void *a0) { - D_801901C4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801901D4[])(void); - -void func_80166654(void *a0) { - D_801901D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E5D78[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E5D78[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E5D78). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E5D78[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E5D78)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E5D78[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E5D78[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80190118[]; - extern u8 D_80190104[]; - extern u8 D_8019012C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80190118; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80190104; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8019012C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80167714); - - -extern void (*D_801901E4[])(void); - -void func_801678B4(void *a0) { - D_801901E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801901F0[])(void); - -void func_80167A9C(void *a0) { - D_801901F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801902FC; - extern u8 D_80190310[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801902FC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80190310; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80190150[]; -extern u8 D_80190164[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80190150; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80190164; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80190208[])(void); - -void func_80168744(void *a0) { - D_80190208[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801901F8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801901F8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801901F8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80190210[])(void); - -void func_801689D8(void *a0) { - D_80190210[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80190218[])(void); - -void func_80168AA8(void *a0) { - D_80190218[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80190220[])(void); - -void func_80168D58(void *a0) { - D_80190220[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80190228[])(void); - -void func_8016901C(void *a0) { - D_80190228[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015AE2C", func_80169228); - - -extern void (*D_80190230[])(void); - -void func_801693CC(void *a0) { - D_80190230[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80190238[])(void); - -void func_80169830(void *a0) { - D_80190238[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801902EC[])(void); - -void func_80169B80(void *a0) { - D_801902EC[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80190240[]; - extern u8 D_801902B0[]; - extern u8 D_801902E0[]; - extern u8 D_801E79B8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801902E0, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80190240[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801E79B8; - RotMatrixYXZ(rot, D_801E79B8); - func_80048D9C(D_801E79B8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801902B0); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801902F4[])(void); - -void func_80169F00(void *a0) { - D_801902F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801902A4[]; -extern char D_80190264[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801902A4, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80190264); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8019032C[])(void); - -void func_8016A020(void *a0) { - D_8019032C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801902FC; - extern u8 D_80190310[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801902FC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80190310; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80190338[])(void); - -void func_8016A700(void *a0) { - D_80190338[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80190380[])(void); - -void func_8016AB30(void *a0) { - D_80190380[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c b/src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c new file mode 100644 index 000000000..085a3b5c8 --- /dev/null +++ b/src/ov_SC04_018/ov_SC04_018_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018F74C; +extern u8 D_8018F6BC; +extern u8 D_8018F698; +extern u8 D_8018F674; +extern u8 D_8018F728; +extern u8 D_8018F704; +extern u8 D_8018F6E0; +extern u8 D_8018F650; +extern void func_80145934(void); +extern u8 D_8018F7DC; +extern u8 D_8018F7B8; +extern u8 D_8018F794; +extern u8 D_8018F770; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018EBD4[]; +extern unsigned char D_8018EC04[]; +extern unsigned char D_8018EC54[]; +extern unsigned char D_8018EC84[]; +extern unsigned char D_8018ECB4[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018ED04[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018EDCC[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018EE54[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018EE5C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E5BA8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E5BAC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018EE8C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018EF34[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018EF58[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018EF48; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018EF6C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018EF78[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018EF88[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018EFA0[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018EF90; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018EFB4[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018EFD0[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018EFC0; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018EFE4[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018EFF8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018F00C; +extern void (*D_8018F034[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018F014; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018F080[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018F084[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018F4E8[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018F4F8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E5BE0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018F520[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018F500; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018F510; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018F560[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018F568[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018F534; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018F574[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018F544; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E5BE8; +extern s32 D_801E5BF4; +extern s32 D_801E5BF8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018F5B0[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018F584[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E5BF0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018F800[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018F620[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018F8A4[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018F9F8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018F814; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018FA00[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018F824; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018F844; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018FA08[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018FA30[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018F8B0[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018FA3C[])(void); + +void func_8015C714(void *a0) { + D_8018FA3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018F8B0[])(void*); + extern int D_8018F854; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F854); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018F8B0[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018F8B0[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018F8B0[])(void*); + extern int D_8018F854; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F854); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018FA4C[])(void); + D_8018FA4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018F8B0[])(struct Ent_8015CD20 *); + extern u8 D_8018F864; + extern u8 D_8018FA54; + extern u8 D_8018FA64; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018F8B0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F864); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA54); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA64); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018F8B0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018FA84[])(void); + D_8018FA84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018FA74; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018FA74 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018F8B0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018FAE0; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018FAE0, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018EBC4[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018EBC4; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018FAE8[])(void); + D_8018FAE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018FAF4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018FAF4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018FAF4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018FAF4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018F8B0[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018FAF4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018F874[]; + extern u8 D_8018F884[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F874); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F884); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018FB28[])(void); + D_8018FB28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018F8B0[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018FB30[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018FB48[])(void); + D_8018FB48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018F8B0[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018FB30[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018FB68[])(void); + D_8018FB68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018F8B0[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018F8B0)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018FB78; +extern u16 D_8018FB7A; +extern u16 D_8018FB7C; +extern s32 D_8018FB80; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018FB78 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018FB7A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018FB7C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018FB80, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018FB88; + +void func_8015E588(void) { + func_8013C9C4(&D_8018FB88); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018F8B0[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018F8B0)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018FB9C[])(void); + D_8018FB9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018F8B0[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018F8B0[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018FBA4[])(void); + D_8018FBA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018F894; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018F894); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018F8B0[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018FBAC[])(void); + D_8018FBAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018F8B0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018F8B0[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018FBB4[])(void); + D_8018FBB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018F8B0[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018FBBC; + extern s32 D_8018FBCC; + extern s32 D_8018FBDC; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBBC); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBCC); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBDC); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018FBEC[])(void); + D_8018FBEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018F8B0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018F8B0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018FBF8[])(void); + D_8018FBF8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018F8B0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018F8B0[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018F8B0[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018FC0C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018FC0C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018F8B0[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018F8B0)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018F8B0[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018F8B0[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018FC88[])(void); + D_8018FC88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018F8B0[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018F8B0)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018FC98[])(void); + D_8018FC98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018F8B0[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018F8B0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018F8B0[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018F8B0[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018F8B0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018F8B0[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018F8B0[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018FCA0[])(void); + D_8018FCA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018F8B0[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018F8B0)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018F8B0[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018FCAC[])(void); + D_8018FCAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018F8B0 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018F8B0[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018F8B0[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018F8B0[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018FCBC[])(void); + +void func_80160EA4(void *a0) { + D_8018FCBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018F8B0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018F8B0[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018FCEC[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018FCEC[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018FD50; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018FD50); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E5C00[]; + extern u8 D_8018FD1C[]; + extern u8 D_8018FD3C[]; + extern u8 D_801E5C0C[]; + extern u8 D_801E5C34[]; + extern u8 D_801E5C4C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E5C00[0] = p; + func_80024054(&D_8018FD1C, &D_801E5C0C); + func_8001CE28(p, &D_801E5C0C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E5C00[1] = p; + func_80024054(&D_8018FD3C, &D_801E5C34); + func_8001CE28(p, &D_801E5C34); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E5C00[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E5C4C, 0x84); + func_8001CE68(p, &D_801E5C4C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E5C4C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E5C00[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E5C00; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018FD50; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018FD50; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018FD50; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018FD50; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E5C00[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E5C00; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018FD74[])(void); + +void func_80162330(void *a0) { + D_8018FD74[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E5C58[i] via `extern int D_801E5C58[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018FD80[]; + extern s32 D_8018FD98; + extern u8 D_801E5C64[]; + extern u8 D_801E5C8C[]; + extern u8 D_801E5CA8[]; + extern int D_801E5C58[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E5C58[0] = (s32)item; + func_80024054(D_8018FD80, D_801E5C64); + func_8001CE28(item, D_801E5C64); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E5C58[1] = (s32)item; + func_80024054(((u8 *)&D_8018FD98), D_801E5C8C); + func_8001CE28(item, D_801E5C8C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E5C58[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E5CA8, 0x84); + func_8001CE68(item, D_801E5CA8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E5CA8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E5C58[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E5C58; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_801627E8); + + +extern void (*D_8018FDBC[])(void); + +void func_80162834(void *a0) { + D_8018FDBC[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018FDAC; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018FDAC, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E5054[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E5054, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E5054[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E5054, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018FDC4[])(void); + +void func_80163A58(void *a0) { + D_8018FDC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E505C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E505C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018FE18[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018FE18[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018FDE0; +extern s16 D_8018FE14; +extern s16 D_8018FE12; +extern s16 D_8018FE10; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018FDE0; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018FE14 = 0x80; + D_8018FE12 = 0x80; + D_8018FE10 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018FE14 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018FE14` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018FE14 - 8; + D_8018FE14 = nv; + D_8018FE12 = nv; + D_8018FE10 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018FE24[])(void); + +void func_80164BA0(void *a0) { + D_8018FE24[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E5CB8; +extern u8 D_801E5CB9; +extern u8 D_801E5CBA; +extern u8 D_801E5CBB; +extern u8 D_801E5CBC; +extern u8 D_801E5CBD; +extern u8 D_801E5CBE; +extern u8 D_801E5CBF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E5CB8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E5CB9 = 0xf0; + *(u8 *)base = 0xf0; + D_801E5CBA = 0xc0; + D_801E5CBE = 0; + D_801E5CBD = 0; + D_801E5CBC = 0; + D_801E5CBF = 0; + D_801E5CBB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E5CB8; +extern u8 D_801E5CB9; +extern u8 D_801E5CBA; + +s32 func_80164E40(void) { + u8 *p = &D_801E5CB8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E5CB9 != 0) { + D_801E5CB9 -= 0x10; + } + if (D_801E5CBA != 0) { + D_801E5CBA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018FE34[])(void); + +void func_80164EA4(void *a0) { + D_8018FE34[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E5D04[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E5D04[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E5CF8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E5CF8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E5CF8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E5CF8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E5CF8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018FE48[]; + extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; + extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; + extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; + extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018FE48[0x00], p); + ApplyMatrixSV(mat, &D_8018FE48[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018FE48[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018FE48[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018FE70; + *(u32 *)(prim + 0x24) = D_8018FE68; + *(u32 *)(prim + 0x28) = D_8018FE74; + *(u32 *)(prim + 0x2c) = D_8018FE6C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018FE78[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018FE78[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018FE78[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018FE78[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018FEF4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018FEF4[a1 & 0x7F]; +} + + + +extern s32 D_8018FF14[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018FF14[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018FF90[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018FF90[a1 & 0x7F]; +} + + + +extern u8 D_8018FFB0[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018FFB0[a1 & 0x7F]; +} + + + +extern u8 D_8018FFD0[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018FFD0[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018FFF0[])(void); + D_8018FFF0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8019006C[])(void); + +void func_80165AC8(void) { + D_8019006C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801900E8[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801900E8[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E5064; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E5064, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801900F4[])(void); + +void func_80166018(void *a0) { + D_801900F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801900FC[])(void); + +void func_801663FC(void *a0) { + D_801900FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801901C4[])(void); + +void func_80166618(void *a0) { + D_801901C4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801901D4[])(void); + +void func_80166654(void *a0) { + D_801901D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E5D78[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E5D78[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E5D78). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E5D78[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E5D78)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E5D78[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E5D78[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80190118[]; + extern u8 D_80190104[]; + extern u8 D_8019012C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80190118; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80190104; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8019012C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80167714); + + +extern void (*D_801901E4[])(void); + +void func_801678B4(void *a0) { + D_801901E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801901F0[])(void); + +void func_80167A9C(void *a0) { + D_801901F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801902FC; + extern u8 D_80190310[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801902FC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80190310; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80190150[]; +extern u8 D_80190164[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80190150; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80190164; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80190208[])(void); + +void func_80168744(void *a0) { + D_80190208[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801901F8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801901F8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801901F8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80190210[])(void); + +void func_801689D8(void *a0) { + D_80190210[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80190218[])(void); + +void func_80168AA8(void *a0) { + D_80190218[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80190220[])(void); + +void func_80168D58(void *a0) { + D_80190220[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80190228[])(void); + +void func_8016901C(void *a0) { + D_80190228[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_018/nonmatchings/ov_SC04_018_jr_8015C32C", func_80169228); + + +extern void (*D_80190230[])(void); + +void func_801693CC(void *a0) { + D_80190230[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80190238[])(void); + +void func_80169830(void *a0) { + D_80190238[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801902EC[])(void); + +void func_80169B80(void *a0) { + D_801902EC[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80190240[]; + extern u8 D_801902B0[]; + extern u8 D_801902E0[]; + extern u8 D_801E79B8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801902E0, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80190240[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801E79B8; + RotMatrixYXZ(rot, D_801E79B8); + func_80048D9C(D_801E79B8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801902B0); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801902F4[])(void); + +void func_80169F00(void *a0) { + D_801902F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801902A4[]; +extern char D_80190264[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801902A4, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80190264); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8019032C[])(void); + +void func_8016A020(void *a0) { + D_8019032C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801902FC; + extern u8 D_80190310[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801902FC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80190310; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80190338[])(void); + +void func_8016A700(void *a0) { + D_80190338[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80190380[])(void); + +void func_8016AB30(void *a0) { + D_80190380[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_019/ov_SC04_019_jr_8015AE2C.c b/src/ov_SC04_019/ov_SC04_019_jr_8015AE2C.c index ea67771c2..ad0874c2a 100644 --- a/src/ov_SC04_019/ov_SC04_019_jr_8015AE2C.c +++ b/src/ov_SC04_019/ov_SC04_019_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018FA3C[])(void); - -void func_8015C714(void *a0) { - D_8018FA3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018F8B0[])(void*); - extern int D_8018F854; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F854); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018F8B0[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018F8B0[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018F8B0[])(void*); - extern int D_8018F854; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F854); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018FA4C[])(void); - D_8018FA4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018F8B0[])(struct Ent_8015CD20 *); - extern u8 D_8018F864; - extern u8 D_8018FA54; - extern u8 D_8018FA64; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018F8B0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F864); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA54); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA64); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018F8B0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018FA84[])(void); - D_8018FA84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018FA74; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018FA74 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018F8B0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018FAE0; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018FAE0, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018EBC4[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018EBC4; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018FAE8[])(void); - D_8018FAE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018FAF4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018FAF4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018FAF4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018FAF4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018F8B0[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018FAF4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018F874[]; - extern u8 D_8018F884[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F874); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F884); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018FB28[])(void); - D_8018FB28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018F8B0[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018FB30[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018FB48[])(void); - D_8018FB48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018F8B0[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018FB30[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018FB68[])(void); - D_8018FB68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018F8B0[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018F8B0)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018FB78; -extern u16 D_8018FB7A; -extern u16 D_8018FB7C; -extern s32 D_8018FB80; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018FB78 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018FB7A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018FB7C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018FB80, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018FB88; - -void func_8015E588(void) { - func_8013C9C4(&D_8018FB88); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018F8B0[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018F8B0)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018FB9C[])(void); - D_8018FB9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018F8B0[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018F8B0[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018FBA4[])(void); - D_8018FBA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018F894; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018F894); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018F8B0[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018FBAC[])(void); - D_8018FBAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018F8B0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018F8B0[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018FBB4[])(void); - D_8018FBB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018F8B0[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018FBBC; - extern s32 D_8018FBCC; - extern s32 D_8018FBDC; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018F8B0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBBC); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBCC); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018F8B0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBDC); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018FBEC[])(void); - D_8018FBEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018F8B0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018F8B0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018F8B0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018FBF8[])(void); - D_8018FBF8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018F8B0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018F8B0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018F8B0[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018F8B0[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018FC0C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018FC0C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018F8B0[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018F8B0)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018F8B0[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018F8B0[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018FC88[])(void); - D_8018FC88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018F8B0[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018F8B0)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018FC98[])(void); - D_8018FC98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018F8B0[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018F8B0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018F8B0[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018F8B0[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018F8B0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018F8B0[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018F8B0[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018FCA0[])(void); - D_8018FCA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018F8B0[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018F8B0)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018F8B0[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018FCAC[])(void); - D_8018FCAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018F8B0 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018F8B0[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018F8B0[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018F8B0[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018FCBC[])(void); - -void func_80160EA4(void *a0) { - D_8018FCBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018F8B0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018F8B0[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018FCEC[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018FCEC[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018FD50; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018FD50); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E5C00[]; - extern u8 D_8018FD1C[]; - extern u8 D_8018FD3C[]; - extern u8 D_801E5C0C[]; - extern u8 D_801E5C34[]; - extern u8 D_801E5C4C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E5C00[0] = p; - func_80024054(&D_8018FD1C, &D_801E5C0C); - func_8001CE28(p, &D_801E5C0C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E5C00[1] = p; - func_80024054(&D_8018FD3C, &D_801E5C34); - func_8001CE28(p, &D_801E5C34); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E5C00[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E5C4C, 0x84); - func_8001CE68(p, &D_801E5C4C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E5C4C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E5C00[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E5C00; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018FD50; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018FD50; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018FD50; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018FD50; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E5C00[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E5C00; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018FD74[])(void); - -void func_80162330(void *a0) { - D_8018FD74[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E5C58[i] via `extern int D_801E5C58[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018FD80[]; - extern s32 D_8018FD98; - extern u8 D_801E5C64[]; - extern u8 D_801E5C8C[]; - extern u8 D_801E5CA8[]; - extern int D_801E5C58[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E5C58[0] = (s32)item; - func_80024054(D_8018FD80, D_801E5C64); - func_8001CE28(item, D_801E5C64); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E5C58[1] = (s32)item; - func_80024054(((u8 *)&D_8018FD98), D_801E5C8C); - func_8001CE28(item, D_801E5C8C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E5C58[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E5CA8, 0x84); - func_8001CE68(item, D_801E5CA8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E5CA8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E5C58[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E5C58; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018FDBC[])(void); - -void func_80162834(void *a0) { - D_8018FDBC[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018FDAC; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018FDAC, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E5054[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E5054, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E5054[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E5054, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018FDC4[])(void); - -void func_80163A58(void *a0) { - D_8018FDC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E505C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E505C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018FE18[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018FE18[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018FDE0; -extern s16 D_8018FE14; -extern s16 D_8018FE12; -extern s16 D_8018FE10; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018FDE0; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018FE14 = 0x80; - D_8018FE12 = 0x80; - D_8018FE10 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018FE14 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018FE14` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018FE14 - 8; - D_8018FE14 = nv; - D_8018FE12 = nv; - D_8018FE10 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018FE24[])(void); - -void func_80164BA0(void *a0) { - D_8018FE24[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E5CB8; -extern u8 D_801E5CB9; -extern u8 D_801E5CBA; -extern u8 D_801E5CBB; -extern u8 D_801E5CBC; -extern u8 D_801E5CBD; -extern u8 D_801E5CBE; -extern u8 D_801E5CBF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E5CB8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E5CB9 = 0xf0; - *(u8 *)base = 0xf0; - D_801E5CBA = 0xc0; - D_801E5CBE = 0; - D_801E5CBD = 0; - D_801E5CBC = 0; - D_801E5CBF = 0; - D_801E5CBB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E5CB8; -extern u8 D_801E5CB9; -extern u8 D_801E5CBA; - -s32 func_80164E40(void) { - u8 *p = &D_801E5CB8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E5CB9 != 0) { - D_801E5CB9 -= 0x10; - } - if (D_801E5CBA != 0) { - D_801E5CBA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018FE34[])(void); - -void func_80164EA4(void *a0) { - D_8018FE34[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E5D04[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E5D04[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E5CF8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E5CF8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E5CF8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E5CF8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E5CF8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018FE48[]; - extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; - extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; - extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; - extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018FE48[0x00], p); - ApplyMatrixSV(mat, &D_8018FE48[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018FE48[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018FE48[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018FE70; - *(u32 *)(prim + 0x24) = D_8018FE68; - *(u32 *)(prim + 0x28) = D_8018FE74; - *(u32 *)(prim + 0x2c) = D_8018FE6C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018FE78[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018FE78[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018FE78[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018FE78[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018FEF4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018FEF4[a1 & 0x7F]; -} - - - -extern s32 D_8018FF14[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018FF14[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018FF90[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018FF90[a1 & 0x7F]; -} - - - -extern u8 D_8018FFB0[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018FFB0[a1 & 0x7F]; -} - - - -extern u8 D_8018FFD0[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018FFD0[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018FFF0[])(void); - D_8018FFF0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8019006C[])(void); - -void func_80165AC8(void) { - D_8019006C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801900E8[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801900E8[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E5064; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E5064, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801900F4[])(void); - -void func_80166018(void *a0) { - D_801900F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801900FC[])(void); - -void func_801663FC(void *a0) { - D_801900FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801901C4[])(void); - -void func_80166618(void *a0) { - D_801901C4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801901D4[])(void); - -void func_80166654(void *a0) { - D_801901D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E5D78[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E5D78[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E5D78). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E5D78[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E5D78)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E5D78[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E5D78[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80190118[]; - extern u8 D_80190104[]; - extern u8 D_8019012C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80190118; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80190104; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8019012C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80167714); - - -extern void (*D_801901E4[])(void); - -void func_801678B4(void *a0) { - D_801901E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801901F0[])(void); - -void func_80167A9C(void *a0) { - D_801901F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801902FC; - extern u8 D_80190310[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801902FC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80190310; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80190150[]; -extern u8 D_80190164[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80190150; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80190164; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80190208[])(void); - -void func_80168744(void *a0) { - D_80190208[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801901F8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801901F8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801901F8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80190210[])(void); - -void func_801689D8(void *a0) { - D_80190210[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80190218[])(void); - -void func_80168AA8(void *a0) { - D_80190218[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80190220[])(void); - -void func_80168D58(void *a0) { - D_80190220[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80190228[])(void); - -void func_8016901C(void *a0) { - D_80190228[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015AE2C", func_80169228); - - -extern void (*D_80190230[])(void); - -void func_801693CC(void *a0) { - D_80190230[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80190238[])(void); - -void func_80169830(void *a0) { - D_80190238[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801902EC[])(void); - -void func_80169B80(void *a0) { - D_801902EC[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80190240[]; - extern u8 D_801902B0[]; - extern u8 D_801902E0[]; - extern u8 D_801E79B8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801902E0, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80190240[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801E79B8; - RotMatrixYXZ(rot, D_801E79B8); - func_80048D9C(D_801E79B8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801902B0); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801902F4[])(void); - -void func_80169F00(void *a0) { - D_801902F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801902A4[]; -extern char D_80190264[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801902A4, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80190264); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8019032C[])(void); - -void func_8016A020(void *a0) { - D_8019032C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801902FC; - extern u8 D_80190310[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801902FC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80190310; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80190338[])(void); - -void func_8016A700(void *a0) { - D_80190338[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80190380[])(void); - -void func_8016AB30(void *a0) { - D_80190380[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c b/src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c new file mode 100644 index 000000000..9222bd580 --- /dev/null +++ b/src/ov_SC04_019/ov_SC04_019_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018F74C; +extern u8 D_8018F6BC; +extern u8 D_8018F698; +extern u8 D_8018F674; +extern u8 D_8018F728; +extern u8 D_8018F704; +extern u8 D_8018F6E0; +extern u8 D_8018F650; +extern void func_80145934(void); +extern u8 D_8018F7DC; +extern u8 D_8018F7B8; +extern u8 D_8018F794; +extern u8 D_8018F770; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018EBD4[]; +extern unsigned char D_8018EC04[]; +extern unsigned char D_8018EC54[]; +extern unsigned char D_8018EC84[]; +extern unsigned char D_8018ECB4[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018ED04[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018EDCC[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018EE54[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018EE5C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E5BA8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E5BAC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018EE8C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018EF34[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018EF58[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018EF48; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018EF6C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018EF78[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018EF88[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018EFA0[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018EF90; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018EFB4[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018EFD0[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018EFC0; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018EFE4[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018EFF8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018F00C; +extern void (*D_8018F034[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018F014; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018F080[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018F084[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018F4E8[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018F4F8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E5BE0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018F520[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018F500; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018F510; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018F560[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018F568[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018F534; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018F574[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018F544; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E5BE8; +extern s32 D_801E5BF4; +extern s32 D_801E5BF8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018F5B0[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018F584[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E5BF0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018F800[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018F620[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018F8A4[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018F9F8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018F814; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018FA00[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018F824; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018F844; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018FA08[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018FA30[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018F8B0[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018FA3C[])(void); + +void func_8015C714(void *a0) { + D_8018FA3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018F8B0[])(void*); + extern int D_8018F854; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F854); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018F8B0[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018F8B0[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018F8B0[])(void*); + extern int D_8018F854; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F854); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018FA4C[])(void); + D_8018FA4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018F8B0[])(struct Ent_8015CD20 *); + extern u8 D_8018F864; + extern u8 D_8018FA54; + extern u8 D_8018FA64; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018F8B0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F864); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA54); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA64); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018F8B0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018FA84[])(void); + D_8018FA84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018FA74; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018FA74 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018F8B0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018FAE0; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018FAE0, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018EBC4[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018EBC4; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018FAE8[])(void); + D_8018FAE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018FAF4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018FAF4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018FAF4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018FAF4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018F8B0[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018FAF4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018F874[]; + extern u8 D_8018F884[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F874); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F884); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018FAF4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018FB28[])(void); + D_8018FB28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018F8B0[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018FB30[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018FB48[])(void); + D_8018FB48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018F8B0[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018FB30[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018FB30[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018FB68[])(void); + D_8018FB68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018F8B0[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018F8B0)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018FB78; +extern u16 D_8018FB7A; +extern u16 D_8018FB7C; +extern s32 D_8018FB80; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018FB78 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018FB7A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018FB7C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018FB80, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018FB88; + +void func_8015E588(void) { + func_8013C9C4(&D_8018FB88); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018F8B0[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018F8B0)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018FB9C[])(void); + D_8018FB9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018F8B0[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018F8B0[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018FBA4[])(void); + D_8018FBA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018F894; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018F894); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018F8B0[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018FBAC[])(void); + D_8018FBAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018F8B0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018F8B0[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018FBB4[])(void); + D_8018FBB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018F8B0[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018FBBC; + extern s32 D_8018FBCC; + extern s32 D_8018FBDC; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBBC); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBCC); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018F8B0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBDC); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018FBEC[])(void); + D_8018FBEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018F8B0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018F8B0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018F8B0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018FBF8[])(void); + D_8018FBF8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018F8B0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018F8B0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018F8B0[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018F8B0[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018FC0C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018FC0C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018F8B0[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018F8B0)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018F8B0[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018F8B0[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018FC88[])(void); + D_8018FC88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018F8B0[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018F8B0)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018FC98[])(void); + D_8018FC98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018F8B0[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018F8B0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018F8B0[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018F8B0[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018F8B0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018F8B0[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018F8B0[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018FCA0[])(void); + D_8018FCA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018F8B0[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018F8B0)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018F8B0[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018F8B0)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018FCAC[])(void); + D_8018FCAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018F8B0 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018F8B0[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018F8B0[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018F8B0[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018FCBC[])(void); + +void func_80160EA4(void *a0) { + D_8018FCBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018F8B0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018F8B0[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018FCEC[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018FCEC[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018FD50; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018FD50); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E5C00[]; + extern u8 D_8018FD1C[]; + extern u8 D_8018FD3C[]; + extern u8 D_801E5C0C[]; + extern u8 D_801E5C34[]; + extern u8 D_801E5C4C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E5C00[0] = p; + func_80024054(&D_8018FD1C, &D_801E5C0C); + func_8001CE28(p, &D_801E5C0C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E5C00[1] = p; + func_80024054(&D_8018FD3C, &D_801E5C34); + func_8001CE28(p, &D_801E5C34); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E5C00[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E5C4C, 0x84); + func_8001CE68(p, &D_801E5C4C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E5C4C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E5C00[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E5C00; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018FD50; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018FD50; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018FD50; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018FD50; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E5C00[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E5C00; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018FD74[])(void); + +void func_80162330(void *a0) { + D_8018FD74[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E5C58[i] via `extern int D_801E5C58[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018FD80[]; + extern s32 D_8018FD98; + extern u8 D_801E5C64[]; + extern u8 D_801E5C8C[]; + extern u8 D_801E5CA8[]; + extern int D_801E5C58[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E5C58[0] = (s32)item; + func_80024054(D_8018FD80, D_801E5C64); + func_8001CE28(item, D_801E5C64); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E5C58[1] = (s32)item; + func_80024054(((u8 *)&D_8018FD98), D_801E5C8C); + func_8001CE28(item, D_801E5C8C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E5C58[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E5CA8, 0x84); + func_8001CE68(item, D_801E5CA8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E5CA8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E5C58[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E5C58; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_801627E8); + + +extern void (*D_8018FDBC[])(void); + +void func_80162834(void *a0) { + D_8018FDBC[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018FDAC; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018FDAC, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E5054[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E5054, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E5054[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E5054, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018FDC4[])(void); + +void func_80163A58(void *a0) { + D_8018FDC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E505C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E505C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018FE18[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018FE18[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018FDE0; +extern s16 D_8018FE14; +extern s16 D_8018FE12; +extern s16 D_8018FE10; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018FDE0; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018FE14 = 0x80; + D_8018FE12 = 0x80; + D_8018FE10 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018FE14 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018FE14` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018FE14 - 8; + D_8018FE14 = nv; + D_8018FE12 = nv; + D_8018FE10 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018FE24[])(void); + +void func_80164BA0(void *a0) { + D_8018FE24[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E5CB8; +extern u8 D_801E5CB9; +extern u8 D_801E5CBA; +extern u8 D_801E5CBB; +extern u8 D_801E5CBC; +extern u8 D_801E5CBD; +extern u8 D_801E5CBE; +extern u8 D_801E5CBF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E5CB8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E5CB9 = 0xf0; + *(u8 *)base = 0xf0; + D_801E5CBA = 0xc0; + D_801E5CBE = 0; + D_801E5CBD = 0; + D_801E5CBC = 0; + D_801E5CBF = 0; + D_801E5CBB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E5CB8; +extern u8 D_801E5CB9; +extern u8 D_801E5CBA; + +s32 func_80164E40(void) { + u8 *p = &D_801E5CB8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E5CB9 != 0) { + D_801E5CB9 -= 0x10; + } + if (D_801E5CBA != 0) { + D_801E5CBA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018FE34[])(void); + +void func_80164EA4(void *a0) { + D_8018FE34[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E5D04[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E5D04[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E5CF8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E5CF8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E5CF8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E5CF8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E5CF8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018FE48[]; + extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; + extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; + extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; + extern u32 D_8018FE68, D_8018FE6C, D_8018FE70, D_8018FE74; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018FE48[0x00], p); + ApplyMatrixSV(mat, &D_8018FE48[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018FE48[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018FE48[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018FE70; + *(u32 *)(prim + 0x24) = D_8018FE68; + *(u32 *)(prim + 0x28) = D_8018FE74; + *(u32 *)(prim + 0x2c) = D_8018FE6C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018FE78[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018FE78[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018FE78[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018FE78[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018FEF4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018FEF4[a1 & 0x7F]; +} + + + +extern s32 D_8018FF14[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018FF14[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018FF90[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018FF90[a1 & 0x7F]; +} + + + +extern u8 D_8018FFB0[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018FFB0[a1 & 0x7F]; +} + + + +extern u8 D_8018FFD0[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018FFD0[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018FFF0[])(void); + D_8018FFF0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8019006C[])(void); + +void func_80165AC8(void) { + D_8019006C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801900E8[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801900E8[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E5064; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E5064, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801900F4[])(void); + +void func_80166018(void *a0) { + D_801900F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801900FC[])(void); + +void func_801663FC(void *a0) { + D_801900FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801901C4[])(void); + +void func_80166618(void *a0) { + D_801901C4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801901D4[])(void); + +void func_80166654(void *a0) { + D_801901D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E5D78[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E5D78[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E5D78). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E5D78[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E5D78)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E5D78[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E5D78[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80190118[]; + extern u8 D_80190104[]; + extern u8 D_8019012C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80190118; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80190104; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8019012C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80167714); + + +extern void (*D_801901E4[])(void); + +void func_801678B4(void *a0) { + D_801901E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801901F0[])(void); + +void func_80167A9C(void *a0) { + D_801901F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801902FC; + extern u8 D_80190310[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801902FC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80190310; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80190150[]; +extern u8 D_80190164[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80190150; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80190164; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80190208[])(void); + +void func_80168744(void *a0) { + D_80190208[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801901F8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801901F8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801901F8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80190210[])(void); + +void func_801689D8(void *a0) { + D_80190210[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80190218[])(void); + +void func_80168AA8(void *a0) { + D_80190218[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80190220[])(void); + +void func_80168D58(void *a0) { + D_80190220[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80190228[])(void); + +void func_8016901C(void *a0) { + D_80190228[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_019/nonmatchings/ov_SC04_019_jr_8015C32C", func_80169228); + + +extern void (*D_80190230[])(void); + +void func_801693CC(void *a0) { + D_80190230[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80190238[])(void); + +void func_80169830(void *a0) { + D_80190238[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801902EC[])(void); + +void func_80169B80(void *a0) { + D_801902EC[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80190240[]; + extern u8 D_801902B0[]; + extern u8 D_801902E0[]; + extern u8 D_801E79B8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801902E0, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80190240[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801E79B8; + RotMatrixYXZ(rot, D_801E79B8); + func_80048D9C(D_801E79B8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801902B0); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801902F4[])(void); + +void func_80169F00(void *a0) { + D_801902F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801902A4[]; +extern char D_80190264[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801902A4, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80190264); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8019032C[])(void); + +void func_8016A020(void *a0) { + D_8019032C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801902FC; + extern u8 D_80190310[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801902FC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80190310; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80190338[])(void); + +void func_8016A700(void *a0) { + D_80190338[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80190380[])(void); + +void func_8016AB30(void *a0) { + D_80190380[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_020/ov_SC04_020_jr_8015AE2C.c b/src/ov_SC04_020/ov_SC04_020_jr_8015AE2C.c index 5174c46ee..627acbd3f 100644 --- a/src/ov_SC04_020/ov_SC04_020_jr_8015AE2C.c +++ b/src/ov_SC04_020/ov_SC04_020_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80185B74[])(void); - -void func_8015C714(void *a0) { - D_80185B74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801859E8[])(void*); - extern int D_8018598C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801859E8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801859E8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018598C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801859E8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801859E8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801859E8[])(void*); - extern int D_8018598C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801859E8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018598C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801859E8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80185B84[])(void); - D_80185B84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801859E8[])(struct Ent_8015CD20 *); - extern u8 D_8018599C; - extern u8 D_80185B8C; - extern u8 D_80185B9C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801859E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018599C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185B8C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185B9C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801859E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80185BBC[])(void); - D_80185BBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80185BAC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80185BAC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801859E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80185C18; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80185C18, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80184CFC[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80184CFC; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80185C20[])(void); - D_80185C20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80185C2C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80185C2C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80185C2C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80185C2C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801859E8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80185C2C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801859AC[]; - extern u8 D_801859BC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801859AC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801859BC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80185C2C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185C2C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185C2C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80185C60[])(void); - D_80185C60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801859E8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80185C68[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80185C80[])(void); - D_80185C80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801859E8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80185C68[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80185CA0[])(void); - D_80185CA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801859E8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801859E8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80185CB0; -extern u16 D_80185CB2; -extern u16 D_80185CB4; -extern s32 D_80185CB8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80185CB0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80185CB2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80185CB4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185CB8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80185CC0; - -void func_8015E588(void) { - func_8013C9C4(&D_80185CC0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801859E8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801859E8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80185CD4[])(void); - D_80185CD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801859E8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801859E8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80185CDC[])(void); - D_80185CDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801859CC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801859CC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801859E8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80185CE4[])(void); - D_80185CE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801859E8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801859E8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80185CEC[])(void); - D_80185CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801859E8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80185CF4; - extern s32 D_80185D04; - extern s32 D_80185D14; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801859E8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185CF4); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185D04); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801859E8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185D14); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80185D24[])(void); - D_80185D24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801859E8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801859E8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801859E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801859E8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80185D30[])(void); - D_80185D30[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801859E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801859E8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801859E8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801859E8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80185D44[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80185D44[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801859E8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801859E8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801859E8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801859E8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80185DC0[])(void); - D_80185DC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801859E8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801859E8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80185DD0[])(void); - D_80185DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801859E8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801859E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801859E8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801859E8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801859E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801859E8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801859E8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80185DD8[])(void); - D_80185DD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801859E8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801859E8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801859E8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801859E8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80185DE4[])(void); - D_80185DE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801859E8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801859E8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801859E8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801859E8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80185DF4[])(void); - -void func_80160EA4(void *a0) { - D_80185DF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801859E8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801859E8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80185E24[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80185E24[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80185E88; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80185E88); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801BB210[]; - extern u8 D_80185E54[]; - extern u8 D_80185E74[]; - extern u8 D_801BB21C[]; - extern u8 D_801BB244[]; - extern u8 D_801BB25C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801BB210[0] = p; - func_80024054(&D_80185E54, &D_801BB21C); - func_8001CE28(p, &D_801BB21C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801BB210[1] = p; - func_80024054(&D_80185E74, &D_801BB244); - func_8001CE28(p, &D_801BB244); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801BB210[2] = p; - func_800242D0((s16)func_801620C4(), &D_801BB25C, 0x84); - func_8001CE68(p, &D_801BB25C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801BB25C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BB210[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801BB210; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80185E88; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80185E88; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80185E88; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80185E88; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801BB210[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801BB210; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80185EAC[])(void); - -void func_80162330(void *a0) { - D_80185EAC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801BB268[i] via `extern int D_801BB268[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80185EB8[]; - extern s32 D_80185ED0; - extern u8 D_801BB274[]; - extern u8 D_801BB29C[]; - extern u8 D_801BB2B8[]; - extern int D_801BB268[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801BB268[0] = (s32)item; - func_80024054(D_80185EB8, D_801BB274); - func_8001CE28(item, D_801BB274); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801BB268[1] = (s32)item; - func_80024054(((u8 *)&D_80185ED0), D_801BB29C); - func_8001CE28(item, D_801BB29C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801BB268[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801BB2B8, 0x84); - func_8001CE68(item, D_801BB2B8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801BB2B8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801BB268[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801BB268; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_801627E8); - - -extern void (*D_80185EF4[])(void); - -void func_80162834(void *a0) { - D_80185EF4[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80185EE4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80185EE4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801BAA7C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801BAA7C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801BAA7C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801BAA7C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80185EFC[])(void); - -void func_80163A58(void *a0) { - D_80185EFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801BAA84; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801BAA84; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80185F50[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80185F50[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80185F18; -extern s16 D_80185F4C; -extern s16 D_80185F4A; -extern s16 D_80185F48; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80185F18; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80185F4C = 0x80; - D_80185F4A = 0x80; - D_80185F48 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80185F4C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80185F4C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80185F4C - 8; - D_80185F4C = nv; - D_80185F4A = nv; - D_80185F48 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80185F5C[])(void); - -void func_80164BA0(void *a0) { - D_80185F5C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801BB2C8; -extern u8 D_801BB2C9; -extern u8 D_801BB2CA; -extern u8 D_801BB2CB; -extern u8 D_801BB2CC; -extern u8 D_801BB2CD; -extern u8 D_801BB2CE; -extern u8 D_801BB2CF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801BB2C8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801BB2C9 = 0xf0; - *(u8 *)base = 0xf0; - D_801BB2CA = 0xc0; - D_801BB2CE = 0; - D_801BB2CD = 0; - D_801BB2CC = 0; - D_801BB2CF = 0; - D_801BB2CB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801BB2C8; -extern u8 D_801BB2C9; -extern u8 D_801BB2CA; - -s32 func_80164E40(void) { - u8 *p = &D_801BB2C8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801BB2C9 != 0) { - D_801BB2C9 -= 0x10; - } - if (D_801BB2CA != 0) { - D_801BB2CA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80185F6C[])(void); - -void func_80164EA4(void *a0) { - D_80185F6C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801BB314[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801BB314[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801BB308[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801BB308[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801BB308[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801BB308; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801BB308; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80185F80[]; - extern u32 D_80185FA0, D_80185FA4, D_80185FA8, D_80185FAC; - extern u32 D_80185FA0, D_80185FA4, D_80185FA8, D_80185FAC; - extern u32 D_80185FA0, D_80185FA4, D_80185FA8, D_80185FAC; - extern u32 D_80185FA0, D_80185FA4, D_80185FA8, D_80185FAC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80185F80[0x00], p); - ApplyMatrixSV(mat, &D_80185F80[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80185F80[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80185F80[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80185FA8; - *(u32 *)(prim + 0x24) = D_80185FA0; - *(u32 *)(prim + 0x28) = D_80185FAC; - *(u32 *)(prim + 0x2c) = D_80185FA4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80185FB0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80185FB0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80185FB0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80185FB0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018602C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018602C[a1 & 0x7F]; -} - - - -extern s32 D_8018604C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018604C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801860C8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801860C8[a1 & 0x7F]; -} - - - -extern u8 D_801860E8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801860E8[a1 & 0x7F]; -} - - - -extern u8 D_80186108[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80186108[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80186128[])(void); - D_80186128[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801861A4[])(void); - -void func_80165AC8(void) { - D_801861A4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80186220[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80186220[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801BAA8C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801BAA8C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018622C[])(void); - -void func_80166018(void *a0) { - D_8018622C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80186234[])(void); - -void func_801663FC(void *a0) { - D_80186234[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801862FC[])(void); - -void func_80166618(void *a0) { - D_801862FC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018630C[])(void); - -void func_80166654(void *a0) { - D_8018630C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801BB388[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801BB388[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BB388). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801BB388[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801BB388)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801BB388[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801BB388[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80186250[]; - extern u8 D_8018623C[]; - extern u8 D_80186264[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80186250; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018623C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80186264; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80167714); - - -extern void (*D_8018631C[])(void); - -void func_801678B4(void *a0) { - D_8018631C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80186328[])(void); - -void func_80167A9C(void *a0) { - D_80186328[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80186434; - extern u8 D_80186448[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80186434); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80186448; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80186288[]; -extern u8 D_8018629C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80186288; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018629C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80186340[])(void); - -void func_80168744(void *a0) { - D_80186340[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80186330 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80186330[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80186330; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80186348[])(void); - -void func_801689D8(void *a0) { - D_80186348[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80186350[])(void); - -void func_80168AA8(void *a0) { - D_80186350[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80186358[])(void); - -void func_80168D58(void *a0) { - D_80186358[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80186360[])(void); - -void func_8016901C(void *a0) { - D_80186360[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015AE2C", func_80169228); - - -extern void (*D_80186368[])(void); - -void func_801693CC(void *a0) { - D_80186368[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80186370[])(void); - -void func_80169830(void *a0) { - D_80186370[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80186424[])(void); - -void func_80169B80(void *a0) { - D_80186424[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80186378[]; - extern u8 D_801863E8[]; - extern u8 D_80186418[]; - extern u8 D_801BC640[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80186418, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80186378[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801BC640; - RotMatrixYXZ(rot, D_801BC640); - func_80048D9C(D_801BC640, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801863E8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018642C[])(void); - -void func_80169F00(void *a0) { - D_8018642C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801863DC[]; -extern char D_8018639C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801863DC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018639C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80186464[])(void); - -void func_8016A020(void *a0) { - D_80186464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80186434; - extern u8 D_80186448[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80186434); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80186448; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80186470[])(void); - -void func_8016A700(void *a0) { - D_80186470[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801864B8[])(void); - -void func_8016AB30(void *a0) { - D_801864B8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c b/src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c new file mode 100644 index 000000000..0f7b76df1 --- /dev/null +++ b/src/ov_SC04_020/ov_SC04_020_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80185884; +extern u8 D_801857F4; +extern u8 D_801857D0; +extern u8 D_801857AC; +extern u8 D_80185860; +extern u8 D_8018583C; +extern u8 D_80185818; +extern u8 D_80185788; +extern void func_80145934(void); +extern u8 D_80185914; +extern u8 D_801858F0; +extern u8 D_801858CC; +extern u8 D_801858A8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80184D0C[]; +extern unsigned char D_80184D3C[]; +extern unsigned char D_80184D8C[]; +extern unsigned char D_80184DBC[]; +extern unsigned char D_80184DEC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80184E3C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80184F04[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80184F8C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80184F94; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801BB1B8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801BB1BC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80184FC4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018506C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80185090[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80185080; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801850A4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801850B0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801850C0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801850D8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801850C8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801850EC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80185108[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801850F8; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018511C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80185130[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80185144; +extern void (*D_8018516C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018514C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801851B8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801851BC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80185620[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80185630[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801BB1F0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80185658[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80185638; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80185648; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80185698[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801856A0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018566C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801856AC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018567C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801BB1F8; +extern s32 D_801BB204; +extern s32 D_801BB208; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801856E8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801856BC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801BB200; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80185938[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80185758[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801859DC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80185B30[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018594C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80185B38[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018595C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018597C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80185B40[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80185B68[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801859E8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80185B74[])(void); + +void func_8015C714(void *a0) { + D_80185B74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801859E8[])(void*); + extern int D_8018598C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801859E8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801859E8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018598C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801859E8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801859E8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801859E8[])(void*); + extern int D_8018598C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801859E8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018598C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801859E8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80185B84[])(void); + D_80185B84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801859E8[])(struct Ent_8015CD20 *); + extern u8 D_8018599C; + extern u8 D_80185B8C; + extern u8 D_80185B9C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801859E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018599C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185B8C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185B9C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801859E8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80185BBC[])(void); + D_80185BBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80185BAC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80185BAC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801859E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80185C18; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80185C18, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80184CFC[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80184CFC; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80185C20[])(void); + D_80185C20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80185C2C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80185C2C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80185C2C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80185C2C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801859E8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80185C2C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801859AC[]; + extern u8 D_801859BC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801859AC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801859BC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80185C2C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185C2C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185C2C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80185C60[])(void); + D_80185C60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801859E8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80185C68[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80185C80[])(void); + D_80185C80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801859E8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80185C68[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80185C68[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80185CA0[])(void); + D_80185CA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801859E8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801859E8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80185CB0; +extern u16 D_80185CB2; +extern u16 D_80185CB4; +extern s32 D_80185CB8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80185CB0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80185CB2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80185CB4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185CB8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80185CC0; + +void func_8015E588(void) { + func_8013C9C4(&D_80185CC0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801859E8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801859E8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80185CD4[])(void); + D_80185CD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801859E8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801859E8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80185CDC[])(void); + D_80185CDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801859CC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801859CC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801859E8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80185CE4[])(void); + D_80185CE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801859E8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801859E8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80185CEC[])(void); + D_80185CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801859E8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80185CF4; + extern s32 D_80185D04; + extern s32 D_80185D14; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185CF4); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185D04); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801859E8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80185D14); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80185D24[])(void); + D_80185D24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801859E8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801859E8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801859E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801859E8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80185D30[])(void); + D_80185D30[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801859E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801859E8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801859E8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801859E8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80185D44[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80185D44[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801859E8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801859E8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801859E8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801859E8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80185DC0[])(void); + D_80185DC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801859E8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801859E8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80185DD0[])(void); + D_80185DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801859E8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801859E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801859E8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801859E8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801859E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801859E8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801859E8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80185DD8[])(void); + D_80185DD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801859E8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801859E8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801859E8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801859E8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80185DE4[])(void); + D_80185DE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801859E8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801859E8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801859E8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801859E8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80185DF4[])(void); + +void func_80160EA4(void *a0) { + D_80185DF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801859E8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801859E8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80185E24[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80185E24[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80185E88; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80185E88); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801BB210[]; + extern u8 D_80185E54[]; + extern u8 D_80185E74[]; + extern u8 D_801BB21C[]; + extern u8 D_801BB244[]; + extern u8 D_801BB25C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801BB210[0] = p; + func_80024054(&D_80185E54, &D_801BB21C); + func_8001CE28(p, &D_801BB21C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801BB210[1] = p; + func_80024054(&D_80185E74, &D_801BB244); + func_8001CE28(p, &D_801BB244); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801BB210[2] = p; + func_800242D0((s16)func_801620C4(), &D_801BB25C, 0x84); + func_8001CE68(p, &D_801BB25C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801BB25C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BB210[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801BB210; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80185E88; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80185E88; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80185E88; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80185E88; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801BB210[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801BB210; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80185EAC[])(void); + +void func_80162330(void *a0) { + D_80185EAC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801BB268[i] via `extern int D_801BB268[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80185EB8[]; + extern s32 D_80185ED0; + extern u8 D_801BB274[]; + extern u8 D_801BB29C[]; + extern u8 D_801BB2B8[]; + extern int D_801BB268[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801BB268[0] = (s32)item; + func_80024054(D_80185EB8, D_801BB274); + func_8001CE28(item, D_801BB274); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801BB268[1] = (s32)item; + func_80024054(((u8 *)&D_80185ED0), D_801BB29C); + func_8001CE28(item, D_801BB29C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801BB268[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801BB2B8, 0x84); + func_8001CE68(item, D_801BB2B8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801BB2B8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801BB268[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801BB268; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_801627E8); + + +extern void (*D_80185EF4[])(void); + +void func_80162834(void *a0) { + D_80185EF4[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80185EE4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80185EE4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801BAA7C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801BAA7C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801BAA7C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801BAA7C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80185EFC[])(void); + +void func_80163A58(void *a0) { + D_80185EFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801BAA84; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801BAA84; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80185F50[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80185F50[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80185F18; +extern s16 D_80185F4C; +extern s16 D_80185F4A; +extern s16 D_80185F48; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80185F18; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80185F4C = 0x80; + D_80185F4A = 0x80; + D_80185F48 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80185F4C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80185F4C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80185F4C - 8; + D_80185F4C = nv; + D_80185F4A = nv; + D_80185F48 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80185F5C[])(void); + +void func_80164BA0(void *a0) { + D_80185F5C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801BB2C8; +extern u8 D_801BB2C9; +extern u8 D_801BB2CA; +extern u8 D_801BB2CB; +extern u8 D_801BB2CC; +extern u8 D_801BB2CD; +extern u8 D_801BB2CE; +extern u8 D_801BB2CF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801BB2C8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801BB2C9 = 0xf0; + *(u8 *)base = 0xf0; + D_801BB2CA = 0xc0; + D_801BB2CE = 0; + D_801BB2CD = 0; + D_801BB2CC = 0; + D_801BB2CF = 0; + D_801BB2CB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801BB2C8; +extern u8 D_801BB2C9; +extern u8 D_801BB2CA; + +s32 func_80164E40(void) { + u8 *p = &D_801BB2C8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801BB2C9 != 0) { + D_801BB2C9 -= 0x10; + } + if (D_801BB2CA != 0) { + D_801BB2CA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80185F6C[])(void); + +void func_80164EA4(void *a0) { + D_80185F6C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801BB314[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801BB314[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801BB308[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801BB308[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801BB308[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801BB308; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801BB308; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80185F80[]; + extern u32 D_80185FA0, D_80185FA4, D_80185FA8, D_80185FAC; + extern u32 D_80185FA0, D_80185FA4, D_80185FA8, D_80185FAC; + extern u32 D_80185FA0, D_80185FA4, D_80185FA8, D_80185FAC; + extern u32 D_80185FA0, D_80185FA4, D_80185FA8, D_80185FAC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80185F80[0x00], p); + ApplyMatrixSV(mat, &D_80185F80[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80185F80[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80185F80[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80185FA8; + *(u32 *)(prim + 0x24) = D_80185FA0; + *(u32 *)(prim + 0x28) = D_80185FAC; + *(u32 *)(prim + 0x2c) = D_80185FA4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80185FB0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80185FB0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80185FB0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80185FB0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018602C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018602C[a1 & 0x7F]; +} + + + +extern s32 D_8018604C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018604C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801860C8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801860C8[a1 & 0x7F]; +} + + + +extern u8 D_801860E8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801860E8[a1 & 0x7F]; +} + + + +extern u8 D_80186108[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80186108[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80186128[])(void); + D_80186128[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801861A4[])(void); + +void func_80165AC8(void) { + D_801861A4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80186220[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80186220[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801BAA8C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801BAA8C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018622C[])(void); + +void func_80166018(void *a0) { + D_8018622C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80186234[])(void); + +void func_801663FC(void *a0) { + D_80186234[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801862FC[])(void); + +void func_80166618(void *a0) { + D_801862FC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018630C[])(void); + +void func_80166654(void *a0) { + D_8018630C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801BB388[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801BB388[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801BB388). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801BB388[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801BB388)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801BB388[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801BB388[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80186250[]; + extern u8 D_8018623C[]; + extern u8 D_80186264[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80186250; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018623C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80186264; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80167714); + + +extern void (*D_8018631C[])(void); + +void func_801678B4(void *a0) { + D_8018631C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80186328[])(void); + +void func_80167A9C(void *a0) { + D_80186328[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80186434; + extern u8 D_80186448[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80186434); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80186448; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80186288[]; +extern u8 D_8018629C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80186288; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018629C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80186340[])(void); + +void func_80168744(void *a0) { + D_80186340[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80186330 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80186330[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80186330; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80186348[])(void); + +void func_801689D8(void *a0) { + D_80186348[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80186350[])(void); + +void func_80168AA8(void *a0) { + D_80186350[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80186358[])(void); + +void func_80168D58(void *a0) { + D_80186358[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80186360[])(void); + +void func_8016901C(void *a0) { + D_80186360[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_020/nonmatchings/ov_SC04_020_jr_8015C32C", func_80169228); + + +extern void (*D_80186368[])(void); + +void func_801693CC(void *a0) { + D_80186368[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80186370[])(void); + +void func_80169830(void *a0) { + D_80186370[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80186424[])(void); + +void func_80169B80(void *a0) { + D_80186424[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80186378[]; + extern u8 D_801863E8[]; + extern u8 D_80186418[]; + extern u8 D_801BC640[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80186418, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80186378[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801BC640; + RotMatrixYXZ(rot, D_801BC640); + func_80048D9C(D_801BC640, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801863E8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018642C[])(void); + +void func_80169F00(void *a0) { + D_8018642C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801863DC[]; +extern char D_8018639C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801863DC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018639C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80186464[])(void); + +void func_8016A020(void *a0) { + D_80186464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80186434; + extern u8 D_80186448[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80186434); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80186448; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80186470[])(void); + +void func_8016A700(void *a0) { + D_80186470[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801864B8[])(void); + +void func_8016AB30(void *a0) { + D_801864B8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC04_021/ov_SC04_021_jr_8015AE2C.c b/src/ov_SC04_021/ov_SC04_021_jr_8015AE2C.c index c949396ba..4d55cef08 100644 --- a/src/ov_SC04_021/ov_SC04_021_jr_8015AE2C.c +++ b/src/ov_SC04_021/ov_SC04_021_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181AA0[])(void); - -void func_8015C714(void *a0) { - D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181914[])(void*); - extern int D_801818B8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181914[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181914[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181914[])(void*); - extern int D_801818B8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181AB0[])(void); - D_80181AB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181914[])(struct Ent_8015CD20 *); - extern u8 D_801818C8; - extern u8 D_80181AB8; - extern u8 D_80181AC8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801818C8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AB8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AC8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181AE8[])(void); - D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181AD8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181AD8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181B44; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181B44, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180C28[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180C28; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80181B4C[])(void); - D_80181B4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80181B58[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181914[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80181B58[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801818D8[]; - extern u8 D_801818E8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818D8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818E8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80181B8C[])(void); - D_80181B8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181914[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181B94[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181BAC[])(void); - D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181914[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181B94[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181BCC[])(void); - D_80181BCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181914[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181914)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181BDC; -extern u16 D_80181BDE; -extern u16 D_80181BE0; -extern s32 D_80181BE4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181BDC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80181BDE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181BE0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181BE4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181BEC; - -void func_8015E588(void) { - func_8013C9C4(&D_80181BEC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181914[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181914)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181C00[])(void); - D_80181C00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181914[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181914[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181C08[])(void); - D_80181C08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801818F8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801818F8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181914[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181C10[])(void); - D_80181C10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181914[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181914[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181C18[])(void); - D_80181C18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181914[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181C20; - extern s32 D_80181C30; - extern s32 D_80181C40; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181914[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C20); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C30); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181914[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C40); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80181C50[])(void); - D_80181C50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181914[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80181C5C[])(void); - D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181914[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181914[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80181C70[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80181C70[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181914[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181914)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181914[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181914[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181CEC[])(void); - D_80181CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181914[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181914)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181CFC[])(void); - D_80181CFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181914[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181D04[])(void); - D_80181D04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181914[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181914)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181914[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181D10[])(void); - D_80181D10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181914 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181914[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181914[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181914[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181D20[])(void); - -void func_80160EA4(void *a0) { - D_80181D20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181914[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80181D50[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80181D50[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181DB4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181DB4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8018E868[]; - extern u8 D_80181D80[]; - extern u8 D_80181DA0[]; - extern u8 D_8018E874[]; - extern u8 D_8018E89C[]; - extern u8 D_8018E8B4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8018E868[0] = p; - func_80024054(&D_80181D80, &D_8018E874); - func_8001CE28(p, &D_8018E874); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8018E868[1] = p; - func_80024054(&D_80181DA0, &D_8018E89C); - func_8001CE28(p, &D_8018E89C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8018E868[2] = p; - func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); - func_8001CE68(p, &D_8018E8B4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E868[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8018E868; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181DB4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181DB4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181DB4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181DB4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8018E868[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8018E868; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181DD8[])(void); - -void func_80162330(void *a0) { - D_80181DD8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8018E8C0[i] via `extern int D_8018E8C0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181DE4[]; - extern s32 D_80181DFC; - extern u8 D_8018E8CC[]; - extern u8 D_8018E8F4[]; - extern u8 D_8018E910[]; - extern int D_8018E8C0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8018E8C0[0] = (s32)item; - func_80024054(D_80181DE4, D_8018E8CC); - func_8001CE28(item, D_8018E8CC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8018E8C0[1] = (s32)item; - func_80024054(((u8 *)&D_80181DFC), D_8018E8F4); - func_8001CE28(item, D_8018E8F4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8018E8C0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); - func_8001CE68(item, D_8018E910); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E8C0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8018E8C0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181E20[])(void); - -void func_80162834(void *a0) { - D_80181E20[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181E10; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181E10, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8018E118[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8018E118, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8018E118[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8018E118, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181E28[])(void); - -void func_80163A58(void *a0) { - D_80181E28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8018E120; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8018E120; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80181E7C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80181E7C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181E44; -extern s16 D_80181E78; -extern s16 D_80181E76; -extern s16 D_80181E74; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181E44; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181E78 = 0x80; - D_80181E76 = 0x80; - D_80181E74 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181E78 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181E78` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181E78 - 8; - D_80181E78 = nv; - D_80181E76 = nv; - D_80181E74 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181E88[])(void); - -void func_80164BA0(void *a0) { - D_80181E88[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8018E920; -extern u8 D_8018E921; -extern u8 D_8018E922; -extern u8 D_8018E923; -extern u8 D_8018E924; -extern u8 D_8018E925; -extern u8 D_8018E926; -extern u8 D_8018E927; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8018E920; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8018E921 = 0xf0; - *(u8 *)base = 0xf0; - D_8018E922 = 0xc0; - D_8018E926 = 0; - D_8018E925 = 0; - D_8018E924 = 0; - D_8018E927 = 0; - D_8018E923 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8018E920; -extern u8 D_8018E921; -extern u8 D_8018E922; - -s32 func_80164E40(void) { - u8 *p = &D_8018E920; - if (*p != 0) { - *p -= 0x10; - } - if (D_8018E921 != 0) { - D_8018E921 -= 0x10; - } - if (D_8018E922 != 0) { - D_8018E922 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181E98[])(void); - -void func_80164EA4(void *a0) { - D_80181E98[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8018E96C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8018E96C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8018E960[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8018E960[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8018E960[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8018E960; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8018E960; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181EAC[]; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181EAC[0x00], p); - ApplyMatrixSV(mat, &D_80181EAC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181EAC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181EAC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181ED4; - *(u32 *)(prim + 0x24) = D_80181ECC; - *(u32 *)(prim + 0x28) = D_80181ED8; - *(u32 *)(prim + 0x2c) = D_80181ED0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181EDC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181EDC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181EDC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181EDC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80181F58[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80181F58[a1 & 0x7F]; -} - - - -extern s32 D_80181F78[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181F78[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181FF4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181FF4[a1 & 0x7F]; -} - - - -extern u8 D_80182014[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182014[a1 & 0x7F]; -} - - - -extern u8 D_80182034[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182034[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80182054[])(void); - D_80182054[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801820D0[])(void); - -void func_80165AC8(void) { - D_801820D0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018214C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018214C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8018E128; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8018E128, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80182158[])(void); - -void func_80166018(void *a0) { - D_80182158[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80182160[])(void); - -void func_801663FC(void *a0) { - D_80182160[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182228[])(void); - -void func_80166618(void *a0) { - D_80182228[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182238[])(void); - -void func_80166654(void *a0) { - D_80182238[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8018E9E0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8018E9E0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018E9E0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8018E9E0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8018E9E0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8018E9E0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8018E9E0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018217C[]; - extern u8 D_80182168[]; - extern u8 D_80182190[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018217C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80182168; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182190; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80167714); - - -extern void (*D_80182248[])(void); - -void func_801678B4(void *a0) { - D_80182248[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80182254[])(void); - -void func_80167A9C(void *a0) { - D_80182254[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80182360; - extern u8 D_80182374[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80182360); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182374; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801821B4[]; -extern u8 D_801821C8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801821B4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801821C8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018226C[])(void); - -void func_80168744(void *a0) { - D_8018226C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018225C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018225C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018225C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80182274[])(void); - -void func_801689D8(void *a0) { - D_80182274[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018227C[])(void); - -void func_80168AA8(void *a0) { - D_8018227C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80182284[])(void); - -void func_80168D58(void *a0) { - D_80182284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018228C[])(void); - -void func_8016901C(void *a0) { - D_8018228C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015AE2C", func_80169228); - - -extern void (*D_80182294[])(void); - -void func_801693CC(void *a0) { - D_80182294[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018229C[])(void); - -void func_80169830(void *a0) { - D_8018229C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80182350[])(void); - -void func_80169B80(void *a0) { - D_80182350[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801822A4[]; - extern u8 D_80182314[]; - extern u8 D_80182344[]; - extern u8 D_8018F9E0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80182344, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801822A4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8018F9E0; - RotMatrixYXZ(rot, D_8018F9E0); - func_80048D9C(D_8018F9E0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182314); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80182358[])(void); - -void func_80169F00(void *a0) { - D_80182358[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80182308[]; -extern char D_801822C8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80182308, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801822C8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80182390[])(void); - -void func_8016A020(void *a0) { - D_80182390[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80182360; - extern u8 D_80182374[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80182360); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182374; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018239C[])(void); - -void func_8016A700(void *a0) { - D_8018239C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801823E4[])(void); - -void func_8016AB30(void *a0) { - D_801823E4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c b/src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c new file mode 100644 index 000000000..df94339f2 --- /dev/null +++ b/src/ov_SC04_021/ov_SC04_021_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801817B0; +extern u8 D_80181720; +extern u8 D_801816FC; +extern u8 D_801816D8; +extern u8 D_8018178C; +extern u8 D_80181768; +extern u8 D_80181744; +extern u8 D_801816B4; +extern void func_80145934(void); +extern u8 D_80181840; +extern u8 D_8018181C; +extern u8 D_801817F8; +extern u8 D_801817D4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180C38[]; +extern unsigned char D_80180C68[]; +extern unsigned char D_80180CB8[]; +extern unsigned char D_80180CE8[]; +extern unsigned char D_80180D18[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80180D68[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80180E30[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180EB8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180EC0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8018E810; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8018E814; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180EF0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180F98[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180FBC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180FAC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180FD0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180FDC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180FEC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181004[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180FF4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181018[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181034[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181024; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181048[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018105C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80181070; +extern void (*D_80181098[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80181078; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801810E4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801810E8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018154C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018155C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8018E848; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80181584[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80181564; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80181574; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801815C4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801815CC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80181598; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801815D8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801815A8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8018E850; +extern s32 D_8018E85C; +extern s32 D_8018E860; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80181614[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801815E8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8018E858; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80181864[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80181684[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181908[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80181A5C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80181878; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80181A64[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80181888; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801818A8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80181A6C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80181A94[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181914[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181AA0[])(void); + +void func_8015C714(void *a0) { + D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181914[])(void*); + extern int D_801818B8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181914[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181914[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181914[])(void*); + extern int D_801818B8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181AB0[])(void); + D_80181AB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181914[])(struct Ent_8015CD20 *); + extern u8 D_801818C8; + extern u8 D_80181AB8; + extern u8 D_80181AC8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801818C8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AB8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AC8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181AE8[])(void); + D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181AD8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181AD8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181B44; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181B44, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180C28[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180C28; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80181B4C[])(void); + D_80181B4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80181B58[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181914[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80181B58[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801818D8[]; + extern u8 D_801818E8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818D8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818E8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80181B8C[])(void); + D_80181B8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181914[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181B94[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181BAC[])(void); + D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181914[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181B94[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181BCC[])(void); + D_80181BCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181914[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181914)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181BDC; +extern u16 D_80181BDE; +extern u16 D_80181BE0; +extern s32 D_80181BE4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181BDC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80181BDE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181BE0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181BE4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181BEC; + +void func_8015E588(void) { + func_8013C9C4(&D_80181BEC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181914[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181914)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181C00[])(void); + D_80181C00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181914[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181914[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181C08[])(void); + D_80181C08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801818F8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801818F8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181914[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181C10[])(void); + D_80181C10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181914[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181914[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181C18[])(void); + D_80181C18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181914[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181C20; + extern s32 D_80181C30; + extern s32 D_80181C40; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181914[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C20); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C30); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C40); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80181C50[])(void); + D_80181C50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181914[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80181C5C[])(void); + D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181914[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181914[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80181C70[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80181C70[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181914[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181914)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181914[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181914[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181CEC[])(void); + D_80181CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181914[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181914)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181CFC[])(void); + D_80181CFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181914[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181D04[])(void); + D_80181D04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181914[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181914)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181914[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181D10[])(void); + D_80181D10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181914 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181914[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181914[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181914[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181D20[])(void); + +void func_80160EA4(void *a0) { + D_80181D20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181914[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80181D50[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80181D50[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181DB4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181DB4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8018E868[]; + extern u8 D_80181D80[]; + extern u8 D_80181DA0[]; + extern u8 D_8018E874[]; + extern u8 D_8018E89C[]; + extern u8 D_8018E8B4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8018E868[0] = p; + func_80024054(&D_80181D80, &D_8018E874); + func_8001CE28(p, &D_8018E874); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8018E868[1] = p; + func_80024054(&D_80181DA0, &D_8018E89C); + func_8001CE28(p, &D_8018E89C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8018E868[2] = p; + func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); + func_8001CE68(p, &D_8018E8B4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E868[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8018E868; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181DB4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181DB4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181DB4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181DB4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8018E868[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8018E868; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181DD8[])(void); + +void func_80162330(void *a0) { + D_80181DD8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8018E8C0[i] via `extern int D_8018E8C0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181DE4[]; + extern s32 D_80181DFC; + extern u8 D_8018E8CC[]; + extern u8 D_8018E8F4[]; + extern u8 D_8018E910[]; + extern int D_8018E8C0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8018E8C0[0] = (s32)item; + func_80024054(D_80181DE4, D_8018E8CC); + func_8001CE28(item, D_8018E8CC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8018E8C0[1] = (s32)item; + func_80024054(((u8 *)&D_80181DFC), D_8018E8F4); + func_8001CE28(item, D_8018E8F4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8018E8C0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); + func_8001CE68(item, D_8018E910); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E8C0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8018E8C0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_801627E8); + + +extern void (*D_80181E20[])(void); + +void func_80162834(void *a0) { + D_80181E20[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181E10; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181E10, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8018E118[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8018E118, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8018E118[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8018E118, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181E28[])(void); + +void func_80163A58(void *a0) { + D_80181E28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8018E120; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8018E120; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80181E7C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80181E7C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181E44; +extern s16 D_80181E78; +extern s16 D_80181E76; +extern s16 D_80181E74; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181E44; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181E78 = 0x80; + D_80181E76 = 0x80; + D_80181E74 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181E78 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181E78` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181E78 - 8; + D_80181E78 = nv; + D_80181E76 = nv; + D_80181E74 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181E88[])(void); + +void func_80164BA0(void *a0) { + D_80181E88[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8018E920; +extern u8 D_8018E921; +extern u8 D_8018E922; +extern u8 D_8018E923; +extern u8 D_8018E924; +extern u8 D_8018E925; +extern u8 D_8018E926; +extern u8 D_8018E927; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8018E920; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8018E921 = 0xf0; + *(u8 *)base = 0xf0; + D_8018E922 = 0xc0; + D_8018E926 = 0; + D_8018E925 = 0; + D_8018E924 = 0; + D_8018E927 = 0; + D_8018E923 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8018E920; +extern u8 D_8018E921; +extern u8 D_8018E922; + +s32 func_80164E40(void) { + u8 *p = &D_8018E920; + if (*p != 0) { + *p -= 0x10; + } + if (D_8018E921 != 0) { + D_8018E921 -= 0x10; + } + if (D_8018E922 != 0) { + D_8018E922 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181E98[])(void); + +void func_80164EA4(void *a0) { + D_80181E98[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8018E96C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8018E96C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8018E960[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8018E960[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8018E960[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8018E960; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8018E960; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181EAC[]; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181EAC[0x00], p); + ApplyMatrixSV(mat, &D_80181EAC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181EAC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181EAC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181ED4; + *(u32 *)(prim + 0x24) = D_80181ECC; + *(u32 *)(prim + 0x28) = D_80181ED8; + *(u32 *)(prim + 0x2c) = D_80181ED0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181EDC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181EDC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181EDC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181EDC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80181F58[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80181F58[a1 & 0x7F]; +} + + + +extern s32 D_80181F78[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181F78[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181FF4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181FF4[a1 & 0x7F]; +} + + + +extern u8 D_80182014[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182014[a1 & 0x7F]; +} + + + +extern u8 D_80182034[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182034[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80182054[])(void); + D_80182054[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801820D0[])(void); + +void func_80165AC8(void) { + D_801820D0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018214C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018214C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8018E128; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8018E128, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80182158[])(void); + +void func_80166018(void *a0) { + D_80182158[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80182160[])(void); + +void func_801663FC(void *a0) { + D_80182160[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182228[])(void); + +void func_80166618(void *a0) { + D_80182228[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182238[])(void); + +void func_80166654(void *a0) { + D_80182238[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8018E9E0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8018E9E0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018E9E0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8018E9E0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8018E9E0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8018E9E0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8018E9E0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018217C[]; + extern u8 D_80182168[]; + extern u8 D_80182190[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018217C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80182168; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182190; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80167714); + + +extern void (*D_80182248[])(void); + +void func_801678B4(void *a0) { + D_80182248[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80182254[])(void); + +void func_80167A9C(void *a0) { + D_80182254[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80182360; + extern u8 D_80182374[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80182360); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182374; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801821B4[]; +extern u8 D_801821C8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801821B4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801821C8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018226C[])(void); + +void func_80168744(void *a0) { + D_8018226C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018225C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018225C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018225C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80182274[])(void); + +void func_801689D8(void *a0) { + D_80182274[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018227C[])(void); + +void func_80168AA8(void *a0) { + D_8018227C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80182284[])(void); + +void func_80168D58(void *a0) { + D_80182284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018228C[])(void); + +void func_8016901C(void *a0) { + D_8018228C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC04_021/nonmatchings/ov_SC04_021_jr_8015C32C", func_80169228); + + +extern void (*D_80182294[])(void); + +void func_801693CC(void *a0) { + D_80182294[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018229C[])(void); + +void func_80169830(void *a0) { + D_8018229C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80182350[])(void); + +void func_80169B80(void *a0) { + D_80182350[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801822A4[]; + extern u8 D_80182314[]; + extern u8 D_80182344[]; + extern u8 D_8018F9E0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80182344, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801822A4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8018F9E0; + RotMatrixYXZ(rot, D_8018F9E0); + func_80048D9C(D_8018F9E0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182314); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80182358[])(void); + +void func_80169F00(void *a0) { + D_80182358[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80182308[]; +extern char D_801822C8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80182308, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801822C8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80182390[])(void); + +void func_8016A020(void *a0) { + D_80182390[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80182360; + extern u8 D_80182374[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80182360); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182374; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018239C[])(void); + +void func_8016A700(void *a0) { + D_8018239C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801823E4[])(void); + +void func_8016AB30(void *a0) { + D_801823E4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_000/ov_SC05_000_jr_8015AE2C.c b/src/ov_SC05_000/ov_SC05_000_jr_8015AE2C.c index 83d47d014..a47dc8740 100644 --- a/src/ov_SC05_000/ov_SC05_000_jr_8015AE2C.c +++ b/src/ov_SC05_000/ov_SC05_000_jr_8015AE2C.c @@ -1619,4590 +1619,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80180AB4[])(void); - -void func_8015C714(void *a0) { - D_80180AB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80180928[])(void*); - extern int D_801808CC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80180928)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80180928)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801808CC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80180928[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80180928[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80180928[])(void*); - extern int D_801808CC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80180928)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801808CC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80180928)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80180AC4[])(void); - D_80180AC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80180928[])(struct Ent_8015CD20 *); - extern u8 D_801808DC; - extern u8 D_80180ACC; - extern u8 D_80180ADC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80180928[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801808DC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180ACC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180ADC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80180928[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80180AFC[])(void); - D_80180AFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80180AEC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80180AEC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80180928[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80180B58; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80180B58, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8017FC3C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8017FC3C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80180B60[])(void); - D_80180B60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80180B6C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80180B6C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80180B6C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80180B6C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80180928[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80180B6C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801808EC[]; - extern u8 D_801808FC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801808EC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801808FC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80180B6C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180B6C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180B6C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80180BA0[])(void); - D_80180BA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80180928[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180BA8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80180BC0[])(void); - D_80180BC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80180928[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180BA8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80180BE0[])(void); - D_80180BE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80180928[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80180928)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80180BF0; -extern u16 D_80180BF2; -extern u16 D_80180BF4; -extern s32 D_80180BF8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80180BF0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80180BF2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80180BF4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180BF8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80180C00; - -void func_8015E588(void) { - func_8013C9C4(&D_80180C00); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80180928[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80180928)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80180C14[])(void); - D_80180C14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80180928[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80180928[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80180C1C[])(void); - D_80180C1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018090C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018090C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80180928[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80180C24[])(void); - D_80180C24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80180928[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80180928[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80180C2C[])(void); - D_80180C2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80180928[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80180C34; - extern s32 D_80180C44; - extern s32 D_80180C54; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80180928[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180C34); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180C44); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80180928[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180C54); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80180C64[])(void); - D_80180C64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80180928[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80180928[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80180928[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80180928[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80180C70[])(void); - D_80180C70[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80180928[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80180928[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80180928[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80180928[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80180C84[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80180C84[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80180928[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80180928)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80180928[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80180928[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80180D00[])(void); - D_80180D00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80180928[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80180928)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80180D10[])(void); - D_80180D10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80180928[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80180928[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80180928[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80180928[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80180928[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80180928[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80180928[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80180D18[])(void); - D_80180D18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80180928[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80180928)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80180928[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80180928)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80180D24[])(void); - D_80180D24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80180928 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80180928[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80180928[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80180928[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80180D34[])(void); - -void func_80160EA4(void *a0) { - D_80180D34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80180928[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80180928[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80180D64[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80180D64[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80180DC8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80180DC8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80199998[]; - extern u8 D_80180D94[]; - extern u8 D_80180DB4[]; - extern u8 D_801999A4[]; - extern u8 D_801999CC[]; - extern u8 D_801999E4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80199998[0] = p; - func_80024054(&D_80180D94, &D_801999A4); - func_8001CE28(p, &D_801999A4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80199998[1] = p; - func_80024054(&D_80180DB4, &D_801999CC); - func_8001CE28(p, &D_801999CC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80199998[2] = p; - func_800242D0((s16)func_801620C4(), &D_801999E4, 0x84); - func_8001CE68(p, &D_801999E4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801999E4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80199998[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80199998; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80180DC8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80180DC8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80180DC8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80180DC8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80199998[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80199998; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80180DEC[])(void); - -void func_80162330(void *a0) { - D_80180DEC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801999F0[i] via `extern int D_801999F0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80180DF8[]; - extern s32 D_80180E10; - extern u8 D_801999FC[]; - extern u8 D_80199A24[]; - extern u8 D_80199A40[]; - extern int D_801999F0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801999F0[0] = (s32)item; - func_80024054(D_80180DF8, D_801999FC); - func_8001CE28(item, D_801999FC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801999F0[1] = (s32)item; - func_80024054(((u8 *)&D_80180E10), D_80199A24); - func_8001CE28(item, D_80199A24); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801999F0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_80199A40, 0x84); - func_8001CE68(item, D_80199A40); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_80199A40, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801999F0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801999F0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_801627E8); - - -extern void (*D_80180E34[])(void); - -void func_80162834(void *a0) { - D_80180E34[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80180E24; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80180E24, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80199268[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80199268, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80199268[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80199268, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80180E3C[])(void); - -void func_80163A58(void *a0) { - D_80180E3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80199270; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80199270; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80180E90[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80180E90[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80180E58; -extern s16 D_80180E8C; -extern s16 D_80180E8A; -extern s16 D_80180E88; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80180E58; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80180E8C = 0x80; - D_80180E8A = 0x80; - D_80180E88 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80180E8C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180E8C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80180E8C - 8; - D_80180E8C = nv; - D_80180E8A = nv; - D_80180E88 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80180E9C[])(void); - -void func_80164BA0(void *a0) { - D_80180E9C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_80199A50; -extern u8 D_80199A51; -extern u8 D_80199A52; -extern u8 D_80199A53; -extern u8 D_80199A54; -extern u8 D_80199A55; -extern u8 D_80199A56; -extern u8 D_80199A57; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_80199A50; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_80199A51 = 0xf0; - *(u8 *)base = 0xf0; - D_80199A52 = 0xc0; - D_80199A56 = 0; - D_80199A55 = 0; - D_80199A54 = 0; - D_80199A57 = 0; - D_80199A53 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_80199A50; -extern u8 D_80199A51; -extern u8 D_80199A52; - -s32 func_80164E40(void) { - u8 *p = &D_80199A50; - if (*p != 0) { - *p -= 0x10; - } - if (D_80199A51 != 0) { - D_80199A51 -= 0x10; - } - if (D_80199A52 != 0) { - D_80199A52 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80180EAC[])(void); - -void func_80164EA4(void *a0) { - D_80180EAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80199A9C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80199A9C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80199A90[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80199A90[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80199A90[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80199A90; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80199A90; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80180EC0[]; - extern u32 D_80180EE0, D_80180EE4, D_80180EE8, D_80180EEC; - extern u32 D_80180EE0, D_80180EE4, D_80180EE8, D_80180EEC; - extern u32 D_80180EE0, D_80180EE4, D_80180EE8, D_80180EEC; - extern u32 D_80180EE0, D_80180EE4, D_80180EE8, D_80180EEC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80180EC0[0x00], p); - ApplyMatrixSV(mat, &D_80180EC0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80180EC0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80180EC0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80180EE8; - *(u32 *)(prim + 0x24) = D_80180EE0; - *(u32 *)(prim + 0x28) = D_80180EEC; - *(u32 *)(prim + 0x2c) = D_80180EE4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80180EF0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80180EF0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80180EF0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80180EF0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80180F6C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80180F6C[a1 & 0x7F]; -} - - - -extern s32 D_80180F8C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80180F8C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181008[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181008[a1 & 0x7F]; -} - - - -extern u8 D_80181028[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80181028[a1 & 0x7F]; -} - - - -extern u8 D_80181048[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181048[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80181068[])(void); - D_80181068[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801810E4[])(void); - -void func_80165AC8(void) { - D_801810E4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181160[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181160[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80199278; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80199278, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018116C[])(void); - -void func_80166018(void *a0) { - D_8018116C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181174[])(void); - -void func_801663FC(void *a0) { - D_80181174[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018123C[])(void); - -void func_80166618(void *a0) { - D_8018123C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018124C[])(void); - -void func_80166654(void *a0) { - D_8018124C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80199B10[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80199B10[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80199B10). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80199B10[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80199B10)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80199B10[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80199B10[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80181190[]; - extern u8 D_8018117C[]; - extern u8 D_801811A4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80181190; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018117C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801811A4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80167714); - - -extern void (*D_8018125C[])(void); - -void func_801678B4(void *a0) { - D_8018125C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181268[])(void); - -void func_80167A9C(void *a0) { - D_80181268[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181374; - extern u8 D_80181388[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181374); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181388; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801811C8[]; -extern u8 D_801811DC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801811C8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801811DC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181280[])(void); - -void func_80168744(void *a0) { - D_80181280[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181270 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181270[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181270; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181288[])(void); - -void func_801689D8(void *a0) { - D_80181288[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181290[])(void); - -void func_80168AA8(void *a0) { - D_80181290[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181298[])(void); - -void func_80168D58(void *a0) { - D_80181298[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801812A0[])(void); - -void func_8016901C(void *a0) { - D_801812A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015AE2C", func_80169228); - - -extern void (*D_801812A8[])(void); - -void func_801693CC(void *a0) { - D_801812A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801812B0[])(void); - -void func_80169830(void *a0) { - D_801812B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181364[])(void); - -void func_80169B80(void *a0) { - D_80181364[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801812B8[]; - extern u8 D_80181328[]; - extern u8 D_80181358[]; - extern u8 D_8019AB10[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181358, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801812B8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019AB10; - RotMatrixYXZ(rot, D_8019AB10); - func_80048D9C(D_8019AB10, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181328); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018136C[])(void); - -void func_80169F00(void *a0) { - D_8018136C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018131C[]; -extern char D_801812DC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018131C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801812DC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801813A4[])(void); - -void func_8016A020(void *a0) { - D_801813A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181374; - extern u8 D_80181388[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181374); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181388; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801813B0[])(void); - -void func_8016A700(void *a0) { - D_801813B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801813F8[])(void); - -void func_8016AB30(void *a0) { - D_801813F8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c b/src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c new file mode 100644 index 000000000..007ac5021 --- /dev/null +++ b/src/ov_SC05_000/ov_SC05_000_jr_8015C32C.c @@ -0,0 +1,5924 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801807C4; +extern u8 D_80180734; +extern u8 D_80180710; +extern u8 D_801806EC; +extern u8 D_801807A0; +extern u8 D_8018077C; +extern u8 D_80180758; +extern u8 D_801806C8; +extern void func_80145934(void); +extern u8 D_80180854; +extern u8 D_80180830; +extern u8 D_8018080C; +extern u8 D_801807E8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8017FC4C[]; +extern unsigned char D_8017FC7C[]; +extern unsigned char D_8017FCCC[]; +extern unsigned char D_8017FCFC[]; +extern unsigned char D_8017FD2C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8017FD7C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8017FE44[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8017FECC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8017FED4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_80199940; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_80199944; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8017FF04; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8017FFAC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8017FFD0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8017FFC0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8017FFE4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8017FFF0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80180018[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180008; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018002C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80180048[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80180038; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018005C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80180070[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80180084; +extern void (*D_801800AC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018008C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801800F8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801800FC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180560[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180570[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80199978; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180598[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180578; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180588; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801805D8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801805E0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801805AC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801805EC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801805BC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80199980; +extern s32 D_8019998C; +extern s32 D_80199990; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180628[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801805FC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80199988; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80180878[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180698[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018091C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80180A70[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018088C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80180A78[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018089C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801808BC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80180A80[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80180AA8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80180928[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80180928[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80180928[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80180928[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80180928[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80180928[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80180928[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80180928[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80180AB4[])(void); + +void func_8015C714(void *a0) { + D_80180AB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80180928[])(void*); + extern int D_801808CC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80180928)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80180928)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801808CC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80180928[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80180928[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80180928[])(void*); + extern int D_801808CC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80180928)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801808CC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80180928)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80180AC4[])(void); + D_80180AC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80180928[])(struct Ent_8015CD20 *); + extern u8 D_801808DC; + extern u8 D_80180ACC; + extern u8 D_80180ADC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80180928[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801808DC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180ACC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180ADC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80180928[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80180AFC[])(void); + D_80180AFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80180AEC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80180AEC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80180928[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80180B58; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80180B58, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8017FC3C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8017FC3C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80180B60[])(void); + D_80180B60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80180B6C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80180B6C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80180B6C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80180B6C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80180928[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80180B6C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801808EC[]; + extern u8 D_801808FC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801808EC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801808FC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80180B6C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80180B6C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80180B6C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80180BA0[])(void); + D_80180BA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80180928[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180BA8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80180BC0[])(void); + D_80180BC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80180928[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180BA8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180BA8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80180BE0[])(void); + D_80180BE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80180928[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80180928)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80180BF0; +extern u16 D_80180BF2; +extern u16 D_80180BF4; +extern s32 D_80180BF8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80180BF0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80180BF2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80180BF4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180BF8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80180C00; + +void func_8015E588(void) { + func_8013C9C4(&D_80180C00); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80180928[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80180928)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80180C14[])(void); + D_80180C14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80180928[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80180928[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80180C1C[])(void); + D_80180C1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018090C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018090C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80180928[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80180C24[])(void); + D_80180C24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80180928[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80180928[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80180C2C[])(void); + D_80180C2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80180928[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80180C34; + extern s32 D_80180C44; + extern s32 D_80180C54; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80180928[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180C34); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180C44); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80180928[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80180C54); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80180C64[])(void); + D_80180C64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80180928[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80180928[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80180928[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80180928[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80180C70[])(void); + D_80180C70[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80180928[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80180928[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80180928[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80180928[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80180C84[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80180C84[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80180928[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80180928)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80180928[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80180928[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80180D00[])(void); + D_80180D00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80180928[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80180928)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80180D10[])(void); + D_80180D10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80180928[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80180928[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80180928[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80180928[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80180928[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80180928[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80180928[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80180D18[])(void); + D_80180D18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80180928[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80180928)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80180928[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80180928)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80180D24[])(void); + D_80180D24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80180928 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80180928[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80180928[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80180928[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80180D34[])(void); + +void func_80160EA4(void *a0) { + D_80180D34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80180928[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80180928[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80180D64[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80180D64[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80180DC8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80180DC8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80199998[]; + extern u8 D_80180D94[]; + extern u8 D_80180DB4[]; + extern u8 D_801999A4[]; + extern u8 D_801999CC[]; + extern u8 D_801999E4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80199998[0] = p; + func_80024054(&D_80180D94, &D_801999A4); + func_8001CE28(p, &D_801999A4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80199998[1] = p; + func_80024054(&D_80180DB4, &D_801999CC); + func_8001CE28(p, &D_801999CC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80199998[2] = p; + func_800242D0((s16)func_801620C4(), &D_801999E4, 0x84); + func_8001CE68(p, &D_801999E4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801999E4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80199998[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80199998; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80180DC8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80180DC8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80180DC8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80180DC8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80199998[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80199998; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80180DEC[])(void); + +void func_80162330(void *a0) { + D_80180DEC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801999F0[i] via `extern int D_801999F0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80180DF8[]; + extern s32 D_80180E10; + extern u8 D_801999FC[]; + extern u8 D_80199A24[]; + extern u8 D_80199A40[]; + extern int D_801999F0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801999F0[0] = (s32)item; + func_80024054(D_80180DF8, D_801999FC); + func_8001CE28(item, D_801999FC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801999F0[1] = (s32)item; + func_80024054(((u8 *)&D_80180E10), D_80199A24); + func_8001CE28(item, D_80199A24); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801999F0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_80199A40, 0x84); + func_8001CE68(item, D_80199A40); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_80199A40, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801999F0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801999F0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_801627E8); + + +extern void (*D_80180E34[])(void); + +void func_80162834(void *a0) { + D_80180E34[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80180E24; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80180E24, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80199268[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80199268, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80199268[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80199268, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80180E3C[])(void); + +void func_80163A58(void *a0) { + D_80180E3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80199270; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80199270; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80180E90[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80180E90[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80180E58; +extern s16 D_80180E8C; +extern s16 D_80180E8A; +extern s16 D_80180E88; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80180E58; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80180E8C = 0x80; + D_80180E8A = 0x80; + D_80180E88 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80180E8C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180E8C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80180E8C - 8; + D_80180E8C = nv; + D_80180E8A = nv; + D_80180E88 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80180E9C[])(void); + +void func_80164BA0(void *a0) { + D_80180E9C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_80199A50; +extern u8 D_80199A51; +extern u8 D_80199A52; +extern u8 D_80199A53; +extern u8 D_80199A54; +extern u8 D_80199A55; +extern u8 D_80199A56; +extern u8 D_80199A57; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_80199A50; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_80199A51 = 0xf0; + *(u8 *)base = 0xf0; + D_80199A52 = 0xc0; + D_80199A56 = 0; + D_80199A55 = 0; + D_80199A54 = 0; + D_80199A57 = 0; + D_80199A53 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_80199A50; +extern u8 D_80199A51; +extern u8 D_80199A52; + +s32 func_80164E40(void) { + u8 *p = &D_80199A50; + if (*p != 0) { + *p -= 0x10; + } + if (D_80199A51 != 0) { + D_80199A51 -= 0x10; + } + if (D_80199A52 != 0) { + D_80199A52 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80180EAC[])(void); + +void func_80164EA4(void *a0) { + D_80180EAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80199A9C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80199A9C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80199A90[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80199A90[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80199A90[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80199A90; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80199A90; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80180EC0[]; + extern u32 D_80180EE0, D_80180EE4, D_80180EE8, D_80180EEC; + extern u32 D_80180EE0, D_80180EE4, D_80180EE8, D_80180EEC; + extern u32 D_80180EE0, D_80180EE4, D_80180EE8, D_80180EEC; + extern u32 D_80180EE0, D_80180EE4, D_80180EE8, D_80180EEC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80180EC0[0x00], p); + ApplyMatrixSV(mat, &D_80180EC0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80180EC0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80180EC0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80180EE8; + *(u32 *)(prim + 0x24) = D_80180EE0; + *(u32 *)(prim + 0x28) = D_80180EEC; + *(u32 *)(prim + 0x2c) = D_80180EE4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80180EF0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80180EF0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80180EF0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80180EF0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80180F6C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80180F6C[a1 & 0x7F]; +} + + + +extern s32 D_80180F8C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80180F8C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181008[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181008[a1 & 0x7F]; +} + + + +extern u8 D_80181028[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80181028[a1 & 0x7F]; +} + + + +extern u8 D_80181048[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181048[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80181068[])(void); + D_80181068[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801810E4[])(void); + +void func_80165AC8(void) { + D_801810E4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181160[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181160[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80199278; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80199278, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018116C[])(void); + +void func_80166018(void *a0) { + D_8018116C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181174[])(void); + +void func_801663FC(void *a0) { + D_80181174[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018123C[])(void); + +void func_80166618(void *a0) { + D_8018123C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018124C[])(void); + +void func_80166654(void *a0) { + D_8018124C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80199B10[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80199B10[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80199B10). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80199B10[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80199B10)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80199B10[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80199B10[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80181190[]; + extern u8 D_8018117C[]; + extern u8 D_801811A4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80181190; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018117C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801811A4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80167714); + + +extern void (*D_8018125C[])(void); + +void func_801678B4(void *a0) { + D_8018125C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181268[])(void); + +void func_80167A9C(void *a0) { + D_80181268[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181374; + extern u8 D_80181388[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181374); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181388; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801811C8[]; +extern u8 D_801811DC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801811C8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801811DC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181280[])(void); + +void func_80168744(void *a0) { + D_80181280[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181270 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181270[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181270; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181288[])(void); + +void func_801689D8(void *a0) { + D_80181288[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181290[])(void); + +void func_80168AA8(void *a0) { + D_80181290[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181298[])(void); + +void func_80168D58(void *a0) { + D_80181298[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801812A0[])(void); + +void func_8016901C(void *a0) { + D_801812A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_000/nonmatchings/ov_SC05_000_jr_8015C32C", func_80169228); + + +extern void (*D_801812A8[])(void); + +void func_801693CC(void *a0) { + D_801812A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801812B0[])(void); + +void func_80169830(void *a0) { + D_801812B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181364[])(void); + +void func_80169B80(void *a0) { + D_80181364[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801812B8[]; + extern u8 D_80181328[]; + extern u8 D_80181358[]; + extern u8 D_8019AB10[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181358, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801812B8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019AB10; + RotMatrixYXZ(rot, D_8019AB10); + func_80048D9C(D_8019AB10, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181328); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018136C[])(void); + +void func_80169F00(void *a0) { + D_8018136C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018131C[]; +extern char D_801812DC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018131C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801812DC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801813A4[])(void); + +void func_8016A020(void *a0) { + D_801813A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181374; + extern u8 D_80181388[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181374); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181388; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801813B0[])(void); + +void func_8016A700(void *a0) { + D_801813B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801813F8[])(void); + +void func_8016AB30(void *a0) { + D_801813F8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_001/ov_SC05_001_jr_8015AE2C.c b/src/ov_SC05_001/ov_SC05_001_jr_8015AE2C.c index 6d11513f7..17a142669 100644 --- a/src/ov_SC05_001/ov_SC05_001_jr_8015AE2C.c +++ b/src/ov_SC05_001/ov_SC05_001_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80188290[])(void); - -void func_8015C714(void *a0) { - D_80188290[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80188104[])(void*); - extern int D_801880A8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80188104)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80188104)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801880A8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80188104[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80188104[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80188104[])(void*); - extern int D_801880A8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80188104)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801880A8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80188104)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801882A0[])(void); - D_801882A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80188104[])(struct Ent_8015CD20 *); - extern u8 D_801880B8; - extern u8 D_801882A8; - extern u8 D_801882B8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80188104[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801880B8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801882A8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801882B8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80188104[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801882D8[])(void); - D_801882D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801882C8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801882C8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80188104[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80188334; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80188334, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80187418[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80187418; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018833C[])(void); - D_8018833C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80188348[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80188348[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80188348[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80188348[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80188104[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80188348[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801880C8[]; - extern u8 D_801880D8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801880C8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801880D8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80188348[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80188348[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80188348[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018837C[])(void); - D_8018837C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188104[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188384[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018839C[])(void); - D_8018839C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188104[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188384[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801883BC[])(void); - D_801883BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80188104[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188104)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801883CC; -extern u16 D_801883CE; -extern u16 D_801883D0; -extern s32 D_801883D4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801883CC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801883CE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801883D0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801883D4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801883DC; - -void func_8015E588(void) { - func_8013C9C4(&D_801883DC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80188104[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188104)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801883F0[])(void); - D_801883F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80188104[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80188104[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801883F8[])(void); - D_801883F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801880E8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801880E8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80188104[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80188400[])(void); - D_80188400[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80188104[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80188104[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80188408[])(void); - D_80188408[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80188104[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80188410; - extern s32 D_80188420; - extern s32 D_80188430; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80188104[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188410); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188420); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80188104[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188430); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80188440[])(void); - D_80188440[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80188104[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80188104[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80188104[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188104[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018844C[])(void); - D_8018844C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80188104[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188104[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80188104[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188104[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80188460[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80188460[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80188104[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80188104)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80188104[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188104[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801884DC[])(void); - D_801884DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80188104[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80188104)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801884EC[])(void); - D_801884EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80188104[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80188104[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80188104[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80188104[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80188104[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80188104[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80188104[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801884F4[])(void); - D_801884F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80188104[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80188104)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80188104[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80188104)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80188500[])(void); - D_80188500[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188104 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80188104[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80188104[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80188104[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80188510[])(void); - -void func_80160EA4(void *a0) { - D_80188510[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80188104[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80188104[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80188540[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80188540[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801885A4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801885A4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B4A58[]; - extern u8 D_80188570[]; - extern u8 D_80188590[]; - extern u8 D_801B4A64[]; - extern u8 D_801B4A8C[]; - extern u8 D_801B4AA4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B4A58[0] = p; - func_80024054(&D_80188570, &D_801B4A64); - func_8001CE28(p, &D_801B4A64); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B4A58[1] = p; - func_80024054(&D_80188590, &D_801B4A8C); - func_8001CE28(p, &D_801B4A8C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B4A58[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B4AA4, 0x84); - func_8001CE68(p, &D_801B4AA4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B4AA4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B4A58[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B4A58; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801885A4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801885A4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801885A4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801885A4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B4A58[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B4A58; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801885C8[])(void); - -void func_80162330(void *a0) { - D_801885C8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B4AB0[i] via `extern int D_801B4AB0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801885D4[]; - extern s32 D_801885EC; - extern u8 D_801B4ABC[]; - extern u8 D_801B4AE4[]; - extern u8 D_801B4B00[]; - extern int D_801B4AB0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B4AB0[0] = (s32)item; - func_80024054(D_801885D4, D_801B4ABC); - func_8001CE28(item, D_801B4ABC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B4AB0[1] = (s32)item; - func_80024054(((u8 *)&D_801885EC), D_801B4AE4); - func_8001CE28(item, D_801B4AE4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B4AB0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B4B00, 0x84); - func_8001CE68(item, D_801B4B00); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B4B00, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B4AB0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B4AB0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_801627E8); - - -extern void (*D_80188610[])(void); - -void func_80162834(void *a0) { - D_80188610[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80188600; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80188600, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B421C[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B421C, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B421C[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B421C, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80188618[])(void); - -void func_80163A58(void *a0) { - D_80188618[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B4224; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B4224; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018866C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018866C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80188634; -extern s16 D_80188668; -extern s16 D_80188666; -extern s16 D_80188664; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80188634; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80188668 = 0x80; - D_80188666 = 0x80; - D_80188664 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80188668 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188668` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80188668 - 8; - D_80188668 = nv; - D_80188666 = nv; - D_80188664 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80188678[])(void); - -void func_80164BA0(void *a0) { - D_80188678[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B4B10; -extern u8 D_801B4B11; -extern u8 D_801B4B12; -extern u8 D_801B4B13; -extern u8 D_801B4B14; -extern u8 D_801B4B15; -extern u8 D_801B4B16; -extern u8 D_801B4B17; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B4B10; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B4B11 = 0xf0; - *(u8 *)base = 0xf0; - D_801B4B12 = 0xc0; - D_801B4B16 = 0; - D_801B4B15 = 0; - D_801B4B14 = 0; - D_801B4B17 = 0; - D_801B4B13 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B4B10; -extern u8 D_801B4B11; -extern u8 D_801B4B12; - -s32 func_80164E40(void) { - u8 *p = &D_801B4B10; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B4B11 != 0) { - D_801B4B11 -= 0x10; - } - if (D_801B4B12 != 0) { - D_801B4B12 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80188688[])(void); - -void func_80164EA4(void *a0) { - D_80188688[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B4B5C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B4B5C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B4B50[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B4B50[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B4B50[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B4B50; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B4B50; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018869C[]; - extern u32 D_801886BC, D_801886C0, D_801886C4, D_801886C8; - extern u32 D_801886BC, D_801886C0, D_801886C4, D_801886C8; - extern u32 D_801886BC, D_801886C0, D_801886C4, D_801886C8; - extern u32 D_801886BC, D_801886C0, D_801886C4, D_801886C8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018869C[0x00], p); - ApplyMatrixSV(mat, &D_8018869C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018869C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018869C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801886C4; - *(u32 *)(prim + 0x24) = D_801886BC; - *(u32 *)(prim + 0x28) = D_801886C8; - *(u32 *)(prim + 0x2c) = D_801886C0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801886CC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801886CC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801886CC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801886CC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80188748[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80188748[a1 & 0x7F]; -} - - - -extern s32 D_80188768[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80188768[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801887E4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801887E4[a1 & 0x7F]; -} - - - -extern u8 D_80188804[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80188804[a1 & 0x7F]; -} - - - -extern u8 D_80188824[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80188824[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80188844[])(void); - D_80188844[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801888C0[])(void); - -void func_80165AC8(void) { - D_801888C0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018893C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018893C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B422C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B422C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80188948[])(void); - -void func_80166018(void *a0) { - D_80188948[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80188950[])(void); - -void func_801663FC(void *a0) { - D_80188950[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80188A18[])(void); - -void func_80166618(void *a0) { - D_80188A18[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80188A28[])(void); - -void func_80166654(void *a0) { - D_80188A28[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B4BD0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B4BD0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B4BD0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B4BD0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B4BD0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B4BD0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B4BD0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018896C[]; - extern u8 D_80188958[]; - extern u8 D_80188980[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018896C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80188958; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80188980; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80167714); - - -extern void (*D_80188A38[])(void); - -void func_801678B4(void *a0) { - D_80188A38[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80188A44[])(void); - -void func_80167A9C(void *a0) { - D_80188A44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80188B50; - extern u8 D_80188B64[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80188B50); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188B64; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801889A4[]; -extern u8 D_801889B8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801889A4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801889B8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80188A5C[])(void); - -void func_80168744(void *a0) { - D_80188A5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80188A4C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80188A4C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80188A4C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80188A64[])(void); - -void func_801689D8(void *a0) { - D_80188A64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80188A6C[])(void); - -void func_80168AA8(void *a0) { - D_80188A6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80188A74[])(void); - -void func_80168D58(void *a0) { - D_80188A74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80188A7C[])(void); - -void func_8016901C(void *a0) { - D_80188A7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015AE2C", func_80169228); - - -extern void (*D_80188A84[])(void); - -void func_801693CC(void *a0) { - D_80188A84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80188A8C[])(void); - -void func_80169830(void *a0) { - D_80188A8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80188B40[])(void); - -void func_80169B80(void *a0) { - D_80188B40[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80188A94[]; - extern u8 D_80188B04[]; - extern u8 D_80188B34[]; - extern u8 D_801B5EC0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80188B34, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80188A94[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B5EC0; - RotMatrixYXZ(rot, D_801B5EC0); - func_80048D9C(D_801B5EC0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80188B04); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80188B48[])(void); - -void func_80169F00(void *a0) { - D_80188B48[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80188AF8[]; -extern char D_80188AB8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80188AF8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188AB8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80188B80[])(void); - -void func_8016A020(void *a0) { - D_80188B80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80188B50; - extern u8 D_80188B64[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80188B50); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188B64; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80188B8C[])(void); - -void func_8016A700(void *a0) { - D_80188B8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80188BD4[])(void); - -void func_8016AB30(void *a0) { - D_80188BD4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c b/src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c new file mode 100644 index 000000000..caf3a4efc --- /dev/null +++ b/src/ov_SC05_001/ov_SC05_001_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80187FA0; +extern u8 D_80187F10; +extern u8 D_80187EEC; +extern u8 D_80187EC8; +extern u8 D_80187F7C; +extern u8 D_80187F58; +extern u8 D_80187F34; +extern u8 D_80187EA4; +extern void func_80145934(void); +extern u8 D_80188030; +extern u8 D_8018800C; +extern u8 D_80187FE8; +extern u8 D_80187FC4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80187428[]; +extern unsigned char D_80187458[]; +extern unsigned char D_801874A8[]; +extern unsigned char D_801874D8[]; +extern unsigned char D_80187508[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80187558[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80187620[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801876A8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801876B0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B4A00; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B4A04; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801876E0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80187788[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801877AC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018779C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801877C0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801877CC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801877DC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801877F4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801877E4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80187808[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80187824[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80187814; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80187838[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018784C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80187860; +extern void (*D_80187888[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80187868; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801878D4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801878D8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80187D3C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80187D4C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B4A38; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80187D74[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80187D54; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80187D64; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80187DB4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80187DBC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80187D88; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80187DC8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80187D98; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B4A40; +extern s32 D_801B4A4C; +extern s32 D_801B4A50; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80187E04[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80187DD8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B4A48; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80188054[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80187E74[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801880F8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018824C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80188068; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80188254[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80188078; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80188098; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018825C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80188284[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80188104[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80188104[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80188104[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80188104[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80188104[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80188104[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80188104[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80188104[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80188290[])(void); + +void func_8015C714(void *a0) { + D_80188290[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80188104[])(void*); + extern int D_801880A8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80188104)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80188104)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801880A8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80188104[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80188104[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80188104[])(void*); + extern int D_801880A8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80188104)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801880A8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80188104)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801882A0[])(void); + D_801882A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80188104[])(struct Ent_8015CD20 *); + extern u8 D_801880B8; + extern u8 D_801882A8; + extern u8 D_801882B8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80188104[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801880B8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801882A8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801882B8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80188104[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801882D8[])(void); + D_801882D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801882C8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801882C8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80188104[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80188334; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80188334, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80187418[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80187418; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018833C[])(void); + D_8018833C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80188348[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80188348[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80188348[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80188348[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80188104[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80188348[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801880C8[]; + extern u8 D_801880D8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801880C8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801880D8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80188348[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80188348[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80188348[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018837C[])(void); + D_8018837C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188104[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188384[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018839C[])(void); + D_8018839C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188104[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188384[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188384[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801883BC[])(void); + D_801883BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80188104[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188104)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801883CC; +extern u16 D_801883CE; +extern u16 D_801883D0; +extern s32 D_801883D4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801883CC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801883CE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801883D0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801883D4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801883DC; + +void func_8015E588(void) { + func_8013C9C4(&D_801883DC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80188104[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188104)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801883F0[])(void); + D_801883F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80188104[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80188104[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801883F8[])(void); + D_801883F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801880E8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801880E8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80188104[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80188400[])(void); + D_80188400[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80188104[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80188104[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80188408[])(void); + D_80188408[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80188104[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80188410; + extern s32 D_80188420; + extern s32 D_80188430; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80188104[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188410); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188420); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80188104[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80188430); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80188440[])(void); + D_80188440[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80188104[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80188104[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80188104[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188104[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018844C[])(void); + D_8018844C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80188104[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188104[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80188104[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188104[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80188460[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80188460[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80188104[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80188104)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80188104[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188104[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801884DC[])(void); + D_801884DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80188104[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80188104)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801884EC[])(void); + D_801884EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80188104[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80188104[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80188104[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80188104[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80188104[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80188104[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80188104[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801884F4[])(void); + D_801884F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80188104[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80188104)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80188104[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80188104)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80188500[])(void); + D_80188500[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188104 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80188104[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80188104[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80188104[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80188510[])(void); + +void func_80160EA4(void *a0) { + D_80188510[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80188104[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80188104[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80188540[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80188540[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801885A4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801885A4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B4A58[]; + extern u8 D_80188570[]; + extern u8 D_80188590[]; + extern u8 D_801B4A64[]; + extern u8 D_801B4A8C[]; + extern u8 D_801B4AA4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B4A58[0] = p; + func_80024054(&D_80188570, &D_801B4A64); + func_8001CE28(p, &D_801B4A64); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B4A58[1] = p; + func_80024054(&D_80188590, &D_801B4A8C); + func_8001CE28(p, &D_801B4A8C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B4A58[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B4AA4, 0x84); + func_8001CE68(p, &D_801B4AA4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B4AA4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B4A58[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B4A58; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801885A4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801885A4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801885A4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801885A4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B4A58[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B4A58; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801885C8[])(void); + +void func_80162330(void *a0) { + D_801885C8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B4AB0[i] via `extern int D_801B4AB0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801885D4[]; + extern s32 D_801885EC; + extern u8 D_801B4ABC[]; + extern u8 D_801B4AE4[]; + extern u8 D_801B4B00[]; + extern int D_801B4AB0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B4AB0[0] = (s32)item; + func_80024054(D_801885D4, D_801B4ABC); + func_8001CE28(item, D_801B4ABC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B4AB0[1] = (s32)item; + func_80024054(((u8 *)&D_801885EC), D_801B4AE4); + func_8001CE28(item, D_801B4AE4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B4AB0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B4B00, 0x84); + func_8001CE68(item, D_801B4B00); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B4B00, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B4AB0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B4AB0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_801627E8); + + +extern void (*D_80188610[])(void); + +void func_80162834(void *a0) { + D_80188610[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80188600; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80188600, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B421C[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B421C, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B421C[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B421C, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80188618[])(void); + +void func_80163A58(void *a0) { + D_80188618[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B4224; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B4224; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018866C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018866C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80188634; +extern s16 D_80188668; +extern s16 D_80188666; +extern s16 D_80188664; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80188634; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80188668 = 0x80; + D_80188666 = 0x80; + D_80188664 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80188668 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188668` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80188668 - 8; + D_80188668 = nv; + D_80188666 = nv; + D_80188664 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80188678[])(void); + +void func_80164BA0(void *a0) { + D_80188678[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B4B10; +extern u8 D_801B4B11; +extern u8 D_801B4B12; +extern u8 D_801B4B13; +extern u8 D_801B4B14; +extern u8 D_801B4B15; +extern u8 D_801B4B16; +extern u8 D_801B4B17; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B4B10; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B4B11 = 0xf0; + *(u8 *)base = 0xf0; + D_801B4B12 = 0xc0; + D_801B4B16 = 0; + D_801B4B15 = 0; + D_801B4B14 = 0; + D_801B4B17 = 0; + D_801B4B13 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B4B10; +extern u8 D_801B4B11; +extern u8 D_801B4B12; + +s32 func_80164E40(void) { + u8 *p = &D_801B4B10; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B4B11 != 0) { + D_801B4B11 -= 0x10; + } + if (D_801B4B12 != 0) { + D_801B4B12 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80188688[])(void); + +void func_80164EA4(void *a0) { + D_80188688[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B4B5C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B4B5C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B4B50[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B4B50[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B4B50[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B4B50; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B4B50; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018869C[]; + extern u32 D_801886BC, D_801886C0, D_801886C4, D_801886C8; + extern u32 D_801886BC, D_801886C0, D_801886C4, D_801886C8; + extern u32 D_801886BC, D_801886C0, D_801886C4, D_801886C8; + extern u32 D_801886BC, D_801886C0, D_801886C4, D_801886C8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018869C[0x00], p); + ApplyMatrixSV(mat, &D_8018869C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018869C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018869C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801886C4; + *(u32 *)(prim + 0x24) = D_801886BC; + *(u32 *)(prim + 0x28) = D_801886C8; + *(u32 *)(prim + 0x2c) = D_801886C0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801886CC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801886CC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801886CC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801886CC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80188748[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80188748[a1 & 0x7F]; +} + + + +extern s32 D_80188768[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80188768[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801887E4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801887E4[a1 & 0x7F]; +} + + + +extern u8 D_80188804[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80188804[a1 & 0x7F]; +} + + + +extern u8 D_80188824[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80188824[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80188844[])(void); + D_80188844[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801888C0[])(void); + +void func_80165AC8(void) { + D_801888C0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018893C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018893C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B422C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B422C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80188948[])(void); + +void func_80166018(void *a0) { + D_80188948[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80188950[])(void); + +void func_801663FC(void *a0) { + D_80188950[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80188A18[])(void); + +void func_80166618(void *a0) { + D_80188A18[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80188A28[])(void); + +void func_80166654(void *a0) { + D_80188A28[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B4BD0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B4BD0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B4BD0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B4BD0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B4BD0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B4BD0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B4BD0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018896C[]; + extern u8 D_80188958[]; + extern u8 D_80188980[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018896C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80188958; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80188980; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80167714); + + +extern void (*D_80188A38[])(void); + +void func_801678B4(void *a0) { + D_80188A38[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80188A44[])(void); + +void func_80167A9C(void *a0) { + D_80188A44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80188B50; + extern u8 D_80188B64[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80188B50); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188B64; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801889A4[]; +extern u8 D_801889B8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801889A4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801889B8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80188A5C[])(void); + +void func_80168744(void *a0) { + D_80188A5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80188A4C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80188A4C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80188A4C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80188A64[])(void); + +void func_801689D8(void *a0) { + D_80188A64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80188A6C[])(void); + +void func_80168AA8(void *a0) { + D_80188A6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80188A74[])(void); + +void func_80168D58(void *a0) { + D_80188A74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80188A7C[])(void); + +void func_8016901C(void *a0) { + D_80188A7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_001/nonmatchings/ov_SC05_001_jr_8015C32C", func_80169228); + + +extern void (*D_80188A84[])(void); + +void func_801693CC(void *a0) { + D_80188A84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80188A8C[])(void); + +void func_80169830(void *a0) { + D_80188A8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80188B40[])(void); + +void func_80169B80(void *a0) { + D_80188B40[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80188A94[]; + extern u8 D_80188B04[]; + extern u8 D_80188B34[]; + extern u8 D_801B5EC0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80188B34, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80188A94[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B5EC0; + RotMatrixYXZ(rot, D_801B5EC0); + func_80048D9C(D_801B5EC0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80188B04); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80188B48[])(void); + +void func_80169F00(void *a0) { + D_80188B48[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80188AF8[]; +extern char D_80188AB8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80188AF8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188AB8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80188B80[])(void); + +void func_8016A020(void *a0) { + D_80188B80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80188B50; + extern u8 D_80188B64[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80188B50); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188B64; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80188B8C[])(void); + +void func_8016A700(void *a0) { + D_80188B8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80188BD4[])(void); + +void func_8016AB30(void *a0) { + D_80188BD4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_002/ov_SC05_002_jr_8015AE2C.c b/src/ov_SC05_002/ov_SC05_002_jr_8015AE2C.c index d2647b99c..a8052f232 100644 --- a/src/ov_SC05_002/ov_SC05_002_jr_8015AE2C.c +++ b/src/ov_SC05_002/ov_SC05_002_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80182A50[])(void); - -void func_8015C714(void *a0) { - D_80182A50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801828C4[])(void*); - extern int D_80182868; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801828C4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801828C4)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182868); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801828C4[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801828C4[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801828C4[])(void*); - extern int D_80182868; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801828C4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182868); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801828C4)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80182A60[])(void); - D_80182A60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801828C4[])(struct Ent_8015CD20 *); - extern u8 D_80182878; - extern u8 D_80182A68; - extern u8 D_80182A78; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801828C4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182878); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182A68); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182A78); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801828C4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80182A98[])(void); - D_80182A98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80182A88; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80182A88 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801828C4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80182AF4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80182AF4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80181BD8[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80181BD8; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80182AFC[])(void); - D_80182AFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80182B08[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80182B08[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80182B08[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80182B08[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801828C4[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80182B08[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80182888[]; - extern u8 D_80182898[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182888); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182898); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80182B08[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80182B08[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80182B08[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80182B3C[])(void); - D_80182B3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801828C4[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182B44[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80182B5C[])(void); - D_80182B5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801828C4[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182B44[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80182B7C[])(void); - D_80182B7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801828C4[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801828C4)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80182B8C; -extern u16 D_80182B8E; -extern u16 D_80182B90; -extern s32 D_80182B94; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80182B8C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80182B8E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80182B90 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182B94, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80182B9C; - -void func_8015E588(void) { - func_8013C9C4(&D_80182B9C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801828C4[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801828C4)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80182BB0[])(void); - D_80182BB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801828C4[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801828C4[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80182BB8[])(void); - D_80182BB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801828A8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801828A8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801828C4[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80182BC0[])(void); - D_80182BC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801828C4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801828C4[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80182BC8[])(void); - D_80182BC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801828C4[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80182BD0; - extern s32 D_80182BE0; - extern s32 D_80182BF0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801828C4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182BD0); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182BE0); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801828C4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182BF0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80182C00[])(void); - D_80182C00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801828C4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801828C4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801828C4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801828C4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80182C0C[])(void); - D_80182C0C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801828C4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801828C4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801828C4[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801828C4[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80182C20[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80182C20[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801828C4[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801828C4)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801828C4[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801828C4[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80182C9C[])(void); - D_80182C9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801828C4[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801828C4)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80182CAC[])(void); - D_80182CAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801828C4[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801828C4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801828C4[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801828C4[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801828C4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801828C4[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801828C4[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80182CB4[])(void); - D_80182CB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801828C4[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801828C4)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801828C4[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801828C4)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80182CC0[])(void); - D_80182CC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801828C4 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801828C4[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801828C4[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801828C4[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80182CD0[])(void); - -void func_80160EA4(void *a0) { - D_80182CD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801828C4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801828C4[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80182D00[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80182D00[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80182D64; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80182D64); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019ECF8[]; - extern u8 D_80182D30[]; - extern u8 D_80182D50[]; - extern u8 D_8019ED04[]; - extern u8 D_8019ED2C[]; - extern u8 D_8019ED44[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019ECF8[0] = p; - func_80024054(&D_80182D30, &D_8019ED04); - func_8001CE28(p, &D_8019ED04); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019ECF8[1] = p; - func_80024054(&D_80182D50, &D_8019ED2C); - func_8001CE28(p, &D_8019ED2C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019ECF8[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019ED44, 0x84); - func_8001CE68(p, &D_8019ED44); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019ED44, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019ECF8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019ECF8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80182D64; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80182D64; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80182D64; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80182D64; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019ECF8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019ECF8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80182D88[])(void); - -void func_80162330(void *a0) { - D_80182D88[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019ED50[i] via `extern int D_8019ED50[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80182D94[]; - extern s32 D_80182DAC; - extern u8 D_8019ED5C[]; - extern u8 D_8019ED84[]; - extern u8 D_8019EDA0[]; - extern int D_8019ED50[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019ED50[0] = (s32)item; - func_80024054(D_80182D94, D_8019ED5C); - func_8001CE28(item, D_8019ED5C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019ED50[1] = (s32)item; - func_80024054(((u8 *)&D_80182DAC), D_8019ED84); - func_8001CE28(item, D_8019ED84); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019ED50[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019EDA0, 0x84); - func_8001CE68(item, D_8019EDA0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019EDA0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019ED50[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019ED50; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_801627E8); - - -extern void (*D_80182DD0[])(void); - -void func_80162834(void *a0) { - D_80182DD0[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80182DC0; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80182DC0, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019E5C8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019E5C8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019E5C8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019E5C8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80182DD8[])(void); - -void func_80163A58(void *a0) { - D_80182DD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019E5D0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019E5D0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80182E2C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80182E2C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80182DF4; -extern s16 D_80182E28; -extern s16 D_80182E26; -extern s16 D_80182E24; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80182DF4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80182E28 = 0x80; - D_80182E26 = 0x80; - D_80182E24 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80182E28 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182E28` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80182E28 - 8; - D_80182E28 = nv; - D_80182E26 = nv; - D_80182E24 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80182E38[])(void); - -void func_80164BA0(void *a0) { - D_80182E38[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019EDB0; -extern u8 D_8019EDB1; -extern u8 D_8019EDB2; -extern u8 D_8019EDB3; -extern u8 D_8019EDB4; -extern u8 D_8019EDB5; -extern u8 D_8019EDB6; -extern u8 D_8019EDB7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019EDB0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019EDB1 = 0xf0; - *(u8 *)base = 0xf0; - D_8019EDB2 = 0xc0; - D_8019EDB6 = 0; - D_8019EDB5 = 0; - D_8019EDB4 = 0; - D_8019EDB7 = 0; - D_8019EDB3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019EDB0; -extern u8 D_8019EDB1; -extern u8 D_8019EDB2; - -s32 func_80164E40(void) { - u8 *p = &D_8019EDB0; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019EDB1 != 0) { - D_8019EDB1 -= 0x10; - } - if (D_8019EDB2 != 0) { - D_8019EDB2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80182E48[])(void); - -void func_80164EA4(void *a0) { - D_80182E48[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019EDFC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019EDFC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019EDF0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019EDF0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019EDF0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019EDF0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019EDF0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80182E5C[]; - extern u32 D_80182E7C, D_80182E80, D_80182E84, D_80182E88; - extern u32 D_80182E7C, D_80182E80, D_80182E84, D_80182E88; - extern u32 D_80182E7C, D_80182E80, D_80182E84, D_80182E88; - extern u32 D_80182E7C, D_80182E80, D_80182E84, D_80182E88; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80182E5C[0x00], p); - ApplyMatrixSV(mat, &D_80182E5C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80182E5C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80182E5C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80182E84; - *(u32 *)(prim + 0x24) = D_80182E7C; - *(u32 *)(prim + 0x28) = D_80182E88; - *(u32 *)(prim + 0x2c) = D_80182E80; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80182E8C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80182E8C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80182E8C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80182E8C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80182F08[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80182F08[a1 & 0x7F]; -} - - - -extern s32 D_80182F28[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80182F28[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80182FA4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80182FA4[a1 & 0x7F]; -} - - - -extern u8 D_80182FC4[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182FC4[a1 & 0x7F]; -} - - - -extern u8 D_80182FE4[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182FE4[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80183004[])(void); - D_80183004[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80183080[])(void); - -void func_80165AC8(void) { - D_80183080[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801830FC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801830FC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019E5D8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019E5D8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80183108[])(void); - -void func_80166018(void *a0) { - D_80183108[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80183110[])(void); - -void func_801663FC(void *a0) { - D_80183110[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801831D8[])(void); - -void func_80166618(void *a0) { - D_801831D8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801831E8[])(void); - -void func_80166654(void *a0) { - D_801831E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019EE70[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019EE70[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019EE70). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019EE70[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019EE70)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019EE70[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019EE70[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018312C[]; - extern u8 D_80183118[]; - extern u8 D_80183140[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018312C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80183118; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80183140; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80167714); - - -extern void (*D_801831F8[])(void); - -void func_801678B4(void *a0) { - D_801831F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80183204[])(void); - -void func_80167A9C(void *a0) { - D_80183204[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80183310; - extern u8 D_80183324[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80183310); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80183324; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80183164[]; -extern u8 D_80183178[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80183164; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80183178; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018321C[])(void); - -void func_80168744(void *a0) { - D_8018321C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018320C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018320C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018320C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80183224[])(void); - -void func_801689D8(void *a0) { - D_80183224[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018322C[])(void); - -void func_80168AA8(void *a0) { - D_8018322C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80183234[])(void); - -void func_80168D58(void *a0) { - D_80183234[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018323C[])(void); - -void func_8016901C(void *a0) { - D_8018323C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015AE2C", func_80169228); - - -extern void (*D_80183244[])(void); - -void func_801693CC(void *a0) { - D_80183244[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018324C[])(void); - -void func_80169830(void *a0) { - D_8018324C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80183300[])(void); - -void func_80169B80(void *a0) { - D_80183300[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80183254[]; - extern u8 D_801832C4[]; - extern u8 D_801832F4[]; - extern u8 D_8019FE78[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801832F4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80183254[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019FE78; - RotMatrixYXZ(rot, D_8019FE78); - func_80048D9C(D_8019FE78, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801832C4); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80183308[])(void); - -void func_80169F00(void *a0) { - D_80183308[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801832B8[]; -extern char D_80183278[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801832B8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183278); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80183340[])(void); - -void func_8016A020(void *a0) { - D_80183340[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80183310; - extern u8 D_80183324[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80183310); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80183324; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018334C[])(void); - -void func_8016A700(void *a0) { - D_8018334C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80183394[])(void); - -void func_8016AB30(void *a0) { - D_80183394[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c b/src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c new file mode 100644 index 000000000..2804e840a --- /dev/null +++ b/src/ov_SC05_002/ov_SC05_002_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80182760; +extern u8 D_801826D0; +extern u8 D_801826AC; +extern u8 D_80182688; +extern u8 D_8018273C; +extern u8 D_80182718; +extern u8 D_801826F4; +extern u8 D_80182664; +extern void func_80145934(void); +extern u8 D_801827F0; +extern u8 D_801827CC; +extern u8 D_801827A8; +extern u8 D_80182784; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80181BE8[]; +extern unsigned char D_80181C18[]; +extern unsigned char D_80181C68[]; +extern unsigned char D_80181C98[]; +extern unsigned char D_80181CC8[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80181D18[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80181DE0[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80181E68[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80181E70; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019ECA0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019ECA4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80181EA0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80181F48[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80181F6C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80181F5C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80181F80[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80181F8C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80181F9C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181FB4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80181FA4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181FC8[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181FE4[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181FD4; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181FF8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018200C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80182020; +extern void (*D_80182048[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80182028; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80182094[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80182098[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_801824FC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018250C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019ECD8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80182534[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80182514; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80182524; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80182574[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018257C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80182548; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80182588[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80182558; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019ECE0; +extern s32 D_8019ECEC; +extern s32 D_8019ECF0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801825C4[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80182598[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019ECE8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80182814[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80182634[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801828B8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80182A0C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80182828; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80182A14[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80182838; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80182858; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80182A1C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80182A44[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801828C4[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80182A50[])(void); + +void func_8015C714(void *a0) { + D_80182A50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801828C4[])(void*); + extern int D_80182868; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801828C4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801828C4)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182868); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801828C4[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801828C4[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801828C4[])(void*); + extern int D_80182868; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801828C4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182868); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801828C4)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80182A60[])(void); + D_80182A60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801828C4[])(struct Ent_8015CD20 *); + extern u8 D_80182878; + extern u8 D_80182A68; + extern u8 D_80182A78; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801828C4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182878); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182A68); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182A78); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801828C4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80182A98[])(void); + D_80182A98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80182A88; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80182A88 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801828C4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80182AF4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80182AF4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80181BD8[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80181BD8; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80182AFC[])(void); + D_80182AFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80182B08[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80182B08[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80182B08[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80182B08[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801828C4[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80182B08[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80182888[]; + extern u8 D_80182898[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182888); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182898); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80182B08[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80182B08[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80182B08[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80182B3C[])(void); + D_80182B3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801828C4[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182B44[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80182B5C[])(void); + D_80182B5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801828C4[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182B44[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182B44[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80182B7C[])(void); + D_80182B7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801828C4[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801828C4)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80182B8C; +extern u16 D_80182B8E; +extern u16 D_80182B90; +extern s32 D_80182B94; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80182B8C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80182B8E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80182B90 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182B94, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80182B9C; + +void func_8015E588(void) { + func_8013C9C4(&D_80182B9C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801828C4[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801828C4)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80182BB0[])(void); + D_80182BB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801828C4[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801828C4[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80182BB8[])(void); + D_80182BB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801828A8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801828A8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801828C4[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80182BC0[])(void); + D_80182BC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801828C4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801828C4[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80182BC8[])(void); + D_80182BC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801828C4[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80182BD0; + extern s32 D_80182BE0; + extern s32 D_80182BF0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182BD0); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182BE0); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801828C4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182BF0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80182C00[])(void); + D_80182C00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801828C4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801828C4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801828C4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801828C4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80182C0C[])(void); + D_80182C0C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801828C4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801828C4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801828C4[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801828C4[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80182C20[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80182C20[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801828C4[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801828C4)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801828C4[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801828C4[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80182C9C[])(void); + D_80182C9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801828C4[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801828C4)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80182CAC[])(void); + D_80182CAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801828C4[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801828C4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801828C4[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801828C4[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801828C4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801828C4[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801828C4[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80182CB4[])(void); + D_80182CB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801828C4[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801828C4)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801828C4[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801828C4)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80182CC0[])(void); + D_80182CC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801828C4 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801828C4[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801828C4[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801828C4[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80182CD0[])(void); + +void func_80160EA4(void *a0) { + D_80182CD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801828C4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801828C4[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80182D00[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80182D00[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80182D64; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80182D64); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019ECF8[]; + extern u8 D_80182D30[]; + extern u8 D_80182D50[]; + extern u8 D_8019ED04[]; + extern u8 D_8019ED2C[]; + extern u8 D_8019ED44[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019ECF8[0] = p; + func_80024054(&D_80182D30, &D_8019ED04); + func_8001CE28(p, &D_8019ED04); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019ECF8[1] = p; + func_80024054(&D_80182D50, &D_8019ED2C); + func_8001CE28(p, &D_8019ED2C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019ECF8[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019ED44, 0x84); + func_8001CE68(p, &D_8019ED44); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019ED44, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019ECF8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019ECF8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80182D64; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80182D64; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80182D64; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80182D64; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019ECF8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019ECF8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80182D88[])(void); + +void func_80162330(void *a0) { + D_80182D88[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019ED50[i] via `extern int D_8019ED50[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80182D94[]; + extern s32 D_80182DAC; + extern u8 D_8019ED5C[]; + extern u8 D_8019ED84[]; + extern u8 D_8019EDA0[]; + extern int D_8019ED50[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019ED50[0] = (s32)item; + func_80024054(D_80182D94, D_8019ED5C); + func_8001CE28(item, D_8019ED5C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019ED50[1] = (s32)item; + func_80024054(((u8 *)&D_80182DAC), D_8019ED84); + func_8001CE28(item, D_8019ED84); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019ED50[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019EDA0, 0x84); + func_8001CE68(item, D_8019EDA0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019EDA0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019ED50[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019ED50; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_801627E8); + + +extern void (*D_80182DD0[])(void); + +void func_80162834(void *a0) { + D_80182DD0[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80182DC0; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80182DC0, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019E5C8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019E5C8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019E5C8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019E5C8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80182DD8[])(void); + +void func_80163A58(void *a0) { + D_80182DD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019E5D0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019E5D0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80182E2C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80182E2C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80182DF4; +extern s16 D_80182E28; +extern s16 D_80182E26; +extern s16 D_80182E24; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80182DF4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80182E28 = 0x80; + D_80182E26 = 0x80; + D_80182E24 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80182E28 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182E28` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80182E28 - 8; + D_80182E28 = nv; + D_80182E26 = nv; + D_80182E24 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80182E38[])(void); + +void func_80164BA0(void *a0) { + D_80182E38[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019EDB0; +extern u8 D_8019EDB1; +extern u8 D_8019EDB2; +extern u8 D_8019EDB3; +extern u8 D_8019EDB4; +extern u8 D_8019EDB5; +extern u8 D_8019EDB6; +extern u8 D_8019EDB7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019EDB0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019EDB1 = 0xf0; + *(u8 *)base = 0xf0; + D_8019EDB2 = 0xc0; + D_8019EDB6 = 0; + D_8019EDB5 = 0; + D_8019EDB4 = 0; + D_8019EDB7 = 0; + D_8019EDB3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019EDB0; +extern u8 D_8019EDB1; +extern u8 D_8019EDB2; + +s32 func_80164E40(void) { + u8 *p = &D_8019EDB0; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019EDB1 != 0) { + D_8019EDB1 -= 0x10; + } + if (D_8019EDB2 != 0) { + D_8019EDB2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80182E48[])(void); + +void func_80164EA4(void *a0) { + D_80182E48[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019EDFC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019EDFC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019EDF0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019EDF0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019EDF0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019EDF0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019EDF0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80182E5C[]; + extern u32 D_80182E7C, D_80182E80, D_80182E84, D_80182E88; + extern u32 D_80182E7C, D_80182E80, D_80182E84, D_80182E88; + extern u32 D_80182E7C, D_80182E80, D_80182E84, D_80182E88; + extern u32 D_80182E7C, D_80182E80, D_80182E84, D_80182E88; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80182E5C[0x00], p); + ApplyMatrixSV(mat, &D_80182E5C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80182E5C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80182E5C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80182E84; + *(u32 *)(prim + 0x24) = D_80182E7C; + *(u32 *)(prim + 0x28) = D_80182E88; + *(u32 *)(prim + 0x2c) = D_80182E80; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80182E8C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80182E8C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80182E8C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80182E8C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80182F08[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80182F08[a1 & 0x7F]; +} + + + +extern s32 D_80182F28[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80182F28[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80182FA4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80182FA4[a1 & 0x7F]; +} + + + +extern u8 D_80182FC4[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182FC4[a1 & 0x7F]; +} + + + +extern u8 D_80182FE4[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182FE4[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80183004[])(void); + D_80183004[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80183080[])(void); + +void func_80165AC8(void) { + D_80183080[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801830FC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801830FC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019E5D8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019E5D8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80183108[])(void); + +void func_80166018(void *a0) { + D_80183108[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80183110[])(void); + +void func_801663FC(void *a0) { + D_80183110[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801831D8[])(void); + +void func_80166618(void *a0) { + D_801831D8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801831E8[])(void); + +void func_80166654(void *a0) { + D_801831E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019EE70[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019EE70[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019EE70). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019EE70[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019EE70)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019EE70[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019EE70[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018312C[]; + extern u8 D_80183118[]; + extern u8 D_80183140[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018312C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80183118; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80183140; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80167714); + + +extern void (*D_801831F8[])(void); + +void func_801678B4(void *a0) { + D_801831F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80183204[])(void); + +void func_80167A9C(void *a0) { + D_80183204[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80183310; + extern u8 D_80183324[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80183310); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80183324; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80183164[]; +extern u8 D_80183178[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80183164; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80183178; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018321C[])(void); + +void func_80168744(void *a0) { + D_8018321C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018320C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018320C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018320C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80183224[])(void); + +void func_801689D8(void *a0) { + D_80183224[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018322C[])(void); + +void func_80168AA8(void *a0) { + D_8018322C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80183234[])(void); + +void func_80168D58(void *a0) { + D_80183234[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018323C[])(void); + +void func_8016901C(void *a0) { + D_8018323C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_002/nonmatchings/ov_SC05_002_jr_8015C32C", func_80169228); + + +extern void (*D_80183244[])(void); + +void func_801693CC(void *a0) { + D_80183244[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018324C[])(void); + +void func_80169830(void *a0) { + D_8018324C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80183300[])(void); + +void func_80169B80(void *a0) { + D_80183300[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80183254[]; + extern u8 D_801832C4[]; + extern u8 D_801832F4[]; + extern u8 D_8019FE78[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801832F4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80183254[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019FE78; + RotMatrixYXZ(rot, D_8019FE78); + func_80048D9C(D_8019FE78, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801832C4); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80183308[])(void); + +void func_80169F00(void *a0) { + D_80183308[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801832B8[]; +extern char D_80183278[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801832B8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183278); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80183340[])(void); + +void func_8016A020(void *a0) { + D_80183340[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80183310; + extern u8 D_80183324[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80183310); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80183324; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018334C[])(void); + +void func_8016A700(void *a0) { + D_8018334C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80183394[])(void); + +void func_8016AB30(void *a0) { + D_80183394[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_003/ov_SC05_003_jr_8015AE2C.c b/src/ov_SC05_003/ov_SC05_003_jr_8015AE2C.c index aab2600e8..f5b8e6ccd 100644 --- a/src/ov_SC05_003/ov_SC05_003_jr_8015AE2C.c +++ b/src/ov_SC05_003/ov_SC05_003_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80184D88[])(void); - -void func_8015C714(void *a0) { - D_80184D88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80184BFC[])(void*); - extern int D_80184BA0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80184BFC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80184BFC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184BA0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80184BFC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80184BFC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80184BFC[])(void*); - extern int D_80184BA0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80184BFC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184BA0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80184BFC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80184D98[])(void); - D_80184D98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80184BFC[])(struct Ent_8015CD20 *); - extern u8 D_80184BB0; - extern u8 D_80184DA0; - extern u8 D_80184DB0; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80184BFC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184BB0); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184DA0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184DB0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80184BFC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80184DD0[])(void); - D_80184DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80184DC0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80184DC0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80184BFC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80184E2C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80184E2C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80183F10[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80183F10; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80184E34[])(void); - D_80184E34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80184E40[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80184E40[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80184E40[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80184E40[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80184BFC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80184E40[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80184BC0[]; - extern u8 D_80184BD0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184BC0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184BD0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80184E40[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184E40[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184E40[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80184E74[])(void); - D_80184E74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184BFC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184E7C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80184E94[])(void); - D_80184E94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184BFC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184E7C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80184EB4[])(void); - D_80184EB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80184BFC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184BFC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80184EC4; -extern u16 D_80184EC6; -extern u16 D_80184EC8; -extern s32 D_80184ECC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80184EC4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80184EC6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80184EC8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184ECC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80184ED4; - -void func_8015E588(void) { - func_8013C9C4(&D_80184ED4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80184BFC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184BFC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80184EE8[])(void); - D_80184EE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80184BFC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80184BFC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80184EF0[])(void); - D_80184EF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80184BE0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80184BE0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80184BFC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80184EF8[])(void); - D_80184EF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80184BFC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80184BFC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80184F00[])(void); - D_80184F00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80184BFC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80184F08; - extern s32 D_80184F18; - extern s32 D_80184F28; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80184BFC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184F08); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184F18); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80184BFC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184F28); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184F38[])(void); - D_80184F38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80184BFC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80184BFC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80184BFC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184BFC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184F44[])(void); - D_80184F44[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80184BFC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184BFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80184BFC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184BFC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80184F58[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80184F58[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80184BFC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80184BFC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80184BFC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184BFC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80184FD4[])(void); - D_80184FD4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80184BFC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80184BFC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80184FE4[])(void); - D_80184FE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80184BFC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80184BFC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80184BFC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80184BFC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80184BFC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80184BFC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80184BFC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80184FEC[])(void); - D_80184FEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80184BFC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80184BFC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80184BFC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80184BFC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80184FF8[])(void); - D_80184FF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184BFC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80184BFC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80184BFC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80184BFC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80185008[])(void); - -void func_80160EA4(void *a0) { - D_80185008[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80184BFC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80184BFC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80185038[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80185038[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018509C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018509C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801AB808[]; - extern u8 D_80185068[]; - extern u8 D_80185088[]; - extern u8 D_801AB814[]; - extern u8 D_801AB83C[]; - extern u8 D_801AB854[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801AB808[0] = p; - func_80024054(&D_80185068, &D_801AB814); - func_8001CE28(p, &D_801AB814); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801AB808[1] = p; - func_80024054(&D_80185088, &D_801AB83C); - func_8001CE28(p, &D_801AB83C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801AB808[2] = p; - func_800242D0((s16)func_801620C4(), &D_801AB854, 0x84); - func_8001CE68(p, &D_801AB854); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801AB854, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801AB808[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801AB808; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018509C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018509C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018509C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018509C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801AB808[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801AB808; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801850C0[])(void); - -void func_80162330(void *a0) { - D_801850C0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801AB860[i] via `extern int D_801AB860[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801850CC[]; - extern s32 D_801850E4; - extern u8 D_801AB86C[]; - extern u8 D_801AB894[]; - extern u8 D_801AB8B0[]; - extern int D_801AB860[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801AB860[0] = (s32)item; - func_80024054(D_801850CC, D_801AB86C); - func_8001CE28(item, D_801AB86C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801AB860[1] = (s32)item; - func_80024054(((u8 *)&D_801850E4), D_801AB894); - func_8001CE28(item, D_801AB894); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801AB860[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801AB8B0, 0x84); - func_8001CE68(item, D_801AB8B0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801AB8B0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801AB860[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801AB860; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_801627E8); - - -extern void (*D_80185108[])(void); - -void func_80162834(void *a0) { - D_80185108[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801850F8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801850F8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801AB0C4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801AB0C4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801AB0C4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801AB0C4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80185110[])(void); - -void func_80163A58(void *a0) { - D_80185110[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801AB0CC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801AB0CC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80185164[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80185164[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018512C; -extern s16 D_80185160; -extern s16 D_8018515E; -extern s16 D_8018515C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018512C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80185160 = 0x80; - D_8018515E = 0x80; - D_8018515C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80185160 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80185160` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80185160 - 8; - D_80185160 = nv; - D_8018515E = nv; - D_8018515C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80185170[])(void); - -void func_80164BA0(void *a0) { - D_80185170[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801AB8C0; -extern u8 D_801AB8C1; -extern u8 D_801AB8C2; -extern u8 D_801AB8C3; -extern u8 D_801AB8C4; -extern u8 D_801AB8C5; -extern u8 D_801AB8C6; -extern u8 D_801AB8C7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801AB8C0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801AB8C1 = 0xf0; - *(u8 *)base = 0xf0; - D_801AB8C2 = 0xc0; - D_801AB8C6 = 0; - D_801AB8C5 = 0; - D_801AB8C4 = 0; - D_801AB8C7 = 0; - D_801AB8C3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801AB8C0; -extern u8 D_801AB8C1; -extern u8 D_801AB8C2; - -s32 func_80164E40(void) { - u8 *p = &D_801AB8C0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801AB8C1 != 0) { - D_801AB8C1 -= 0x10; - } - if (D_801AB8C2 != 0) { - D_801AB8C2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80185180[])(void); - -void func_80164EA4(void *a0) { - D_80185180[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801AB90C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801AB90C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801AB900[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801AB900[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801AB900[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801AB900; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801AB900; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80185194[]; - extern u32 D_801851B4, D_801851B8, D_801851BC, D_801851C0; - extern u32 D_801851B4, D_801851B8, D_801851BC, D_801851C0; - extern u32 D_801851B4, D_801851B8, D_801851BC, D_801851C0; - extern u32 D_801851B4, D_801851B8, D_801851BC, D_801851C0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80185194[0x00], p); - ApplyMatrixSV(mat, &D_80185194[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80185194[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80185194[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801851BC; - *(u32 *)(prim + 0x24) = D_801851B4; - *(u32 *)(prim + 0x28) = D_801851C0; - *(u32 *)(prim + 0x2c) = D_801851B8; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801851C4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801851C4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801851C4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801851C4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80185240[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80185240[a1 & 0x7F]; -} - - - -extern s32 D_80185260[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80185260[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801852DC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801852DC[a1 & 0x7F]; -} - - - -extern u8 D_801852FC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801852FC[a1 & 0x7F]; -} - - - -extern u8 D_8018531C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018531C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018533C[])(void); - D_8018533C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801853B8[])(void); - -void func_80165AC8(void) { - D_801853B8[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80185434[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80185434[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801AB0D4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801AB0D4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80185440[])(void); - -void func_80166018(void *a0) { - D_80185440[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80185448[])(void); - -void func_801663FC(void *a0) { - D_80185448[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80185510[])(void); - -void func_80166618(void *a0) { - D_80185510[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80185520[])(void); - -void func_80166654(void *a0) { - D_80185520[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801AB980[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801AB980[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801AB980). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801AB980[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801AB980)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801AB980[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801AB980[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80185464[]; - extern u8 D_80185450[]; - extern u8 D_80185478[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80185464; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80185450; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80185478; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80167714); - - -extern void (*D_80185530[])(void); - -void func_801678B4(void *a0) { - D_80185530[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018553C[])(void); - -void func_80167A9C(void *a0) { - D_8018553C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80185648; - extern u8 D_8018565C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80185648); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018565C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018549C[]; -extern u8 D_801854B0[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018549C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801854B0; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80185554[])(void); - -void func_80168744(void *a0) { - D_80185554[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80185544 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80185544[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80185544; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018555C[])(void); - -void func_801689D8(void *a0) { - D_8018555C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80185564[])(void); - -void func_80168AA8(void *a0) { - D_80185564[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018556C[])(void); - -void func_80168D58(void *a0) { - D_8018556C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80185574[])(void); - -void func_8016901C(void *a0) { - D_80185574[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015AE2C", func_80169228); - - -extern void (*D_8018557C[])(void); - -void func_801693CC(void *a0) { - D_8018557C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80185584[])(void); - -void func_80169830(void *a0) { - D_80185584[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80185638[])(void); - -void func_80169B80(void *a0) { - D_80185638[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018558C[]; - extern u8 D_801855FC[]; - extern u8 D_8018562C[]; - extern u8 D_801AC988[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018562C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018558C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801AC988; - RotMatrixYXZ(rot, D_801AC988); - func_80048D9C(D_801AC988, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801855FC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80185640[])(void); - -void func_80169F00(void *a0) { - D_80185640[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801855F0[]; -extern char D_801855B0[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801855F0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801855B0); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80185678[])(void); - -void func_8016A020(void *a0) { - D_80185678[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80185648; - extern u8 D_8018565C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80185648); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018565C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80185684[])(void); - -void func_8016A700(void *a0) { - D_80185684[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801856CC[])(void); - -void func_8016AB30(void *a0) { - D_801856CC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c b/src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c new file mode 100644 index 000000000..9493f27af --- /dev/null +++ b/src/ov_SC05_003/ov_SC05_003_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80184A98; +extern u8 D_80184A08; +extern u8 D_801849E4; +extern u8 D_801849C0; +extern u8 D_80184A74; +extern u8 D_80184A50; +extern u8 D_80184A2C; +extern u8 D_8018499C; +extern void func_80145934(void); +extern u8 D_80184B28; +extern u8 D_80184B04; +extern u8 D_80184AE0; +extern u8 D_80184ABC; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80183F20[]; +extern unsigned char D_80183F50[]; +extern unsigned char D_80183FA0[]; +extern unsigned char D_80183FD0[]; +extern unsigned char D_80184000[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80184050[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80184118[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801841A0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801841A8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801AB7B0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801AB7B4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801841D8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80184280[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801842A4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80184294; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801842B8[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801842C4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801842D4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801842EC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801842DC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80184300[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018431C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018430C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80184330[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80184344[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80184358; +extern void (*D_80184380[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80184360; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801843CC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801843D0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184834[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184844[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801AB7E8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018486C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018484C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018485C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801848AC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801848B4[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80184880; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801848C0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80184890; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801AB7F0; +extern s32 D_801AB7FC; +extern s32 D_801AB800; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801848FC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801848D0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801AB7F8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184B4C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018496C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80184BF0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80184D44[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80184B60; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80184D4C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80184B70; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80184B90; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80184D54[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80184D7C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80184BFC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80184D88[])(void); + +void func_8015C714(void *a0) { + D_80184D88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80184BFC[])(void*); + extern int D_80184BA0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80184BFC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80184BFC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184BA0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80184BFC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80184BFC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80184BFC[])(void*); + extern int D_80184BA0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80184BFC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184BA0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80184BFC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80184D98[])(void); + D_80184D98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80184BFC[])(struct Ent_8015CD20 *); + extern u8 D_80184BB0; + extern u8 D_80184DA0; + extern u8 D_80184DB0; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80184BFC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184BB0); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184DA0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184DB0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80184BFC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80184DD0[])(void); + D_80184DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80184DC0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80184DC0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80184BFC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80184E2C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80184E2C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80183F10[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80183F10; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80184E34[])(void); + D_80184E34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80184E40[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80184E40[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80184E40[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80184E40[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80184BFC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80184E40[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80184BC0[]; + extern u8 D_80184BD0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184BC0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184BD0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80184E40[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184E40[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184E40[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80184E74[])(void); + D_80184E74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184BFC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184E7C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80184E94[])(void); + D_80184E94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184BFC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184E7C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184E7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80184EB4[])(void); + D_80184EB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80184BFC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184BFC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80184EC4; +extern u16 D_80184EC6; +extern u16 D_80184EC8; +extern s32 D_80184ECC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80184EC4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80184EC6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80184EC8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184ECC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80184ED4; + +void func_8015E588(void) { + func_8013C9C4(&D_80184ED4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80184BFC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184BFC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80184EE8[])(void); + D_80184EE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80184BFC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80184BFC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80184EF0[])(void); + D_80184EF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80184BE0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80184BE0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80184BFC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80184EF8[])(void); + D_80184EF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80184BFC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80184BFC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80184F00[])(void); + D_80184F00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80184BFC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80184F08; + extern s32 D_80184F18; + extern s32 D_80184F28; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184F08); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184F18); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80184BFC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184F28); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184F38[])(void); + D_80184F38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80184BFC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80184BFC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80184BFC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184BFC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184F44[])(void); + D_80184F44[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80184BFC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184BFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80184BFC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184BFC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80184F58[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80184F58[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80184BFC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80184BFC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80184BFC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184BFC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80184FD4[])(void); + D_80184FD4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80184BFC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80184BFC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80184FE4[])(void); + D_80184FE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80184BFC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80184BFC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80184BFC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80184BFC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80184BFC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80184BFC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80184BFC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80184FEC[])(void); + D_80184FEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80184BFC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80184BFC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80184BFC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80184BFC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80184FF8[])(void); + D_80184FF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184BFC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80184BFC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80184BFC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80184BFC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80185008[])(void); + +void func_80160EA4(void *a0) { + D_80185008[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80184BFC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80184BFC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80185038[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80185038[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018509C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018509C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801AB808[]; + extern u8 D_80185068[]; + extern u8 D_80185088[]; + extern u8 D_801AB814[]; + extern u8 D_801AB83C[]; + extern u8 D_801AB854[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801AB808[0] = p; + func_80024054(&D_80185068, &D_801AB814); + func_8001CE28(p, &D_801AB814); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801AB808[1] = p; + func_80024054(&D_80185088, &D_801AB83C); + func_8001CE28(p, &D_801AB83C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801AB808[2] = p; + func_800242D0((s16)func_801620C4(), &D_801AB854, 0x84); + func_8001CE68(p, &D_801AB854); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801AB854, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801AB808[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801AB808; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018509C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018509C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018509C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018509C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801AB808[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801AB808; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801850C0[])(void); + +void func_80162330(void *a0) { + D_801850C0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801AB860[i] via `extern int D_801AB860[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801850CC[]; + extern s32 D_801850E4; + extern u8 D_801AB86C[]; + extern u8 D_801AB894[]; + extern u8 D_801AB8B0[]; + extern int D_801AB860[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801AB860[0] = (s32)item; + func_80024054(D_801850CC, D_801AB86C); + func_8001CE28(item, D_801AB86C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801AB860[1] = (s32)item; + func_80024054(((u8 *)&D_801850E4), D_801AB894); + func_8001CE28(item, D_801AB894); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801AB860[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801AB8B0, 0x84); + func_8001CE68(item, D_801AB8B0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801AB8B0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801AB860[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801AB860; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_801627E8); + + +extern void (*D_80185108[])(void); + +void func_80162834(void *a0) { + D_80185108[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801850F8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801850F8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801AB0C4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801AB0C4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801AB0C4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801AB0C4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80185110[])(void); + +void func_80163A58(void *a0) { + D_80185110[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801AB0CC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801AB0CC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80185164[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80185164[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018512C; +extern s16 D_80185160; +extern s16 D_8018515E; +extern s16 D_8018515C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018512C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80185160 = 0x80; + D_8018515E = 0x80; + D_8018515C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80185160 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80185160` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80185160 - 8; + D_80185160 = nv; + D_8018515E = nv; + D_8018515C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80185170[])(void); + +void func_80164BA0(void *a0) { + D_80185170[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801AB8C0; +extern u8 D_801AB8C1; +extern u8 D_801AB8C2; +extern u8 D_801AB8C3; +extern u8 D_801AB8C4; +extern u8 D_801AB8C5; +extern u8 D_801AB8C6; +extern u8 D_801AB8C7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801AB8C0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801AB8C1 = 0xf0; + *(u8 *)base = 0xf0; + D_801AB8C2 = 0xc0; + D_801AB8C6 = 0; + D_801AB8C5 = 0; + D_801AB8C4 = 0; + D_801AB8C7 = 0; + D_801AB8C3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801AB8C0; +extern u8 D_801AB8C1; +extern u8 D_801AB8C2; + +s32 func_80164E40(void) { + u8 *p = &D_801AB8C0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801AB8C1 != 0) { + D_801AB8C1 -= 0x10; + } + if (D_801AB8C2 != 0) { + D_801AB8C2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80185180[])(void); + +void func_80164EA4(void *a0) { + D_80185180[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801AB90C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801AB90C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801AB900[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801AB900[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801AB900[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801AB900; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801AB900; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80185194[]; + extern u32 D_801851B4, D_801851B8, D_801851BC, D_801851C0; + extern u32 D_801851B4, D_801851B8, D_801851BC, D_801851C0; + extern u32 D_801851B4, D_801851B8, D_801851BC, D_801851C0; + extern u32 D_801851B4, D_801851B8, D_801851BC, D_801851C0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80185194[0x00], p); + ApplyMatrixSV(mat, &D_80185194[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80185194[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80185194[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801851BC; + *(u32 *)(prim + 0x24) = D_801851B4; + *(u32 *)(prim + 0x28) = D_801851C0; + *(u32 *)(prim + 0x2c) = D_801851B8; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801851C4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801851C4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801851C4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801851C4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80185240[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80185240[a1 & 0x7F]; +} + + + +extern s32 D_80185260[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80185260[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801852DC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801852DC[a1 & 0x7F]; +} + + + +extern u8 D_801852FC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801852FC[a1 & 0x7F]; +} + + + +extern u8 D_8018531C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018531C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018533C[])(void); + D_8018533C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801853B8[])(void); + +void func_80165AC8(void) { + D_801853B8[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80185434[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80185434[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801AB0D4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801AB0D4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80185440[])(void); + +void func_80166018(void *a0) { + D_80185440[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80185448[])(void); + +void func_801663FC(void *a0) { + D_80185448[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80185510[])(void); + +void func_80166618(void *a0) { + D_80185510[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80185520[])(void); + +void func_80166654(void *a0) { + D_80185520[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801AB980[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801AB980[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801AB980). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801AB980[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801AB980)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801AB980[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801AB980[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80185464[]; + extern u8 D_80185450[]; + extern u8 D_80185478[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80185464; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80185450; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80185478; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80167714); + + +extern void (*D_80185530[])(void); + +void func_801678B4(void *a0) { + D_80185530[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018553C[])(void); + +void func_80167A9C(void *a0) { + D_8018553C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80185648; + extern u8 D_8018565C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80185648); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018565C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018549C[]; +extern u8 D_801854B0[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018549C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801854B0; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80185554[])(void); + +void func_80168744(void *a0) { + D_80185554[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80185544 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80185544[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80185544; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018555C[])(void); + +void func_801689D8(void *a0) { + D_8018555C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80185564[])(void); + +void func_80168AA8(void *a0) { + D_80185564[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018556C[])(void); + +void func_80168D58(void *a0) { + D_8018556C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80185574[])(void); + +void func_8016901C(void *a0) { + D_80185574[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_003/nonmatchings/ov_SC05_003_jr_8015C32C", func_80169228); + + +extern void (*D_8018557C[])(void); + +void func_801693CC(void *a0) { + D_8018557C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80185584[])(void); + +void func_80169830(void *a0) { + D_80185584[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80185638[])(void); + +void func_80169B80(void *a0) { + D_80185638[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018558C[]; + extern u8 D_801855FC[]; + extern u8 D_8018562C[]; + extern u8 D_801AC988[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018562C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018558C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801AC988; + RotMatrixYXZ(rot, D_801AC988); + func_80048D9C(D_801AC988, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801855FC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80185640[])(void); + +void func_80169F00(void *a0) { + D_80185640[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801855F0[]; +extern char D_801855B0[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801855F0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801855B0); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80185678[])(void); + +void func_8016A020(void *a0) { + D_80185678[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80185648; + extern u8 D_8018565C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80185648); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018565C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80185684[])(void); + +void func_8016A700(void *a0) { + D_80185684[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801856CC[])(void); + +void func_8016AB30(void *a0) { + D_801856CC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_004/ov_SC05_004_jr_8015AE2C.c b/src/ov_SC05_004/ov_SC05_004_jr_8015AE2C.c index 3d535a640..b9152664d 100644 --- a/src/ov_SC05_004/ov_SC05_004_jr_8015AE2C.c +++ b/src/ov_SC05_004/ov_SC05_004_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80183E94[])(void); - -void func_8015C714(void *a0) { - D_80183E94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80183D08[])(void*); - extern int D_80183CAC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80183D08)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80183D08)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183CAC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80183D08[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80183D08[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80183D08[])(void*); - extern int D_80183CAC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80183D08)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183CAC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80183D08)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80183EA4[])(void); - D_80183EA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80183D08[])(struct Ent_8015CD20 *); - extern u8 D_80183CBC; - extern u8 D_80183EAC; - extern u8 D_80183EBC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80183D08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183CBC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183EAC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183EBC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80183D08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80183EDC[])(void); - D_80183EDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80183ECC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80183ECC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80183D08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80183F38; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80183F38, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018301C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018301C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80183F40[])(void); - D_80183F40[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80183F4C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80183F4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80183F4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80183F4C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80183D08[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80183F4C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80183CCC[]; - extern u8 D_80183CDC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183CCC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183CDC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80183F4C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183F4C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183F4C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80183F80[])(void); - D_80183F80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80183D08[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80183F88[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80183FA0[])(void); - D_80183FA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80183D08[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80183F88[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80183FC0[])(void); - D_80183FC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80183D08[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80183D08)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80183FD0; -extern u16 D_80183FD2; -extern u16 D_80183FD4; -extern s32 D_80183FD8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80183FD0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80183FD2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80183FD4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80183FD8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80183FE0; - -void func_8015E588(void) { - func_8013C9C4(&D_80183FE0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80183D08[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80183D08)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80183FF4[])(void); - D_80183FF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80183D08[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80183D08[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80183FFC[])(void); - D_80183FFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80183CEC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80183CEC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80183D08[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80184004[])(void); - D_80184004[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80183D08[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80183D08[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018400C[])(void); - D_8018400C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80183D08[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80184014; - extern s32 D_80184024; - extern s32 D_80184034; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80183D08[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184014); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184024); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80183D08[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184034); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184044[])(void); - D_80184044[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80183D08[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80183D08[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80183D08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80183D08[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184050[])(void); - D_80184050[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80183D08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80183D08[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80183D08[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80183D08[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80184064[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80184064[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80183D08[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80183D08)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80183D08[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80183D08[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801840E0[])(void); - D_801840E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80183D08[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80183D08)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801840F0[])(void); - D_801840F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80183D08[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80183D08[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80183D08[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80183D08[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80183D08[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80183D08[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80183D08[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801840F8[])(void); - D_801840F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80183D08[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80183D08)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80183D08[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80183D08)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80184104[])(void); - D_80184104[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80183D08 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80183D08[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80183D08[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80183D08[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80184114[])(void); - -void func_80160EA4(void *a0) { - D_80184114[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80183D08[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80183D08[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80184144[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80184144[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801841A8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801841A8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019DE80[]; - extern u8 D_80184174[]; - extern u8 D_80184194[]; - extern u8 D_8019DE8C[]; - extern u8 D_8019DEB4[]; - extern u8 D_8019DECC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019DE80[0] = p; - func_80024054(&D_80184174, &D_8019DE8C); - func_8001CE28(p, &D_8019DE8C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019DE80[1] = p; - func_80024054(&D_80184194, &D_8019DEB4); - func_8001CE28(p, &D_8019DEB4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019DE80[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019DECC, 0x84); - func_8001CE68(p, &D_8019DECC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019DECC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019DE80[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019DE80; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801841A8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801841A8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801841A8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801841A8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019DE80[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019DE80; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801841CC[])(void); - -void func_80162330(void *a0) { - D_801841CC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019DED8[i] via `extern int D_8019DED8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801841D8[]; - extern s32 D_801841F0; - extern u8 D_8019DEE4[]; - extern u8 D_8019DF0C[]; - extern u8 D_8019DF28[]; - extern int D_8019DED8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019DED8[0] = (s32)item; - func_80024054(D_801841D8, D_8019DEE4); - func_8001CE28(item, D_8019DEE4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019DED8[1] = (s32)item; - func_80024054(((u8 *)&D_801841F0), D_8019DF0C); - func_8001CE28(item, D_8019DF0C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019DED8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019DF28, 0x84); - func_8001CE68(item, D_8019DF28); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019DF28, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019DED8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019DED8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_801627E8); - - -extern void (*D_80184214[])(void); - -void func_80162834(void *a0) { - D_80184214[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80184204; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80184204, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019D6B8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019D6B8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019D6B8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019D6B8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018421C[])(void); - -void func_80163A58(void *a0) { - D_8018421C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019D6C0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019D6C0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80184270[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80184270[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80184238; -extern s16 D_8018426C; -extern s16 D_8018426A; -extern s16 D_80184268; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80184238; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018426C = 0x80; - D_8018426A = 0x80; - D_80184268 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018426C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018426C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018426C - 8; - D_8018426C = nv; - D_8018426A = nv; - D_80184268 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018427C[])(void); - -void func_80164BA0(void *a0) { - D_8018427C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019DF38; -extern u8 D_8019DF39; -extern u8 D_8019DF3A; -extern u8 D_8019DF3B; -extern u8 D_8019DF3C; -extern u8 D_8019DF3D; -extern u8 D_8019DF3E; -extern u8 D_8019DF3F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019DF38; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019DF39 = 0xf0; - *(u8 *)base = 0xf0; - D_8019DF3A = 0xc0; - D_8019DF3E = 0; - D_8019DF3D = 0; - D_8019DF3C = 0; - D_8019DF3F = 0; - D_8019DF3B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019DF38; -extern u8 D_8019DF39; -extern u8 D_8019DF3A; - -s32 func_80164E40(void) { - u8 *p = &D_8019DF38; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019DF39 != 0) { - D_8019DF39 -= 0x10; - } - if (D_8019DF3A != 0) { - D_8019DF3A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018428C[])(void); - -void func_80164EA4(void *a0) { - D_8018428C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019DF84[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019DF84[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019DF78[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019DF78[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019DF78[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019DF78; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019DF78; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801842A0[]; - extern u32 D_801842C0, D_801842C4, D_801842C8, D_801842CC; - extern u32 D_801842C0, D_801842C4, D_801842C8, D_801842CC; - extern u32 D_801842C0, D_801842C4, D_801842C8, D_801842CC; - extern u32 D_801842C0, D_801842C4, D_801842C8, D_801842CC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801842A0[0x00], p); - ApplyMatrixSV(mat, &D_801842A0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801842A0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801842A0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801842C8; - *(u32 *)(prim + 0x24) = D_801842C0; - *(u32 *)(prim + 0x28) = D_801842CC; - *(u32 *)(prim + 0x2c) = D_801842C4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801842D0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801842D0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801842D0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801842D0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018434C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018434C[a1 & 0x7F]; -} - - - -extern s32 D_8018436C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018436C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801843E8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801843E8[a1 & 0x7F]; -} - - - -extern u8 D_80184408[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80184408[a1 & 0x7F]; -} - - - -extern u8 D_80184428[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80184428[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80184448[])(void); - D_80184448[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801844C4[])(void); - -void func_80165AC8(void) { - D_801844C4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80184540[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80184540[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019D6C8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019D6C8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018454C[])(void); - -void func_80166018(void *a0) { - D_8018454C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80184554[])(void); - -void func_801663FC(void *a0) { - D_80184554[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018461C[])(void); - -void func_80166618(void *a0) { - D_8018461C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018462C[])(void); - -void func_80166654(void *a0) { - D_8018462C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019DFF8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019DFF8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019DFF8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019DFF8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019DFF8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019DFF8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019DFF8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80184570[]; - extern u8 D_8018455C[]; - extern u8 D_80184584[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80184570; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018455C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80184584; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80167714); - - -extern void (*D_8018463C[])(void); - -void func_801678B4(void *a0) { - D_8018463C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80184648[])(void); - -void func_80167A9C(void *a0) { - D_80184648[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80184754; - extern u8 D_80184768[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80184754); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184768; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801845A8[]; -extern u8 D_801845BC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801845A8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801845BC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80184660[])(void); - -void func_80168744(void *a0) { - D_80184660[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80184650 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80184650[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80184650; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80184668[])(void); - -void func_801689D8(void *a0) { - D_80184668[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80184670[])(void); - -void func_80168AA8(void *a0) { - D_80184670[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80184678[])(void); - -void func_80168D58(void *a0) { - D_80184678[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80184680[])(void); - -void func_8016901C(void *a0) { - D_80184680[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015AE2C", func_80169228); - - -extern void (*D_80184688[])(void); - -void func_801693CC(void *a0) { - D_80184688[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80184690[])(void); - -void func_80169830(void *a0) { - D_80184690[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80184744[])(void); - -void func_80169B80(void *a0) { - D_80184744[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80184698[]; - extern u8 D_80184708[]; - extern u8 D_80184738[]; - extern u8 D_8019F1E0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80184738, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80184698[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019F1E0; - RotMatrixYXZ(rot, D_8019F1E0); - func_80048D9C(D_8019F1E0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80184708); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018474C[])(void); - -void func_80169F00(void *a0) { - D_8018474C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801846FC[]; -extern char D_801846BC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801846FC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801846BC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80184784[])(void); - -void func_8016A020(void *a0) { - D_80184784[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80184754; - extern u8 D_80184768[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80184754); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184768; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80184790[])(void); - -void func_8016A700(void *a0) { - D_80184790[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801847D8[])(void); - -void func_8016AB30(void *a0) { - D_801847D8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c b/src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c new file mode 100644 index 000000000..d622a8686 --- /dev/null +++ b/src/ov_SC05_004/ov_SC05_004_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80183BA4; +extern u8 D_80183B14; +extern u8 D_80183AF0; +extern u8 D_80183ACC; +extern u8 D_80183B80; +extern u8 D_80183B5C; +extern u8 D_80183B38; +extern u8 D_80183AA8; +extern void func_80145934(void); +extern u8 D_80183C34; +extern u8 D_80183C10; +extern u8 D_80183BEC; +extern u8 D_80183BC8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018302C[]; +extern unsigned char D_8018305C[]; +extern unsigned char D_801830AC[]; +extern unsigned char D_801830DC[]; +extern unsigned char D_8018310C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018315C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80183224[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801832AC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801832B4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019DE28; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019DE2C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801832E4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018338C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801833B0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801833A0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801833C4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801833D0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801833E0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801833F8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801833E8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018340C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80183428[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80183418; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018343C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80183450[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80183464; +extern void (*D_8018348C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018346C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801834D8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801834DC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80183940[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80183950[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019DE60; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80183978[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80183958; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80183968; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801839B8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801839C0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018398C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801839CC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018399C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019DE68; +extern s32 D_8019DE74; +extern s32 D_8019DE78; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80183A08[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801839DC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019DE70; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80183C58[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80183A78[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80183CFC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80183E50[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80183C6C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80183E58[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80183C7C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80183C9C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80183E60[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80183E88[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80183D08[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80183E94[])(void); + +void func_8015C714(void *a0) { + D_80183E94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80183D08[])(void*); + extern int D_80183CAC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80183D08)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80183D08)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183CAC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80183D08[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80183D08[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80183D08[])(void*); + extern int D_80183CAC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80183D08)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80183CAC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80183D08)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80183EA4[])(void); + D_80183EA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80183D08[])(struct Ent_8015CD20 *); + extern u8 D_80183CBC; + extern u8 D_80183EAC; + extern u8 D_80183EBC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80183D08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183CBC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183EAC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80183EBC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80183D08[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80183EDC[])(void); + D_80183EDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80183ECC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80183ECC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80183D08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80183F38; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80183F38, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018301C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018301C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80183F40[])(void); + D_80183F40[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80183F4C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80183F4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80183F4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80183F4C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80183D08[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80183F4C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80183CCC[]; + extern u8 D_80183CDC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183CCC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80183CDC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80183F4C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80183F4C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80183F4C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80183F80[])(void); + D_80183F80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80183D08[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80183F88[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80183FA0[])(void); + D_80183FA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80183D08[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80183F88[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80183F88[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80183FC0[])(void); + D_80183FC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80183D08[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80183D08)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80183FD0; +extern u16 D_80183FD2; +extern u16 D_80183FD4; +extern s32 D_80183FD8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80183FD0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80183FD2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80183FD4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80183FD8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80183FE0; + +void func_8015E588(void) { + func_8013C9C4(&D_80183FE0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80183D08[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80183D08)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80183FF4[])(void); + D_80183FF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80183D08[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80183D08[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80183FFC[])(void); + D_80183FFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80183CEC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80183CEC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80183D08[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80184004[])(void); + D_80184004[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80183D08[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80183D08[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018400C[])(void); + D_8018400C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80183D08[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80184014; + extern s32 D_80184024; + extern s32 D_80184034; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184014); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184024); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80183D08[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184034); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184044[])(void); + D_80184044[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80183D08[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80183D08[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80183D08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80183D08[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184050[])(void); + D_80184050[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80183D08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80183D08[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80183D08[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80183D08[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80184064[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80184064[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80183D08[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80183D08)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80183D08[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80183D08[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801840E0[])(void); + D_801840E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80183D08[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80183D08)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801840F0[])(void); + D_801840F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80183D08[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80183D08[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80183D08[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80183D08[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80183D08[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80183D08[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80183D08[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801840F8[])(void); + D_801840F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80183D08[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80183D08)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80183D08[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80183D08)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80184104[])(void); + D_80184104[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80183D08 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80183D08[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80183D08[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80183D08[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80184114[])(void); + +void func_80160EA4(void *a0) { + D_80184114[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80183D08[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80183D08[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80184144[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80184144[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801841A8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801841A8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019DE80[]; + extern u8 D_80184174[]; + extern u8 D_80184194[]; + extern u8 D_8019DE8C[]; + extern u8 D_8019DEB4[]; + extern u8 D_8019DECC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019DE80[0] = p; + func_80024054(&D_80184174, &D_8019DE8C); + func_8001CE28(p, &D_8019DE8C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019DE80[1] = p; + func_80024054(&D_80184194, &D_8019DEB4); + func_8001CE28(p, &D_8019DEB4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019DE80[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019DECC, 0x84); + func_8001CE68(p, &D_8019DECC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019DECC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019DE80[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019DE80; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801841A8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801841A8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801841A8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801841A8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019DE80[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019DE80; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801841CC[])(void); + +void func_80162330(void *a0) { + D_801841CC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019DED8[i] via `extern int D_8019DED8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801841D8[]; + extern s32 D_801841F0; + extern u8 D_8019DEE4[]; + extern u8 D_8019DF0C[]; + extern u8 D_8019DF28[]; + extern int D_8019DED8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019DED8[0] = (s32)item; + func_80024054(D_801841D8, D_8019DEE4); + func_8001CE28(item, D_8019DEE4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019DED8[1] = (s32)item; + func_80024054(((u8 *)&D_801841F0), D_8019DF0C); + func_8001CE28(item, D_8019DF0C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019DED8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019DF28, 0x84); + func_8001CE68(item, D_8019DF28); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019DF28, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019DED8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019DED8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_801627E8); + + +extern void (*D_80184214[])(void); + +void func_80162834(void *a0) { + D_80184214[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80184204; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80184204, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019D6B8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019D6B8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019D6B8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019D6B8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018421C[])(void); + +void func_80163A58(void *a0) { + D_8018421C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019D6C0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019D6C0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80184270[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80184270[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80184238; +extern s16 D_8018426C; +extern s16 D_8018426A; +extern s16 D_80184268; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80184238; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018426C = 0x80; + D_8018426A = 0x80; + D_80184268 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018426C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018426C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018426C - 8; + D_8018426C = nv; + D_8018426A = nv; + D_80184268 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018427C[])(void); + +void func_80164BA0(void *a0) { + D_8018427C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019DF38; +extern u8 D_8019DF39; +extern u8 D_8019DF3A; +extern u8 D_8019DF3B; +extern u8 D_8019DF3C; +extern u8 D_8019DF3D; +extern u8 D_8019DF3E; +extern u8 D_8019DF3F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019DF38; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019DF39 = 0xf0; + *(u8 *)base = 0xf0; + D_8019DF3A = 0xc0; + D_8019DF3E = 0; + D_8019DF3D = 0; + D_8019DF3C = 0; + D_8019DF3F = 0; + D_8019DF3B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019DF38; +extern u8 D_8019DF39; +extern u8 D_8019DF3A; + +s32 func_80164E40(void) { + u8 *p = &D_8019DF38; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019DF39 != 0) { + D_8019DF39 -= 0x10; + } + if (D_8019DF3A != 0) { + D_8019DF3A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018428C[])(void); + +void func_80164EA4(void *a0) { + D_8018428C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019DF84[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019DF84[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019DF78[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019DF78[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019DF78[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019DF78; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019DF78; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801842A0[]; + extern u32 D_801842C0, D_801842C4, D_801842C8, D_801842CC; + extern u32 D_801842C0, D_801842C4, D_801842C8, D_801842CC; + extern u32 D_801842C0, D_801842C4, D_801842C8, D_801842CC; + extern u32 D_801842C0, D_801842C4, D_801842C8, D_801842CC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801842A0[0x00], p); + ApplyMatrixSV(mat, &D_801842A0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801842A0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801842A0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801842C8; + *(u32 *)(prim + 0x24) = D_801842C0; + *(u32 *)(prim + 0x28) = D_801842CC; + *(u32 *)(prim + 0x2c) = D_801842C4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801842D0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801842D0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801842D0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801842D0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018434C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018434C[a1 & 0x7F]; +} + + + +extern s32 D_8018436C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018436C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801843E8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801843E8[a1 & 0x7F]; +} + + + +extern u8 D_80184408[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80184408[a1 & 0x7F]; +} + + + +extern u8 D_80184428[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80184428[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80184448[])(void); + D_80184448[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801844C4[])(void); + +void func_80165AC8(void) { + D_801844C4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80184540[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80184540[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019D6C8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019D6C8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018454C[])(void); + +void func_80166018(void *a0) { + D_8018454C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80184554[])(void); + +void func_801663FC(void *a0) { + D_80184554[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018461C[])(void); + +void func_80166618(void *a0) { + D_8018461C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018462C[])(void); + +void func_80166654(void *a0) { + D_8018462C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019DFF8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019DFF8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019DFF8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019DFF8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019DFF8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019DFF8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019DFF8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80184570[]; + extern u8 D_8018455C[]; + extern u8 D_80184584[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80184570; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018455C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80184584; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80167714); + + +extern void (*D_8018463C[])(void); + +void func_801678B4(void *a0) { + D_8018463C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80184648[])(void); + +void func_80167A9C(void *a0) { + D_80184648[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80184754; + extern u8 D_80184768[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80184754); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184768; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801845A8[]; +extern u8 D_801845BC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801845A8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801845BC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80184660[])(void); + +void func_80168744(void *a0) { + D_80184660[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80184650 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80184650[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80184650; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80184668[])(void); + +void func_801689D8(void *a0) { + D_80184668[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80184670[])(void); + +void func_80168AA8(void *a0) { + D_80184670[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80184678[])(void); + +void func_80168D58(void *a0) { + D_80184678[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80184680[])(void); + +void func_8016901C(void *a0) { + D_80184680[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_004/nonmatchings/ov_SC05_004_jr_8015C32C", func_80169228); + + +extern void (*D_80184688[])(void); + +void func_801693CC(void *a0) { + D_80184688[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80184690[])(void); + +void func_80169830(void *a0) { + D_80184690[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80184744[])(void); + +void func_80169B80(void *a0) { + D_80184744[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80184698[]; + extern u8 D_80184708[]; + extern u8 D_80184738[]; + extern u8 D_8019F1E0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80184738, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80184698[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019F1E0; + RotMatrixYXZ(rot, D_8019F1E0); + func_80048D9C(D_8019F1E0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80184708); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018474C[])(void); + +void func_80169F00(void *a0) { + D_8018474C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801846FC[]; +extern char D_801846BC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801846FC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801846BC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80184784[])(void); + +void func_8016A020(void *a0) { + D_80184784[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80184754; + extern u8 D_80184768[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80184754); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184768; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80184790[])(void); + +void func_8016A700(void *a0) { + D_80184790[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801847D8[])(void); + +void func_8016AB30(void *a0) { + D_801847D8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_005/ov_SC05_005_jr_8015AE2C.c b/src/ov_SC05_005/ov_SC05_005_jr_8015AE2C.c index 5d1308d66..414d64dfc 100644 --- a/src/ov_SC05_005/ov_SC05_005_jr_8015AE2C.c +++ b/src/ov_SC05_005/ov_SC05_005_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80184C68[])(void); - -void func_8015C714(void *a0) { - D_80184C68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80184ADC[])(void*); - extern int D_80184A80; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80184ADC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80184ADC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184A80); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80184ADC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80184ADC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80184ADC[])(void*); - extern int D_80184A80; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80184ADC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184A80); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80184ADC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80184C78[])(void); - D_80184C78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80184ADC[])(struct Ent_8015CD20 *); - extern u8 D_80184A90; - extern u8 D_80184C80; - extern u8 D_80184C90; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80184ADC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184A90); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184C80); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184C90); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80184ADC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80184CB0[])(void); - D_80184CB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80184CA0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80184CA0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80184ADC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80184D0C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80184D0C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80183DF0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80183DF0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80184D14[])(void); - D_80184D14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80184D20[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80184D20[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80184D20[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80184D20[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80184ADC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80184D20[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80184AA0[]; - extern u8 D_80184AB0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184AA0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184AB0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80184D20[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184D20[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184D20[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80184D54[])(void); - D_80184D54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184ADC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184D5C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80184D74[])(void); - D_80184D74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184ADC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80184D5C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80184D94[])(void); - D_80184D94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80184ADC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184ADC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80184DA4; -extern u16 D_80184DA6; -extern u16 D_80184DA8; -extern s32 D_80184DAC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80184DA4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80184DA6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80184DA8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184DAC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80184DB4; - -void func_8015E588(void) { - func_8013C9C4(&D_80184DB4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80184ADC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184ADC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80184DC8[])(void); - D_80184DC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80184ADC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80184ADC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80184DD0[])(void); - D_80184DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80184AC0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80184AC0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80184ADC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80184DD8[])(void); - D_80184DD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80184ADC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80184ADC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80184DE0[])(void); - D_80184DE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80184ADC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80184DE8; - extern s32 D_80184DF8; - extern s32 D_80184E08; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80184ADC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184DE8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184DF8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80184ADC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184E08); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184E18[])(void); - D_80184E18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80184ADC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80184ADC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80184ADC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184ADC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184E24[])(void); - D_80184E24[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80184ADC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184ADC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80184ADC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184ADC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80184E38[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80184E38[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80184ADC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80184ADC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80184ADC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184ADC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80184EB4[])(void); - D_80184EB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80184ADC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80184ADC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80184EC4[])(void); - D_80184EC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80184ADC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80184ADC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80184ADC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80184ADC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80184ADC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80184ADC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80184ADC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80184ECC[])(void); - D_80184ECC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80184ADC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80184ADC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80184ADC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80184ADC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80184ED8[])(void); - D_80184ED8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184ADC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80184ADC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80184ADC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80184ADC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80184EE8[])(void); - -void func_80160EA4(void *a0) { - D_80184EE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80184ADC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80184ADC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80184F18[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80184F18[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80184F7C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80184F7C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B0AE8[]; - extern u8 D_80184F48[]; - extern u8 D_80184F68[]; - extern u8 D_801B0AF4[]; - extern u8 D_801B0B1C[]; - extern u8 D_801B0B34[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B0AE8[0] = p; - func_80024054(&D_80184F48, &D_801B0AF4); - func_8001CE28(p, &D_801B0AF4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B0AE8[1] = p; - func_80024054(&D_80184F68, &D_801B0B1C); - func_8001CE28(p, &D_801B0B1C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B0AE8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B0B34, 0x84); - func_8001CE68(p, &D_801B0B34); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B0B34, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B0AE8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B0AE8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80184F7C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80184F7C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80184F7C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80184F7C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B0AE8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B0AE8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80184FA0[])(void); - -void func_80162330(void *a0) { - D_80184FA0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B0B40[i] via `extern int D_801B0B40[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80184FAC[]; - extern s32 D_80184FC4; - extern u8 D_801B0B4C[]; - extern u8 D_801B0B74[]; - extern u8 D_801B0B90[]; - extern int D_801B0B40[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B0B40[0] = (s32)item; - func_80024054(D_80184FAC, D_801B0B4C); - func_8001CE28(item, D_801B0B4C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B0B40[1] = (s32)item; - func_80024054(((u8 *)&D_80184FC4), D_801B0B74); - func_8001CE28(item, D_801B0B74); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B0B40[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B0B90, 0x84); - func_8001CE68(item, D_801B0B90); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B0B90, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B0B40[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B0B40; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_801627E8); - - -extern void (*D_80184FE8[])(void); - -void func_80162834(void *a0) { - D_80184FE8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80184FD8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80184FD8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B03A0[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B03A0, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B03A0[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B03A0, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80184FF0[])(void); - -void func_80163A58(void *a0) { - D_80184FF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B03A8; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B03A8; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80185044[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80185044[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018500C; -extern s16 D_80185040; -extern s16 D_8018503E; -extern s16 D_8018503C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018500C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80185040 = 0x80; - D_8018503E = 0x80; - D_8018503C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80185040 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80185040` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80185040 - 8; - D_80185040 = nv; - D_8018503E = nv; - D_8018503C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80185050[])(void); - -void func_80164BA0(void *a0) { - D_80185050[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B0BA0; -extern u8 D_801B0BA1; -extern u8 D_801B0BA2; -extern u8 D_801B0BA3; -extern u8 D_801B0BA4; -extern u8 D_801B0BA5; -extern u8 D_801B0BA6; -extern u8 D_801B0BA7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B0BA0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B0BA1 = 0xf0; - *(u8 *)base = 0xf0; - D_801B0BA2 = 0xc0; - D_801B0BA6 = 0; - D_801B0BA5 = 0; - D_801B0BA4 = 0; - D_801B0BA7 = 0; - D_801B0BA3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B0BA0; -extern u8 D_801B0BA1; -extern u8 D_801B0BA2; - -s32 func_80164E40(void) { - u8 *p = &D_801B0BA0; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B0BA1 != 0) { - D_801B0BA1 -= 0x10; - } - if (D_801B0BA2 != 0) { - D_801B0BA2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80185060[])(void); - -void func_80164EA4(void *a0) { - D_80185060[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B0BEC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B0BEC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B0BE0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B0BE0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B0BE0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B0BE0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B0BE0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80185074[]; - extern u32 D_80185094, D_80185098, D_8018509C, D_801850A0; - extern u32 D_80185094, D_80185098, D_8018509C, D_801850A0; - extern u32 D_80185094, D_80185098, D_8018509C, D_801850A0; - extern u32 D_80185094, D_80185098, D_8018509C, D_801850A0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80185074[0x00], p); - ApplyMatrixSV(mat, &D_80185074[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80185074[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80185074[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018509C; - *(u32 *)(prim + 0x24) = D_80185094; - *(u32 *)(prim + 0x28) = D_801850A0; - *(u32 *)(prim + 0x2c) = D_80185098; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801850A4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801850A4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801850A4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801850A4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80185120[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80185120[a1 & 0x7F]; -} - - - -extern s32 D_80185140[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80185140[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801851BC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801851BC[a1 & 0x7F]; -} - - - -extern u8 D_801851DC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801851DC[a1 & 0x7F]; -} - - - -extern u8 D_801851FC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801851FC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018521C[])(void); - D_8018521C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80185298[])(void); - -void func_80165AC8(void) { - D_80185298[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80185314[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80185314[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B03B0; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B03B0, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80185320[])(void); - -void func_80166018(void *a0) { - D_80185320[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80185328[])(void); - -void func_801663FC(void *a0) { - D_80185328[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801853F0[])(void); - -void func_80166618(void *a0) { - D_801853F0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80185400[])(void); - -void func_80166654(void *a0) { - D_80185400[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B0C60[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B0C60[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B0C60). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B0C60[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B0C60)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B0C60[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B0C60[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80185344[]; - extern u8 D_80185330[]; - extern u8 D_80185358[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80185344; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80185330; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80185358; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80167714); - - -extern void (*D_80185410[])(void); - -void func_801678B4(void *a0) { - D_80185410[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018541C[])(void); - -void func_80167A9C(void *a0) { - D_8018541C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80185528; - extern u8 D_8018553C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80185528); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018553C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018537C[]; -extern u8 D_80185390[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018537C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80185390; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80185434[])(void); - -void func_80168744(void *a0) { - D_80185434[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80185424 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80185424[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80185424; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018543C[])(void); - -void func_801689D8(void *a0) { - D_8018543C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80185444[])(void); - -void func_80168AA8(void *a0) { - D_80185444[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018544C[])(void); - -void func_80168D58(void *a0) { - D_8018544C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80185454[])(void); - -void func_8016901C(void *a0) { - D_80185454[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015AE2C", func_80169228); - - -extern void (*D_8018545C[])(void); - -void func_801693CC(void *a0) { - D_8018545C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80185464[])(void); - -void func_80169830(void *a0) { - D_80185464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80185518[])(void); - -void func_80169B80(void *a0) { - D_80185518[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018546C[]; - extern u8 D_801854DC[]; - extern u8 D_8018550C[]; - extern u8 D_801B1EE8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018550C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018546C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B1EE8; - RotMatrixYXZ(rot, D_801B1EE8); - func_80048D9C(D_801B1EE8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801854DC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80185520[])(void); - -void func_80169F00(void *a0) { - D_80185520[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801854D0[]; -extern char D_80185490[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801854D0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80185490); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80185558[])(void); - -void func_8016A020(void *a0) { - D_80185558[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80185528; - extern u8 D_8018553C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80185528); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018553C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80185564[])(void); - -void func_8016A700(void *a0) { - D_80185564[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801855AC[])(void); - -void func_8016AB30(void *a0) { - D_801855AC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c b/src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c new file mode 100644 index 000000000..2d509a4d4 --- /dev/null +++ b/src/ov_SC05_005/ov_SC05_005_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80184978; +extern u8 D_801848E8; +extern u8 D_801848C4; +extern u8 D_801848A0; +extern u8 D_80184954; +extern u8 D_80184930; +extern u8 D_8018490C; +extern u8 D_8018487C; +extern void func_80145934(void); +extern u8 D_80184A08; +extern u8 D_801849E4; +extern u8 D_801849C0; +extern u8 D_8018499C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80183E00[]; +extern unsigned char D_80183E30[]; +extern unsigned char D_80183E80[]; +extern unsigned char D_80183EB0[]; +extern unsigned char D_80183EE0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80183F30[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80183FF8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80184080[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80184088; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B0A90; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B0A94; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801840B8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80184160[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80184184[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80184174; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80184198[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801841A4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801841B4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801841CC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801841BC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801841E0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801841FC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801841EC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80184210[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80184224[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80184238; +extern void (*D_80184260[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80184240; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801842AC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801842B0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184714[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184724[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B0AC8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018474C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018472C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018473C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018478C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80184794[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80184760; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801847A0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80184770; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B0AD0; +extern s32 D_801B0ADC; +extern s32 D_801B0AE0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801847DC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801847B0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B0AD8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184A2C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018484C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80184AD0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80184C24[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80184A40; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80184C2C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80184A50; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80184A70; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80184C34[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80184C5C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80184ADC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80184C68[])(void); + +void func_8015C714(void *a0) { + D_80184C68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80184ADC[])(void*); + extern int D_80184A80; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80184ADC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80184ADC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184A80); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80184ADC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80184ADC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80184ADC[])(void*); + extern int D_80184A80; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80184ADC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184A80); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80184ADC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80184C78[])(void); + D_80184C78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80184ADC[])(struct Ent_8015CD20 *); + extern u8 D_80184A90; + extern u8 D_80184C80; + extern u8 D_80184C90; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80184ADC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184A90); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184C80); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80184C90); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80184ADC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80184CB0[])(void); + D_80184CB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80184CA0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80184CA0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80184ADC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80184D0C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80184D0C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80183DF0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80183DF0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80184D14[])(void); + D_80184D14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80184D20[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80184D20[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80184D20[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80184D20[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80184ADC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80184D20[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80184AA0[]; + extern u8 D_80184AB0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184AA0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80184AB0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80184D20[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80184D20[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80184D20[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80184D54[])(void); + D_80184D54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184ADC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184D5C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80184D74[])(void); + D_80184D74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184ADC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80184D5C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80184D5C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80184D94[])(void); + D_80184D94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80184ADC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184ADC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80184DA4; +extern u16 D_80184DA6; +extern u16 D_80184DA8; +extern s32 D_80184DAC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80184DA4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80184DA6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80184DA8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184DAC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80184DB4; + +void func_8015E588(void) { + func_8013C9C4(&D_80184DB4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80184ADC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184ADC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80184DC8[])(void); + D_80184DC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80184ADC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80184ADC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80184DD0[])(void); + D_80184DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80184AC0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80184AC0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80184ADC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80184DD8[])(void); + D_80184DD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80184ADC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80184ADC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80184DE0[])(void); + D_80184DE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80184ADC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80184DE8; + extern s32 D_80184DF8; + extern s32 D_80184E08; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184DE8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184DF8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80184ADC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184E08); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184E18[])(void); + D_80184E18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80184ADC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80184ADC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80184ADC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184ADC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184E24[])(void); + D_80184E24[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80184ADC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184ADC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80184ADC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184ADC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80184E38[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80184E38[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80184ADC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80184ADC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80184ADC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184ADC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80184EB4[])(void); + D_80184EB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80184ADC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80184ADC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80184EC4[])(void); + D_80184EC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80184ADC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80184ADC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80184ADC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80184ADC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80184ADC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80184ADC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80184ADC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80184ECC[])(void); + D_80184ECC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80184ADC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80184ADC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80184ADC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80184ADC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80184ED8[])(void); + D_80184ED8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184ADC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80184ADC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80184ADC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80184ADC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80184EE8[])(void); + +void func_80160EA4(void *a0) { + D_80184EE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80184ADC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80184ADC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80184F18[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80184F18[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80184F7C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80184F7C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B0AE8[]; + extern u8 D_80184F48[]; + extern u8 D_80184F68[]; + extern u8 D_801B0AF4[]; + extern u8 D_801B0B1C[]; + extern u8 D_801B0B34[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B0AE8[0] = p; + func_80024054(&D_80184F48, &D_801B0AF4); + func_8001CE28(p, &D_801B0AF4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B0AE8[1] = p; + func_80024054(&D_80184F68, &D_801B0B1C); + func_8001CE28(p, &D_801B0B1C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B0AE8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B0B34, 0x84); + func_8001CE68(p, &D_801B0B34); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B0B34, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B0AE8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B0AE8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80184F7C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80184F7C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80184F7C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80184F7C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B0AE8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B0AE8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80184FA0[])(void); + +void func_80162330(void *a0) { + D_80184FA0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B0B40[i] via `extern int D_801B0B40[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80184FAC[]; + extern s32 D_80184FC4; + extern u8 D_801B0B4C[]; + extern u8 D_801B0B74[]; + extern u8 D_801B0B90[]; + extern int D_801B0B40[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B0B40[0] = (s32)item; + func_80024054(D_80184FAC, D_801B0B4C); + func_8001CE28(item, D_801B0B4C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B0B40[1] = (s32)item; + func_80024054(((u8 *)&D_80184FC4), D_801B0B74); + func_8001CE28(item, D_801B0B74); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B0B40[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B0B90, 0x84); + func_8001CE68(item, D_801B0B90); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B0B90, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B0B40[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B0B40; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_801627E8); + + +extern void (*D_80184FE8[])(void); + +void func_80162834(void *a0) { + D_80184FE8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80184FD8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80184FD8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B03A0[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B03A0, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B03A0[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B03A0, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80184FF0[])(void); + +void func_80163A58(void *a0) { + D_80184FF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B03A8; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B03A8; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80185044[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80185044[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018500C; +extern s16 D_80185040; +extern s16 D_8018503E; +extern s16 D_8018503C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018500C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80185040 = 0x80; + D_8018503E = 0x80; + D_8018503C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80185040 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80185040` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80185040 - 8; + D_80185040 = nv; + D_8018503E = nv; + D_8018503C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80185050[])(void); + +void func_80164BA0(void *a0) { + D_80185050[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B0BA0; +extern u8 D_801B0BA1; +extern u8 D_801B0BA2; +extern u8 D_801B0BA3; +extern u8 D_801B0BA4; +extern u8 D_801B0BA5; +extern u8 D_801B0BA6; +extern u8 D_801B0BA7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B0BA0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B0BA1 = 0xf0; + *(u8 *)base = 0xf0; + D_801B0BA2 = 0xc0; + D_801B0BA6 = 0; + D_801B0BA5 = 0; + D_801B0BA4 = 0; + D_801B0BA7 = 0; + D_801B0BA3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B0BA0; +extern u8 D_801B0BA1; +extern u8 D_801B0BA2; + +s32 func_80164E40(void) { + u8 *p = &D_801B0BA0; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B0BA1 != 0) { + D_801B0BA1 -= 0x10; + } + if (D_801B0BA2 != 0) { + D_801B0BA2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80185060[])(void); + +void func_80164EA4(void *a0) { + D_80185060[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B0BEC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B0BEC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B0BE0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B0BE0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B0BE0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B0BE0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B0BE0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80185074[]; + extern u32 D_80185094, D_80185098, D_8018509C, D_801850A0; + extern u32 D_80185094, D_80185098, D_8018509C, D_801850A0; + extern u32 D_80185094, D_80185098, D_8018509C, D_801850A0; + extern u32 D_80185094, D_80185098, D_8018509C, D_801850A0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80185074[0x00], p); + ApplyMatrixSV(mat, &D_80185074[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80185074[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80185074[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018509C; + *(u32 *)(prim + 0x24) = D_80185094; + *(u32 *)(prim + 0x28) = D_801850A0; + *(u32 *)(prim + 0x2c) = D_80185098; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801850A4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801850A4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801850A4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801850A4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80185120[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80185120[a1 & 0x7F]; +} + + + +extern s32 D_80185140[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80185140[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801851BC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801851BC[a1 & 0x7F]; +} + + + +extern u8 D_801851DC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801851DC[a1 & 0x7F]; +} + + + +extern u8 D_801851FC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801851FC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018521C[])(void); + D_8018521C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80185298[])(void); + +void func_80165AC8(void) { + D_80185298[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80185314[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80185314[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B03B0; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B03B0, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80185320[])(void); + +void func_80166018(void *a0) { + D_80185320[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80185328[])(void); + +void func_801663FC(void *a0) { + D_80185328[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801853F0[])(void); + +void func_80166618(void *a0) { + D_801853F0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80185400[])(void); + +void func_80166654(void *a0) { + D_80185400[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B0C60[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B0C60[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B0C60). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B0C60[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B0C60)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B0C60[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B0C60[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80185344[]; + extern u8 D_80185330[]; + extern u8 D_80185358[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80185344; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80185330; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80185358; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80167714); + + +extern void (*D_80185410[])(void); + +void func_801678B4(void *a0) { + D_80185410[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018541C[])(void); + +void func_80167A9C(void *a0) { + D_8018541C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80185528; + extern u8 D_8018553C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80185528); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018553C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018537C[]; +extern u8 D_80185390[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018537C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80185390; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80185434[])(void); + +void func_80168744(void *a0) { + D_80185434[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80185424 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80185424[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80185424; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018543C[])(void); + +void func_801689D8(void *a0) { + D_8018543C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80185444[])(void); + +void func_80168AA8(void *a0) { + D_80185444[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018544C[])(void); + +void func_80168D58(void *a0) { + D_8018544C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80185454[])(void); + +void func_8016901C(void *a0) { + D_80185454[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_005/nonmatchings/ov_SC05_005_jr_8015C32C", func_80169228); + + +extern void (*D_8018545C[])(void); + +void func_801693CC(void *a0) { + D_8018545C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80185464[])(void); + +void func_80169830(void *a0) { + D_80185464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80185518[])(void); + +void func_80169B80(void *a0) { + D_80185518[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018546C[]; + extern u8 D_801854DC[]; + extern u8 D_8018550C[]; + extern u8 D_801B1EE8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018550C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018546C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B1EE8; + RotMatrixYXZ(rot, D_801B1EE8); + func_80048D9C(D_801B1EE8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801854DC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80185520[])(void); + +void func_80169F00(void *a0) { + D_80185520[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801854D0[]; +extern char D_80185490[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801854D0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80185490); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80185558[])(void); + +void func_8016A020(void *a0) { + D_80185558[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80185528; + extern u8 D_8018553C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80185528); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018553C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80185564[])(void); + +void func_8016A700(void *a0) { + D_80185564[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801855AC[])(void); + +void func_8016AB30(void *a0) { + D_801855AC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_006/ov_SC05_006_jr_8015AE2C.c b/src/ov_SC05_006/ov_SC05_006_jr_8015AE2C.c index 7dcf1aa3f..6f36d3a1b 100644 --- a/src/ov_SC05_006/ov_SC05_006_jr_8015AE2C.c +++ b/src/ov_SC05_006/ov_SC05_006_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181C88[])(void); - -void func_8015C714(void *a0) { - D_80181C88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181AFC[])(void*); - extern int D_80181AA0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181AFC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181AFC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181AA0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181AFC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181AFC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181AFC[])(void*); - extern int D_80181AA0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181AFC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181AA0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181AFC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181C98[])(void); - D_80181C98[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181AFC[])(struct Ent_8015CD20 *); - extern u8 D_80181AB0; - extern u8 D_80181CA0; - extern u8 D_80181CB0; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181AFC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AB0); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181CA0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181CB0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181AFC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181CD0[])(void); - D_80181CD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181CC0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181CC0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181AFC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181D2C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181D2C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180E10[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180E10; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80181D34[])(void); - D_80181D34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80181D40[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80181D40[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80181D40[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80181D40[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181AFC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80181D40[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80181AC0[]; - extern u8 D_80181AD0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181AC0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181AD0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80181D40[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181D40[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181D40[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80181D74[])(void); - D_80181D74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181AFC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181D7C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181D94[])(void); - D_80181D94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181AFC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181D7C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181DB4[])(void); - D_80181DB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181AFC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181AFC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181DC4; -extern u16 D_80181DC6; -extern u16 D_80181DC8; -extern s32 D_80181DCC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181DC4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80181DC6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181DC8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181DCC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181DD4; - -void func_8015E588(void) { - func_8013C9C4(&D_80181DD4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181AFC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181AFC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181DE8[])(void); - D_80181DE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181AFC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181AFC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181DF0[])(void); - D_80181DF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80181AE0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181AE0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181AFC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181DF8[])(void); - D_80181DF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181AFC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181AFC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181E00[])(void); - D_80181E00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181AFC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181E08; - extern s32 D_80181E18; - extern s32 D_80181E28; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181AFC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181E08); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181E18); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181AFC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181E28); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80181E38[])(void); - D_80181E38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181AFC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181AFC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181AFC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181AFC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80181E44[])(void); - D_80181E44[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181AFC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181AFC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181AFC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181AFC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80181E58[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80181E58[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181AFC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181AFC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181AFC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181AFC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181ED4[])(void); - D_80181ED4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181AFC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181AFC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181EE4[])(void); - D_80181EE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181AFC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181AFC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181AFC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181AFC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181AFC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181AFC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181AFC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181EEC[])(void); - D_80181EEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181AFC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181AFC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181AFC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181AFC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181EF8[])(void); - D_80181EF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181AFC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181AFC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181AFC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181AFC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181F08[])(void); - -void func_80160EA4(void *a0) { - D_80181F08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181AFC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181AFC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80181F38[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80181F38[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181F9C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181F9C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8018EC20[]; - extern u8 D_80181F68[]; - extern u8 D_80181F88[]; - extern u8 D_8018EC2C[]; - extern u8 D_8018EC54[]; - extern u8 D_8018EC6C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8018EC20[0] = p; - func_80024054(&D_80181F68, &D_8018EC2C); - func_8001CE28(p, &D_8018EC2C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8018EC20[1] = p; - func_80024054(&D_80181F88, &D_8018EC54); - func_8001CE28(p, &D_8018EC54); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8018EC20[2] = p; - func_800242D0((s16)func_801620C4(), &D_8018EC6C, 0x84); - func_8001CE68(p, &D_8018EC6C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8018EC6C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018EC20[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8018EC20; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181F9C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181F9C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181F9C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181F9C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8018EC20[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8018EC20; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181FC0[])(void); - -void func_80162330(void *a0) { - D_80181FC0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8018EC78[i] via `extern int D_8018EC78[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181FCC[]; - extern s32 D_80181FE4; - extern u8 D_8018EC84[]; - extern u8 D_8018ECAC[]; - extern u8 D_8018ECC8[]; - extern int D_8018EC78[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8018EC78[0] = (s32)item; - func_80024054(D_80181FCC, D_8018EC84); - func_8001CE28(item, D_8018EC84); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8018EC78[1] = (s32)item; - func_80024054(((u8 *)&D_80181FE4), D_8018ECAC); - func_8001CE28(item, D_8018ECAC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8018EC78[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8018ECC8, 0x84); - func_8001CE68(item, D_8018ECC8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8018ECC8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018EC78[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8018EC78; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_801627E8); - - -extern void (*D_80182008[])(void); - -void func_80162834(void *a0) { - D_80182008[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181FF8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181FF8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8018E4F0[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8018E4F0, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8018E4F0[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8018E4F0, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80182010[])(void); - -void func_80163A58(void *a0) { - D_80182010[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8018E4F8; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8018E4F8; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80182064[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80182064[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018202C; -extern s16 D_80182060; -extern s16 D_8018205E; -extern s16 D_8018205C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018202C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80182060 = 0x80; - D_8018205E = 0x80; - D_8018205C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80182060 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182060` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80182060 - 8; - D_80182060 = nv; - D_8018205E = nv; - D_8018205C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80182070[])(void); - -void func_80164BA0(void *a0) { - D_80182070[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8018ECD8; -extern u8 D_8018ECD9; -extern u8 D_8018ECDA; -extern u8 D_8018ECDB; -extern u8 D_8018ECDC; -extern u8 D_8018ECDD; -extern u8 D_8018ECDE; -extern u8 D_8018ECDF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8018ECD8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8018ECD9 = 0xf0; - *(u8 *)base = 0xf0; - D_8018ECDA = 0xc0; - D_8018ECDE = 0; - D_8018ECDD = 0; - D_8018ECDC = 0; - D_8018ECDF = 0; - D_8018ECDB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8018ECD8; -extern u8 D_8018ECD9; -extern u8 D_8018ECDA; - -s32 func_80164E40(void) { - u8 *p = &D_8018ECD8; - if (*p != 0) { - *p -= 0x10; - } - if (D_8018ECD9 != 0) { - D_8018ECD9 -= 0x10; - } - if (D_8018ECDA != 0) { - D_8018ECDA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80182080[])(void); - -void func_80164EA4(void *a0) { - D_80182080[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8018ED24[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8018ED24[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8018ED18[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8018ED18[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8018ED18[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8018ED18; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8018ED18; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80182094[]; - extern u32 D_801820B4, D_801820B8, D_801820BC, D_801820C0; - extern u32 D_801820B4, D_801820B8, D_801820BC, D_801820C0; - extern u32 D_801820B4, D_801820B8, D_801820BC, D_801820C0; - extern u32 D_801820B4, D_801820B8, D_801820BC, D_801820C0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80182094[0x00], p); - ApplyMatrixSV(mat, &D_80182094[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80182094[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80182094[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801820BC; - *(u32 *)(prim + 0x24) = D_801820B4; - *(u32 *)(prim + 0x28) = D_801820C0; - *(u32 *)(prim + 0x2c) = D_801820B8; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801820C4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801820C4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801820C4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801820C4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80182140[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80182140[a1 & 0x7F]; -} - - - -extern s32 D_80182160[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80182160[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801821DC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801821DC[a1 & 0x7F]; -} - - - -extern u8 D_801821FC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801821FC[a1 & 0x7F]; -} - - - -extern u8 D_8018221C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018221C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018223C[])(void); - D_8018223C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801822B8[])(void); - -void func_80165AC8(void) { - D_801822B8[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80182334[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80182334[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8018E500; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8018E500, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80182340[])(void); - -void func_80166018(void *a0) { - D_80182340[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80182348[])(void); - -void func_801663FC(void *a0) { - D_80182348[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182410[])(void); - -void func_80166618(void *a0) { - D_80182410[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182420[])(void); - -void func_80166654(void *a0) { - D_80182420[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8018ED98[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8018ED98[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018ED98). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8018ED98[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8018ED98)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8018ED98[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8018ED98[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80182364[]; - extern u8 D_80182350[]; - extern u8 D_80182378[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80182364; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80182350; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182378; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80167714); - - -extern void (*D_80182430[])(void); - -void func_801678B4(void *a0) { - D_80182430[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018243C[])(void); - -void func_80167A9C(void *a0) { - D_8018243C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80182548; - extern u8 D_8018255C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80182548); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018255C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018239C[]; -extern u8 D_801823B0[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018239C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801823B0; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80182454[])(void); - -void func_80168744(void *a0) { - D_80182454[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80182444 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80182444[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80182444; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018245C[])(void); - -void func_801689D8(void *a0) { - D_8018245C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80182464[])(void); - -void func_80168AA8(void *a0) { - D_80182464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018246C[])(void); - -void func_80168D58(void *a0) { - D_8018246C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80182474[])(void); - -void func_8016901C(void *a0) { - D_80182474[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015AE2C", func_80169228); - - -extern void (*D_8018247C[])(void); - -void func_801693CC(void *a0) { - D_8018247C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80182484[])(void); - -void func_80169830(void *a0) { - D_80182484[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80182538[])(void); - -void func_80169B80(void *a0) { - D_80182538[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018248C[]; - extern u8 D_801824FC[]; - extern u8 D_8018252C[]; - extern u8 D_80190018[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018252C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018248C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80190018; - RotMatrixYXZ(rot, D_80190018); - func_80048D9C(D_80190018, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801824FC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80182540[])(void); - -void func_80169F00(void *a0) { - D_80182540[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801824F0[]; -extern char D_801824B0[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801824F0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801824B0); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80182578[])(void); - -void func_8016A020(void *a0) { - D_80182578[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80182548; - extern u8 D_8018255C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80182548); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018255C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80182584[])(void); - -void func_8016A700(void *a0) { - D_80182584[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801825CC[])(void); - -void func_8016AB30(void *a0) { - D_801825CC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c b/src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c new file mode 100644 index 000000000..8d10d580d --- /dev/null +++ b/src/ov_SC05_006/ov_SC05_006_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80181998; +extern u8 D_80181908; +extern u8 D_801818E4; +extern u8 D_801818C0; +extern u8 D_80181974; +extern u8 D_80181950; +extern u8 D_8018192C; +extern u8 D_8018189C; +extern void func_80145934(void); +extern u8 D_80181A28; +extern u8 D_80181A04; +extern u8 D_801819E0; +extern u8 D_801819BC; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180E20[]; +extern unsigned char D_80180E50[]; +extern unsigned char D_80180EA0[]; +extern unsigned char D_80180ED0[]; +extern unsigned char D_80180F00[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80180F50[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80181018[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801810A0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801810A8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8018EBC8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8018EBCC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801810D8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80181180[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801811A4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80181194; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801811B8[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801811C4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801811D4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801811EC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801811DC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181200[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018121C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018120C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181230[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80181244[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80181258; +extern void (*D_80181280[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80181260; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801812CC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801812D0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80181734[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80181744[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8018EC00; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018176C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018174C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018175C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801817AC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801817B4[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80181780; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801817C0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80181790; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8018EC08; +extern s32 D_8018EC14; +extern s32 D_8018EC18; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801817FC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801817D0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8018EC10; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80181A4C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018186C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181AF0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80181C44[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80181A60; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80181C4C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80181A70; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80181A90; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80181C54[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80181C7C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181AFC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181C88[])(void); + +void func_8015C714(void *a0) { + D_80181C88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181AFC[])(void*); + extern int D_80181AA0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181AFC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181AFC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181AA0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181AFC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181AFC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181AFC[])(void*); + extern int D_80181AA0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181AFC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181AA0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181AFC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181C98[])(void); + D_80181C98[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181AFC[])(struct Ent_8015CD20 *); + extern u8 D_80181AB0; + extern u8 D_80181CA0; + extern u8 D_80181CB0; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181AFC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AB0); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181CA0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181CB0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181AFC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181CD0[])(void); + D_80181CD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181CC0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181CC0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181AFC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181D2C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181D2C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180E10[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180E10; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80181D34[])(void); + D_80181D34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80181D40[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80181D40[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80181D40[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80181D40[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181AFC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80181D40[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80181AC0[]; + extern u8 D_80181AD0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181AC0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181AD0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80181D40[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181D40[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181D40[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80181D74[])(void); + D_80181D74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181AFC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181D7C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181D94[])(void); + D_80181D94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181AFC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181D7C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181D7C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181DB4[])(void); + D_80181DB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181AFC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181AFC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181DC4; +extern u16 D_80181DC6; +extern u16 D_80181DC8; +extern s32 D_80181DCC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181DC4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80181DC6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181DC8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181DCC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181DD4; + +void func_8015E588(void) { + func_8013C9C4(&D_80181DD4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181AFC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181AFC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181DE8[])(void); + D_80181DE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181AFC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181AFC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181DF0[])(void); + D_80181DF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80181AE0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181AE0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181AFC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181DF8[])(void); + D_80181DF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181AFC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181AFC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181E00[])(void); + D_80181E00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181AFC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181E08; + extern s32 D_80181E18; + extern s32 D_80181E28; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181E08); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181E18); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181AFC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181E28); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80181E38[])(void); + D_80181E38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181AFC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181AFC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181AFC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181AFC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80181E44[])(void); + D_80181E44[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181AFC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181AFC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181AFC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181AFC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80181E58[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80181E58[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181AFC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181AFC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181AFC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181AFC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181ED4[])(void); + D_80181ED4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181AFC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181AFC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181EE4[])(void); + D_80181EE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181AFC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181AFC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181AFC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181AFC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181AFC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181AFC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181AFC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181EEC[])(void); + D_80181EEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181AFC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181AFC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181AFC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181AFC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181EF8[])(void); + D_80181EF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181AFC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181AFC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181AFC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181AFC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181F08[])(void); + +void func_80160EA4(void *a0) { + D_80181F08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181AFC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181AFC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80181F38[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80181F38[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181F9C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181F9C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8018EC20[]; + extern u8 D_80181F68[]; + extern u8 D_80181F88[]; + extern u8 D_8018EC2C[]; + extern u8 D_8018EC54[]; + extern u8 D_8018EC6C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8018EC20[0] = p; + func_80024054(&D_80181F68, &D_8018EC2C); + func_8001CE28(p, &D_8018EC2C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8018EC20[1] = p; + func_80024054(&D_80181F88, &D_8018EC54); + func_8001CE28(p, &D_8018EC54); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8018EC20[2] = p; + func_800242D0((s16)func_801620C4(), &D_8018EC6C, 0x84); + func_8001CE68(p, &D_8018EC6C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8018EC6C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018EC20[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8018EC20; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181F9C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181F9C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181F9C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181F9C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8018EC20[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8018EC20; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181FC0[])(void); + +void func_80162330(void *a0) { + D_80181FC0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8018EC78[i] via `extern int D_8018EC78[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181FCC[]; + extern s32 D_80181FE4; + extern u8 D_8018EC84[]; + extern u8 D_8018ECAC[]; + extern u8 D_8018ECC8[]; + extern int D_8018EC78[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8018EC78[0] = (s32)item; + func_80024054(D_80181FCC, D_8018EC84); + func_8001CE28(item, D_8018EC84); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8018EC78[1] = (s32)item; + func_80024054(((u8 *)&D_80181FE4), D_8018ECAC); + func_8001CE28(item, D_8018ECAC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8018EC78[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8018ECC8, 0x84); + func_8001CE68(item, D_8018ECC8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8018ECC8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018EC78[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8018EC78; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_801627E8); + + +extern void (*D_80182008[])(void); + +void func_80162834(void *a0) { + D_80182008[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181FF8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181FF8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8018E4F0[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8018E4F0, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8018E4F0[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8018E4F0, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80182010[])(void); + +void func_80163A58(void *a0) { + D_80182010[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8018E4F8; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8018E4F8; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80182064[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80182064[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018202C; +extern s16 D_80182060; +extern s16 D_8018205E; +extern s16 D_8018205C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018202C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80182060 = 0x80; + D_8018205E = 0x80; + D_8018205C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80182060 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182060` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80182060 - 8; + D_80182060 = nv; + D_8018205E = nv; + D_8018205C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80182070[])(void); + +void func_80164BA0(void *a0) { + D_80182070[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8018ECD8; +extern u8 D_8018ECD9; +extern u8 D_8018ECDA; +extern u8 D_8018ECDB; +extern u8 D_8018ECDC; +extern u8 D_8018ECDD; +extern u8 D_8018ECDE; +extern u8 D_8018ECDF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8018ECD8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8018ECD9 = 0xf0; + *(u8 *)base = 0xf0; + D_8018ECDA = 0xc0; + D_8018ECDE = 0; + D_8018ECDD = 0; + D_8018ECDC = 0; + D_8018ECDF = 0; + D_8018ECDB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8018ECD8; +extern u8 D_8018ECD9; +extern u8 D_8018ECDA; + +s32 func_80164E40(void) { + u8 *p = &D_8018ECD8; + if (*p != 0) { + *p -= 0x10; + } + if (D_8018ECD9 != 0) { + D_8018ECD9 -= 0x10; + } + if (D_8018ECDA != 0) { + D_8018ECDA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80182080[])(void); + +void func_80164EA4(void *a0) { + D_80182080[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8018ED24[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8018ED24[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8018ED18[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8018ED18[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8018ED18[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8018ED18; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8018ED18; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80182094[]; + extern u32 D_801820B4, D_801820B8, D_801820BC, D_801820C0; + extern u32 D_801820B4, D_801820B8, D_801820BC, D_801820C0; + extern u32 D_801820B4, D_801820B8, D_801820BC, D_801820C0; + extern u32 D_801820B4, D_801820B8, D_801820BC, D_801820C0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80182094[0x00], p); + ApplyMatrixSV(mat, &D_80182094[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80182094[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80182094[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801820BC; + *(u32 *)(prim + 0x24) = D_801820B4; + *(u32 *)(prim + 0x28) = D_801820C0; + *(u32 *)(prim + 0x2c) = D_801820B8; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801820C4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801820C4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801820C4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801820C4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80182140[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80182140[a1 & 0x7F]; +} + + + +extern s32 D_80182160[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80182160[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801821DC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801821DC[a1 & 0x7F]; +} + + + +extern u8 D_801821FC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801821FC[a1 & 0x7F]; +} + + + +extern u8 D_8018221C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018221C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018223C[])(void); + D_8018223C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801822B8[])(void); + +void func_80165AC8(void) { + D_801822B8[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80182334[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80182334[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8018E500; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8018E500, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80182340[])(void); + +void func_80166018(void *a0) { + D_80182340[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80182348[])(void); + +void func_801663FC(void *a0) { + D_80182348[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182410[])(void); + +void func_80166618(void *a0) { + D_80182410[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182420[])(void); + +void func_80166654(void *a0) { + D_80182420[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8018ED98[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8018ED98[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018ED98). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8018ED98[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8018ED98)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8018ED98[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8018ED98[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80182364[]; + extern u8 D_80182350[]; + extern u8 D_80182378[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80182364; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80182350; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182378; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80167714); + + +extern void (*D_80182430[])(void); + +void func_801678B4(void *a0) { + D_80182430[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018243C[])(void); + +void func_80167A9C(void *a0) { + D_8018243C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80182548; + extern u8 D_8018255C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80182548); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018255C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018239C[]; +extern u8 D_801823B0[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018239C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801823B0; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80182454[])(void); + +void func_80168744(void *a0) { + D_80182454[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80182444 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80182444[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80182444; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018245C[])(void); + +void func_801689D8(void *a0) { + D_8018245C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80182464[])(void); + +void func_80168AA8(void *a0) { + D_80182464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018246C[])(void); + +void func_80168D58(void *a0) { + D_8018246C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80182474[])(void); + +void func_8016901C(void *a0) { + D_80182474[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_006/nonmatchings/ov_SC05_006_jr_8015C32C", func_80169228); + + +extern void (*D_8018247C[])(void); + +void func_801693CC(void *a0) { + D_8018247C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80182484[])(void); + +void func_80169830(void *a0) { + D_80182484[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80182538[])(void); + +void func_80169B80(void *a0) { + D_80182538[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018248C[]; + extern u8 D_801824FC[]; + extern u8 D_8018252C[]; + extern u8 D_80190018[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018252C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018248C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80190018; + RotMatrixYXZ(rot, D_80190018); + func_80048D9C(D_80190018, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801824FC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80182540[])(void); + +void func_80169F00(void *a0) { + D_80182540[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801824F0[]; +extern char D_801824B0[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801824F0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801824B0); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80182578[])(void); + +void func_8016A020(void *a0) { + D_80182578[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80182548; + extern u8 D_8018255C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80182548); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018255C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80182584[])(void); + +void func_8016A700(void *a0) { + D_80182584[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801825CC[])(void); + +void func_8016AB30(void *a0) { + D_801825CC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_007/ov_SC05_007_jr_8015AE2C.c b/src/ov_SC05_007/ov_SC05_007_jr_8015AE2C.c index 20fc5e739..42daa3cfa 100644 --- a/src/ov_SC05_007/ov_SC05_007_jr_8015AE2C.c +++ b/src/ov_SC05_007/ov_SC05_007_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80183284[])(void); - -void func_8015C714(void *a0) { - D_80183284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801830F8[])(void*); - extern int D_8018309C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801830F8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801830F8)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018309C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801830F8[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801830F8[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801830F8[])(void*); - extern int D_8018309C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801830F8)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018309C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801830F8)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80183294[])(void); - D_80183294[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801830F8[])(struct Ent_8015CD20 *); - extern u8 D_801830AC; - extern u8 D_8018329C; - extern u8 D_801832AC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801830F8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801830AC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018329C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801832AC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801830F8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801832CC[])(void); - D_801832CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801832BC; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801832BC | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801830F8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80183328; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80183328, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018240C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018240C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80183330[])(void); - D_80183330[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018333C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018333C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018333C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018333C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801830F8[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018333C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801830BC[]; - extern u8 D_801830CC[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801830BC); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801830CC); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018333C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018333C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018333C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80183370[])(void); - D_80183370[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801830F8[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80183378[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80183390[])(void); - D_80183390[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801830F8[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80183378[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801833B0[])(void); - D_801833B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801830F8[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801830F8)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801833C0; -extern u16 D_801833C2; -extern u16 D_801833C4; -extern s32 D_801833C8; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801833C0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801833C2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801833C4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801833C8, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801833D0; - -void func_8015E588(void) { - func_8013C9C4(&D_801833D0); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801830F8[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801830F8)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801833E4[])(void); - D_801833E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801830F8[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801830F8[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801833EC[])(void); - D_801833EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801830DC; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801830DC); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801830F8[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801833F4[])(void); - D_801833F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801830F8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801830F8[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801833FC[])(void); - D_801833FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801830F8[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80183404; - extern s32 D_80183414; - extern s32 D_80183424; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801830F8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183404); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183414); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801830F8[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183424); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80183434[])(void); - D_80183434[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801830F8[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801830F8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801830F8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801830F8[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80183440[])(void); - D_80183440[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801830F8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801830F8[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801830F8[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801830F8[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80183454[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80183454[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801830F8[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801830F8)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801830F8[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801830F8[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801834D0[])(void); - D_801834D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801830F8[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801830F8)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801834E0[])(void); - D_801834E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801830F8[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801830F8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801830F8[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801830F8[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801830F8[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801830F8[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801830F8[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801834E8[])(void); - D_801834E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801830F8[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801830F8)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801830F8[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801830F8)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801834F4[])(void); - D_801834F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801830F8 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801830F8[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801830F8[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801830F8[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80183504[])(void); - -void func_80160EA4(void *a0) { - D_80183504[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801830F8[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801830F8[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80183534[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80183534[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80183598; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80183598); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019BC00[]; - extern u8 D_80183564[]; - extern u8 D_80183584[]; - extern u8 D_8019BC0C[]; - extern u8 D_8019BC34[]; - extern u8 D_8019BC4C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019BC00[0] = p; - func_80024054(&D_80183564, &D_8019BC0C); - func_8001CE28(p, &D_8019BC0C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019BC00[1] = p; - func_80024054(&D_80183584, &D_8019BC34); - func_8001CE28(p, &D_8019BC34); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019BC00[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019BC4C, 0x84); - func_8001CE68(p, &D_8019BC4C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019BC4C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019BC00[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019BC00; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80183598; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80183598; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80183598; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80183598; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019BC00[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019BC00; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801835BC[])(void); - -void func_80162330(void *a0) { - D_801835BC[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019BC58[i] via `extern int D_8019BC58[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801835C8[]; - extern s32 D_801835E0; - extern u8 D_8019BC64[]; - extern u8 D_8019BC8C[]; - extern u8 D_8019BCA8[]; - extern int D_8019BC58[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019BC58[0] = (s32)item; - func_80024054(D_801835C8, D_8019BC64); - func_8001CE28(item, D_8019BC64); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019BC58[1] = (s32)item; - func_80024054(((u8 *)&D_801835E0), D_8019BC8C); - func_8001CE28(item, D_8019BC8C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019BC58[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019BCA8, 0x84); - func_8001CE68(item, D_8019BCA8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019BCA8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019BC58[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019BC58; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_801627E8); - - -extern void (*D_80183604[])(void); - -void func_80162834(void *a0) { - D_80183604[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801835F4; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801835F4, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019B4C8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019B4C8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019B4C8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019B4C8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018360C[])(void); - -void func_80163A58(void *a0) { - D_8018360C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019B4D0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019B4D0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80183660[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80183660[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80183628; -extern s16 D_8018365C; -extern s16 D_8018365A; -extern s16 D_80183658; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80183628; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018365C = 0x80; - D_8018365A = 0x80; - D_80183658 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018365C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018365C` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018365C - 8; - D_8018365C = nv; - D_8018365A = nv; - D_80183658 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018366C[])(void); - -void func_80164BA0(void *a0) { - D_8018366C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019BCB8; -extern u8 D_8019BCB9; -extern u8 D_8019BCBA; -extern u8 D_8019BCBB; -extern u8 D_8019BCBC; -extern u8 D_8019BCBD; -extern u8 D_8019BCBE; -extern u8 D_8019BCBF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019BCB8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019BCB9 = 0xf0; - *(u8 *)base = 0xf0; - D_8019BCBA = 0xc0; - D_8019BCBE = 0; - D_8019BCBD = 0; - D_8019BCBC = 0; - D_8019BCBF = 0; - D_8019BCBB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019BCB8; -extern u8 D_8019BCB9; -extern u8 D_8019BCBA; - -s32 func_80164E40(void) { - u8 *p = &D_8019BCB8; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019BCB9 != 0) { - D_8019BCB9 -= 0x10; - } - if (D_8019BCBA != 0) { - D_8019BCBA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018367C[])(void); - -void func_80164EA4(void *a0) { - D_8018367C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019BD04[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019BD04[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019BCF8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019BCF8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019BCF8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019BCF8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019BCF8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80183690[]; - extern u32 D_801836B0, D_801836B4, D_801836B8, D_801836BC; - extern u32 D_801836B0, D_801836B4, D_801836B8, D_801836BC; - extern u32 D_801836B0, D_801836B4, D_801836B8, D_801836BC; - extern u32 D_801836B0, D_801836B4, D_801836B8, D_801836BC; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80183690[0x00], p); - ApplyMatrixSV(mat, &D_80183690[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80183690[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80183690[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801836B8; - *(u32 *)(prim + 0x24) = D_801836B0; - *(u32 *)(prim + 0x28) = D_801836BC; - *(u32 *)(prim + 0x2c) = D_801836B4; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801836C0[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801836C0[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801836C0[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801836C0[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018373C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018373C[a1 & 0x7F]; -} - - - -extern s32 D_8018375C[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018375C[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801837D8[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801837D8[a1 & 0x7F]; -} - - - -extern u8 D_801837F8[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801837F8[a1 & 0x7F]; -} - - - -extern u8 D_80183818[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80183818[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80183838[])(void); - D_80183838[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801838B4[])(void); - -void func_80165AC8(void) { - D_801838B4[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80183930[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80183930[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019B4D8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019B4D8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018393C[])(void); - -void func_80166018(void *a0) { - D_8018393C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80183944[])(void); - -void func_801663FC(void *a0) { - D_80183944[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80183A0C[])(void); - -void func_80166618(void *a0) { - D_80183A0C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80183A1C[])(void); - -void func_80166654(void *a0) { - D_80183A1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019BD78[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019BD78[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019BD78). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019BD78[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019BD78)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019BD78[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019BD78[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80183960[]; - extern u8 D_8018394C[]; - extern u8 D_80183974[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80183960; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018394C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80183974; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80167714); - - -extern void (*D_80183A2C[])(void); - -void func_801678B4(void *a0) { - D_80183A2C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80183A38[])(void); - -void func_80167A9C(void *a0) { - D_80183A38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80183B44; - extern u8 D_80183B58[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80183B44); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80183B58; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80183998[]; -extern u8 D_801839AC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80183998; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801839AC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80183A50[])(void); - -void func_80168744(void *a0) { - D_80183A50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80183A40 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80183A40[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80183A40; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80183A58[])(void); - -void func_801689D8(void *a0) { - D_80183A58[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80183A60[])(void); - -void func_80168AA8(void *a0) { - D_80183A60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80183A68[])(void); - -void func_80168D58(void *a0) { - D_80183A68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80183A70[])(void); - -void func_8016901C(void *a0) { - D_80183A70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015AE2C", func_80169228); - - -extern void (*D_80183A78[])(void); - -void func_801693CC(void *a0) { - D_80183A78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80183A80[])(void); - -void func_80169830(void *a0) { - D_80183A80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80183B34[])(void); - -void func_80169B80(void *a0) { - D_80183B34[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80183A88[]; - extern u8 D_80183AF8[]; - extern u8 D_80183B28[]; - extern u8 D_8019CDB8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80183B28, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80183A88[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019CDB8; - RotMatrixYXZ(rot, D_8019CDB8); - func_80048D9C(D_8019CDB8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80183AF8); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80183B3C[])(void); - -void func_80169F00(void *a0) { - D_80183B3C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80183AEC[]; -extern char D_80183AAC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80183AEC, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183AAC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80183B74[])(void); - -void func_8016A020(void *a0) { - D_80183B74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80183B44; - extern u8 D_80183B58[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80183B44); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80183B58; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80183B80[])(void); - -void func_8016A700(void *a0) { - D_80183B80[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80183BC8[])(void); - -void func_8016AB30(void *a0) { - D_80183BC8[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c b/src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c new file mode 100644 index 000000000..1d524ab03 --- /dev/null +++ b/src/ov_SC05_007/ov_SC05_007_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80182F94; +extern u8 D_80182F04; +extern u8 D_80182EE0; +extern u8 D_80182EBC; +extern u8 D_80182F70; +extern u8 D_80182F4C; +extern u8 D_80182F28; +extern u8 D_80182E98; +extern void func_80145934(void); +extern u8 D_80183024; +extern u8 D_80183000; +extern u8 D_80182FDC; +extern u8 D_80182FB8; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018241C[]; +extern unsigned char D_8018244C[]; +extern unsigned char D_8018249C[]; +extern unsigned char D_801824CC[]; +extern unsigned char D_801824FC[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018254C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80182614[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018269C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801826A4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019BBA8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019BBAC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801826D4; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018277C[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801827A0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80182790; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801827B4[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801827C0[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801827D0[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801827E8[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801827D8; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801827FC[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80182818[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80182808; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018282C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80182840[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80182854; +extern void (*D_8018287C[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018285C; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801828C8[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801828CC[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80182D30[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80182D40[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019BBE0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80182D68[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80182D48; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80182D58; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80182DA8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80182DB0[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80182D7C; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80182DBC[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80182D8C; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019BBE8; +extern s32 D_8019BBF4; +extern s32 D_8019BBF8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80182DF8[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80182DCC[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019BBF0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80183048[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80182E68[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801830EC[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80183240[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018305C; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80183248[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018306C; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018308C; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80183250[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80183278[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801830F8[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80183284[])(void); + +void func_8015C714(void *a0) { + D_80183284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801830F8[])(void*); + extern int D_8018309C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801830F8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801830F8)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018309C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801830F8[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801830F8[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801830F8[])(void*); + extern int D_8018309C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801830F8)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018309C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801830F8)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80183294[])(void); + D_80183294[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801830F8[])(struct Ent_8015CD20 *); + extern u8 D_801830AC; + extern u8 D_8018329C; + extern u8 D_801832AC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801830F8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801830AC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018329C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801832AC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801830F8[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801832CC[])(void); + D_801832CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801832BC; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801832BC | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801830F8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80183328; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80183328, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018240C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018240C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80183330[])(void); + D_80183330[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018333C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018333C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018333C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018333C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801830F8[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018333C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801830BC[]; + extern u8 D_801830CC[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801830BC); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801830CC); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018333C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018333C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018333C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80183370[])(void); + D_80183370[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801830F8[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80183378[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80183390[])(void); + D_80183390[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801830F8[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80183378[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80183378[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801833B0[])(void); + D_801833B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801830F8[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801830F8)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801833C0; +extern u16 D_801833C2; +extern u16 D_801833C4; +extern s32 D_801833C8; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801833C0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801833C2 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801833C4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801833C8, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801833D0; + +void func_8015E588(void) { + func_8013C9C4(&D_801833D0); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801830F8[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801830F8)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801833E4[])(void); + D_801833E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801830F8[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801830F8[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801833EC[])(void); + D_801833EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801830DC; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801830DC); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801830F8[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801833F4[])(void); + D_801833F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801830F8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801830F8[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801833FC[])(void); + D_801833FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801830F8[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80183404; + extern s32 D_80183414; + extern s32 D_80183424; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183404); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183414); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801830F8[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80183424); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80183434[])(void); + D_80183434[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801830F8[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801830F8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801830F8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801830F8[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80183440[])(void); + D_80183440[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801830F8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801830F8[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801830F8[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801830F8[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80183454[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80183454[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801830F8[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801830F8)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801830F8[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801830F8[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801834D0[])(void); + D_801834D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801830F8[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801830F8)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801834E0[])(void); + D_801834E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801830F8[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801830F8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801830F8[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801830F8[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801830F8[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801830F8[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801830F8[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801834E8[])(void); + D_801834E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801830F8[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801830F8)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801830F8[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801830F8)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801834F4[])(void); + D_801834F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801830F8 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801830F8[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801830F8[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801830F8[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80183504[])(void); + +void func_80160EA4(void *a0) { + D_80183504[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801830F8[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801830F8[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80183534[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80183534[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80183598; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80183598); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019BC00[]; + extern u8 D_80183564[]; + extern u8 D_80183584[]; + extern u8 D_8019BC0C[]; + extern u8 D_8019BC34[]; + extern u8 D_8019BC4C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019BC00[0] = p; + func_80024054(&D_80183564, &D_8019BC0C); + func_8001CE28(p, &D_8019BC0C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019BC00[1] = p; + func_80024054(&D_80183584, &D_8019BC34); + func_8001CE28(p, &D_8019BC34); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019BC00[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019BC4C, 0x84); + func_8001CE68(p, &D_8019BC4C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019BC4C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019BC00[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019BC00; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80183598; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80183598; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80183598; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80183598; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019BC00[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019BC00; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801835BC[])(void); + +void func_80162330(void *a0) { + D_801835BC[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019BC58[i] via `extern int D_8019BC58[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801835C8[]; + extern s32 D_801835E0; + extern u8 D_8019BC64[]; + extern u8 D_8019BC8C[]; + extern u8 D_8019BCA8[]; + extern int D_8019BC58[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019BC58[0] = (s32)item; + func_80024054(D_801835C8, D_8019BC64); + func_8001CE28(item, D_8019BC64); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019BC58[1] = (s32)item; + func_80024054(((u8 *)&D_801835E0), D_8019BC8C); + func_8001CE28(item, D_8019BC8C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019BC58[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019BCA8, 0x84); + func_8001CE68(item, D_8019BCA8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019BCA8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019BC58[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019BC58; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_801627E8); + + +extern void (*D_80183604[])(void); + +void func_80162834(void *a0) { + D_80183604[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801835F4; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801835F4, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019B4C8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019B4C8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019B4C8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019B4C8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018360C[])(void); + +void func_80163A58(void *a0) { + D_8018360C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019B4D0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019B4D0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80183660[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80183660[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80183628; +extern s16 D_8018365C; +extern s16 D_8018365A; +extern s16 D_80183658; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80183628; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018365C = 0x80; + D_8018365A = 0x80; + D_80183658 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018365C read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018365C` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018365C - 8; + D_8018365C = nv; + D_8018365A = nv; + D_80183658 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018366C[])(void); + +void func_80164BA0(void *a0) { + D_8018366C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019BCB8; +extern u8 D_8019BCB9; +extern u8 D_8019BCBA; +extern u8 D_8019BCBB; +extern u8 D_8019BCBC; +extern u8 D_8019BCBD; +extern u8 D_8019BCBE; +extern u8 D_8019BCBF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019BCB8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019BCB9 = 0xf0; + *(u8 *)base = 0xf0; + D_8019BCBA = 0xc0; + D_8019BCBE = 0; + D_8019BCBD = 0; + D_8019BCBC = 0; + D_8019BCBF = 0; + D_8019BCBB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019BCB8; +extern u8 D_8019BCB9; +extern u8 D_8019BCBA; + +s32 func_80164E40(void) { + u8 *p = &D_8019BCB8; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019BCB9 != 0) { + D_8019BCB9 -= 0x10; + } + if (D_8019BCBA != 0) { + D_8019BCBA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018367C[])(void); + +void func_80164EA4(void *a0) { + D_8018367C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019BD04[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019BD04[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019BCF8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019BCF8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019BCF8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019BCF8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019BCF8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80183690[]; + extern u32 D_801836B0, D_801836B4, D_801836B8, D_801836BC; + extern u32 D_801836B0, D_801836B4, D_801836B8, D_801836BC; + extern u32 D_801836B0, D_801836B4, D_801836B8, D_801836BC; + extern u32 D_801836B0, D_801836B4, D_801836B8, D_801836BC; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80183690[0x00], p); + ApplyMatrixSV(mat, &D_80183690[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80183690[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80183690[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801836B8; + *(u32 *)(prim + 0x24) = D_801836B0; + *(u32 *)(prim + 0x28) = D_801836BC; + *(u32 *)(prim + 0x2c) = D_801836B4; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801836C0[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801836C0[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801836C0[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801836C0[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018373C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018373C[a1 & 0x7F]; +} + + + +extern s32 D_8018375C[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018375C[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801837D8[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801837D8[a1 & 0x7F]; +} + + + +extern u8 D_801837F8[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801837F8[a1 & 0x7F]; +} + + + +extern u8 D_80183818[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80183818[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80183838[])(void); + D_80183838[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801838B4[])(void); + +void func_80165AC8(void) { + D_801838B4[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80183930[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80183930[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019B4D8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019B4D8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018393C[])(void); + +void func_80166018(void *a0) { + D_8018393C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80183944[])(void); + +void func_801663FC(void *a0) { + D_80183944[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80183A0C[])(void); + +void func_80166618(void *a0) { + D_80183A0C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80183A1C[])(void); + +void func_80166654(void *a0) { + D_80183A1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019BD78[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019BD78[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019BD78). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019BD78[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019BD78)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019BD78[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019BD78[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80183960[]; + extern u8 D_8018394C[]; + extern u8 D_80183974[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80183960; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018394C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80183974; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80167714); + + +extern void (*D_80183A2C[])(void); + +void func_801678B4(void *a0) { + D_80183A2C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80183A38[])(void); + +void func_80167A9C(void *a0) { + D_80183A38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80183B44; + extern u8 D_80183B58[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80183B44); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80183B58; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80183998[]; +extern u8 D_801839AC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80183998; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801839AC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80183A50[])(void); + +void func_80168744(void *a0) { + D_80183A50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80183A40 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80183A40[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80183A40; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80183A58[])(void); + +void func_801689D8(void *a0) { + D_80183A58[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80183A60[])(void); + +void func_80168AA8(void *a0) { + D_80183A60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80183A68[])(void); + +void func_80168D58(void *a0) { + D_80183A68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80183A70[])(void); + +void func_8016901C(void *a0) { + D_80183A70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_007/nonmatchings/ov_SC05_007_jr_8015C32C", func_80169228); + + +extern void (*D_80183A78[])(void); + +void func_801693CC(void *a0) { + D_80183A78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80183A80[])(void); + +void func_80169830(void *a0) { + D_80183A80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80183B34[])(void); + +void func_80169B80(void *a0) { + D_80183B34[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80183A88[]; + extern u8 D_80183AF8[]; + extern u8 D_80183B28[]; + extern u8 D_8019CDB8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80183B28, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80183A88[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019CDB8; + RotMatrixYXZ(rot, D_8019CDB8); + func_80048D9C(D_8019CDB8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80183AF8); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80183B3C[])(void); + +void func_80169F00(void *a0) { + D_80183B3C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80183AEC[]; +extern char D_80183AAC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80183AEC, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80183AAC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80183B74[])(void); + +void func_8016A020(void *a0) { + D_80183B74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80183B44; + extern u8 D_80183B58[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80183B44); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80183B58; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80183B80[])(void); + +void func_8016A700(void *a0) { + D_80183B80[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80183BC8[])(void); + +void func_8016AB30(void *a0) { + D_80183BC8[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_008/ov_SC05_008_jr_8015AE2C.c b/src/ov_SC05_008/ov_SC05_008_jr_8015AE2C.c index ee895507b..2a1076a80 100644 --- a/src/ov_SC05_008/ov_SC05_008_jr_8015AE2C.c +++ b/src/ov_SC05_008/ov_SC05_008_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801851DC[])(void); - -void func_8015C714(void *a0) { - D_801851DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80185050[])(void*); - extern int D_80184FF4; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80185050)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80185050)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184FF4); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80185050[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80185050[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80185050[])(void*); - extern int D_80184FF4; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80185050)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184FF4); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80185050)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801851EC[])(void); - D_801851EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80185050[])(struct Ent_8015CD20 *); - extern u8 D_80185004; - extern u8 D_801851F4; - extern u8 D_80185204; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80185050[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185004); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801851F4); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185204); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80185050[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80185224[])(void); - D_80185224[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80185214; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80185214 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80185050[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80185280; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80185280, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80184364[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80184364; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80185288[])(void); - D_80185288[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80185294[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80185294[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80185294[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80185294[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80185050[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80185294[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80185014[]; - extern u8 D_80185024[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185014); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185024); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80185294[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185294[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185294[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801852C8[])(void); - D_801852C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185050[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801852D0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801852E8[])(void); - D_801852E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80185050[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801852D0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80185308[])(void); - D_80185308[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80185050[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185050)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80185318; -extern u16 D_8018531A; -extern u16 D_8018531C; -extern s32 D_80185320; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80185318 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018531A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018531C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185320, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80185328; - -void func_8015E588(void) { - func_8013C9C4(&D_80185328); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80185050[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80185050)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018533C[])(void); - D_8018533C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80185050[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80185050[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80185344[])(void); - D_80185344[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80185034; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185034); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80185050[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018534C[])(void); - D_8018534C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80185050[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80185050[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80185354[])(void); - D_80185354[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80185050[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018535C; - extern s32 D_8018536C; - extern s32 D_8018537C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80185050[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018535C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018536C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80185050[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018537C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018538C[])(void); - D_8018538C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80185050[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80185050[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80185050[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80185050[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80185398[])(void); - D_80185398[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80185050[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80185050[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80185050[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185050[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801853AC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801853AC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80185050[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80185050)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80185050[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80185050[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80185428[])(void); - D_80185428[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80185050[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80185050)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80185438[])(void); - D_80185438[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80185050[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80185050[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80185050[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80185050[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80185050[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80185050[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80185050[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80185440[])(void); - D_80185440[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80185050[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80185050)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80185050[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80185050)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018544C[])(void); - D_8018544C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185050 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80185050[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80185050[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80185050[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018545C[])(void); - -void func_80160EA4(void *a0) { - D_8018545C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80185050[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80185050[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018548C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018548C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801854F0; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801854F0); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019FF30[]; - extern u8 D_801854BC[]; - extern u8 D_801854DC[]; - extern u8 D_8019FF3C[]; - extern u8 D_8019FF64[]; - extern u8 D_8019FF7C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019FF30[0] = p; - func_80024054(&D_801854BC, &D_8019FF3C); - func_8001CE28(p, &D_8019FF3C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019FF30[1] = p; - func_80024054(&D_801854DC, &D_8019FF64); - func_8001CE28(p, &D_8019FF64); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019FF30[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019FF7C, 0x84); - func_8001CE68(p, &D_8019FF7C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019FF7C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019FF30[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019FF30; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801854F0; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801854F0; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801854F0; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801854F0; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019FF30[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019FF30; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80185514[])(void); - -void func_80162330(void *a0) { - D_80185514[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019FF88[i] via `extern int D_8019FF88[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80185520[]; - extern s32 D_80185538; - extern u8 D_8019FF94[]; - extern u8 D_8019FFBC[]; - extern u8 D_8019FFD8[]; - extern int D_8019FF88[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019FF88[0] = (s32)item; - func_80024054(D_80185520, D_8019FF94); - func_8001CE28(item, D_8019FF94); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019FF88[1] = (s32)item; - func_80024054(((u8 *)&D_80185538), D_8019FFBC); - func_8001CE28(item, D_8019FFBC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019FF88[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019FFD8, 0x84); - func_8001CE68(item, D_8019FFD8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019FFD8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019FF88[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019FF88; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018555C[])(void); - -void func_80162834(void *a0) { - D_8018555C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018554C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018554C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019F7FC[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019F7FC, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019F7FC[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019F7FC, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80185564[])(void); - -void func_80163A58(void *a0) { - D_80185564[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019F804; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019F804; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801855B8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801855B8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80185580; -extern s16 D_801855B4; -extern s16 D_801855B2; -extern s16 D_801855B0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80185580; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801855B4 = 0x80; - D_801855B2 = 0x80; - D_801855B0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801855B4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801855B4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801855B4 - 8; - D_801855B4 = nv; - D_801855B2 = nv; - D_801855B0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801855C4[])(void); - -void func_80164BA0(void *a0) { - D_801855C4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019FFE8; -extern u8 D_8019FFE9; -extern u8 D_8019FFEA; -extern u8 D_8019FFEB; -extern u8 D_8019FFEC; -extern u8 D_8019FFED; -extern u8 D_8019FFEE; -extern u8 D_8019FFEF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019FFE8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019FFE9 = 0xf0; - *(u8 *)base = 0xf0; - D_8019FFEA = 0xc0; - D_8019FFEE = 0; - D_8019FFED = 0; - D_8019FFEC = 0; - D_8019FFEF = 0; - D_8019FFEB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019FFE8; -extern u8 D_8019FFE9; -extern u8 D_8019FFEA; - -s32 func_80164E40(void) { - u8 *p = &D_8019FFE8; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019FFE9 != 0) { - D_8019FFE9 -= 0x10; - } - if (D_8019FFEA != 0) { - D_8019FFEA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801855D4[])(void); - -void func_80164EA4(void *a0) { - D_801855D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A0034[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A0034[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A0028[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A0028[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A0028[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A0028; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A0028; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801855E8[]; - extern u32 D_80185608, D_8018560C, D_80185610, D_80185614; - extern u32 D_80185608, D_8018560C, D_80185610, D_80185614; - extern u32 D_80185608, D_8018560C, D_80185610, D_80185614; - extern u32 D_80185608, D_8018560C, D_80185610, D_80185614; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801855E8[0x00], p); - ApplyMatrixSV(mat, &D_801855E8[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801855E8[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801855E8[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80185610; - *(u32 *)(prim + 0x24) = D_80185608; - *(u32 *)(prim + 0x28) = D_80185614; - *(u32 *)(prim + 0x2c) = D_8018560C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80185618[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80185618[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80185618[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80185618[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80185694[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80185694[a1 & 0x7F]; -} - - - -extern s32 D_801856B4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801856B4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80185730[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80185730[a1 & 0x7F]; -} - - - -extern u8 D_80185750[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80185750[a1 & 0x7F]; -} - - - -extern u8 D_80185770[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80185770[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80185790[])(void); - D_80185790[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018580C[])(void); - -void func_80165AC8(void) { - D_8018580C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80185888[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80185888[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019F80C; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019F80C, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80185894[])(void); - -void func_80166018(void *a0) { - D_80185894[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018589C[])(void); - -void func_801663FC(void *a0) { - D_8018589C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80185964[])(void); - -void func_80166618(void *a0) { - D_80185964[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80185974[])(void); - -void func_80166654(void *a0) { - D_80185974[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A00A8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A00A8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A00A8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A00A8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A00A8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A00A8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A00A8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801858B8[]; - extern u8 D_801858A4[]; - extern u8 D_801858CC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801858B8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801858A4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801858CC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80167714); - - -extern void (*D_80185984[])(void); - -void func_801678B4(void *a0) { - D_80185984[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80185990[])(void); - -void func_80167A9C(void *a0) { - D_80185990[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80185A9C; - extern u8 D_80185AB0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80185A9C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185AB0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801858F0[]; -extern u8 D_80185904[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801858F0; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80185904; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801859A8[])(void); - -void func_80168744(void *a0) { - D_801859A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80185998 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80185998[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80185998; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801859B0[])(void); - -void func_801689D8(void *a0) { - D_801859B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801859B8[])(void); - -void func_80168AA8(void *a0) { - D_801859B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801859C0[])(void); - -void func_80168D58(void *a0) { - D_801859C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801859C8[])(void); - -void func_8016901C(void *a0) { - D_801859C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015AE2C", func_80169228); - - -extern void (*D_801859D0[])(void); - -void func_801693CC(void *a0) { - D_801859D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801859D8[])(void); - -void func_80169830(void *a0) { - D_801859D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80185A8C[])(void); - -void func_80169B80(void *a0) { - D_80185A8C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801859E0[]; - extern u8 D_80185A50[]; - extern u8 D_80185A80[]; - extern u8 D_801A11A0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80185A80, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801859E0[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A11A0; - RotMatrixYXZ(rot, D_801A11A0); - func_80048D9C(D_801A11A0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80185A50); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80185A94[])(void); - -void func_80169F00(void *a0) { - D_80185A94[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80185A44[]; -extern char D_80185A04[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80185A44, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80185A04); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80185ACC[])(void); - -void func_8016A020(void *a0) { - D_80185ACC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80185A9C; - extern u8 D_80185AB0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80185A9C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80185AB0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80185AD8[])(void); - -void func_8016A700(void *a0) { - D_80185AD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80185B20[])(void); - -void func_8016AB30(void *a0) { - D_80185B20[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c b/src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c new file mode 100644 index 000000000..fa80c5af0 --- /dev/null +++ b/src/ov_SC05_008/ov_SC05_008_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80184EEC; +extern u8 D_80184E5C; +extern u8 D_80184E38; +extern u8 D_80184E14; +extern u8 D_80184EC8; +extern u8 D_80184EA4; +extern u8 D_80184E80; +extern u8 D_80184DF0; +extern void func_80145934(void); +extern u8 D_80184F7C; +extern u8 D_80184F58; +extern u8 D_80184F34; +extern u8 D_80184F10; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80184374[]; +extern unsigned char D_801843A4[]; +extern unsigned char D_801843F4[]; +extern unsigned char D_80184424[]; +extern unsigned char D_80184454[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801844A4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018456C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801845F4[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801845FC; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019FED8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019FEDC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018462C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801846D4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801846F8[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801846E8; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018470C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80184718[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80184728[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80184740[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80184730; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80184754[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80184770[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80184760; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80184784[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80184798[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801847AC; +extern void (*D_801847D4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801847B4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80184820[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80184824[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184C88[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184C98[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019FF10; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80184CC0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80184CA0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80184CB0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80184D00[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80184D08[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80184CD4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80184D14[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80184CE4; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019FF18; +extern s32 D_8019FF24; +extern s32 D_8019FF28; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80184D50[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80184D24[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019FF20; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184FA0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80184DC0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80185044[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80185198[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80184FB4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801851A0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80184FC4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80184FE4; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801851A8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801851D0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80185050[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80185050[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80185050[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80185050[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80185050[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80185050[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80185050[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80185050[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801851DC[])(void); + +void func_8015C714(void *a0) { + D_801851DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80185050[])(void*); + extern int D_80184FF4; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80185050)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80185050)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184FF4); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80185050[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80185050[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80185050[])(void*); + extern int D_80184FF4; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80185050)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80184FF4); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80185050)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801851EC[])(void); + D_801851EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80185050[])(struct Ent_8015CD20 *); + extern u8 D_80185004; + extern u8 D_801851F4; + extern u8 D_80185204; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80185050[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185004); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801851F4); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80185204); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80185050[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80185224[])(void); + D_80185224[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80185214; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80185214 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80185050[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80185280; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80185280, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80184364[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80184364; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80185288[])(void); + D_80185288[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80185294[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80185294[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80185294[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80185294[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80185050[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80185294[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80185014[]; + extern u8 D_80185024[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185014); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80185024); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80185294[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80185294[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80185294[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801852C8[])(void); + D_801852C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185050[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801852D0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801852E8[])(void); + D_801852E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80185050[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801852D0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801852D0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80185308[])(void); + D_80185308[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80185050[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185050)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80185318; +extern u16 D_8018531A; +extern u16 D_8018531C; +extern s32 D_80185320; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80185318 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018531A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018531C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80185320, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80185328; + +void func_8015E588(void) { + func_8013C9C4(&D_80185328); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80185050[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80185050)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018533C[])(void); + D_8018533C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80185050[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80185050[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80185344[])(void); + D_80185344[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80185034; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80185034); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80185050[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018534C[])(void); + D_8018534C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80185050[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80185050[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80185354[])(void); + D_80185354[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80185050[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018535C; + extern s32 D_8018536C; + extern s32 D_8018537C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80185050[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018535C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018536C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80185050[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018537C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018538C[])(void); + D_8018538C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80185050[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80185050[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80185050[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80185050[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80185398[])(void); + D_80185398[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80185050[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80185050[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80185050[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185050[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801853AC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801853AC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80185050[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80185050)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80185050[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80185050[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80185428[])(void); + D_80185428[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80185050[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80185050)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80185438[])(void); + D_80185438[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80185050[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80185050[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80185050[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80185050[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80185050[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80185050[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80185050[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80185440[])(void); + D_80185440[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80185050[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80185050)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80185050[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80185050)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018544C[])(void); + D_8018544C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80185050 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80185050[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80185050[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80185050[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018545C[])(void); + +void func_80160EA4(void *a0) { + D_8018545C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80185050[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80185050[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018548C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018548C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801854F0; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801854F0); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019FF30[]; + extern u8 D_801854BC[]; + extern u8 D_801854DC[]; + extern u8 D_8019FF3C[]; + extern u8 D_8019FF64[]; + extern u8 D_8019FF7C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019FF30[0] = p; + func_80024054(&D_801854BC, &D_8019FF3C); + func_8001CE28(p, &D_8019FF3C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019FF30[1] = p; + func_80024054(&D_801854DC, &D_8019FF64); + func_8001CE28(p, &D_8019FF64); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019FF30[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019FF7C, 0x84); + func_8001CE68(p, &D_8019FF7C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019FF7C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019FF30[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019FF30; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801854F0; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801854F0; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801854F0; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801854F0; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019FF30[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019FF30; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80185514[])(void); + +void func_80162330(void *a0) { + D_80185514[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019FF88[i] via `extern int D_8019FF88[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80185520[]; + extern s32 D_80185538; + extern u8 D_8019FF94[]; + extern u8 D_8019FFBC[]; + extern u8 D_8019FFD8[]; + extern int D_8019FF88[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019FF88[0] = (s32)item; + func_80024054(D_80185520, D_8019FF94); + func_8001CE28(item, D_8019FF94); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019FF88[1] = (s32)item; + func_80024054(((u8 *)&D_80185538), D_8019FFBC); + func_8001CE28(item, D_8019FFBC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019FF88[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019FFD8, 0x84); + func_8001CE68(item, D_8019FFD8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019FFD8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019FF88[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019FF88; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_801627E8); + + +extern void (*D_8018555C[])(void); + +void func_80162834(void *a0) { + D_8018555C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018554C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018554C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019F7FC[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019F7FC, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019F7FC[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019F7FC, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80185564[])(void); + +void func_80163A58(void *a0) { + D_80185564[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019F804; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019F804; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801855B8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801855B8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80185580; +extern s16 D_801855B4; +extern s16 D_801855B2; +extern s16 D_801855B0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80185580; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801855B4 = 0x80; + D_801855B2 = 0x80; + D_801855B0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801855B4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801855B4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801855B4 - 8; + D_801855B4 = nv; + D_801855B2 = nv; + D_801855B0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801855C4[])(void); + +void func_80164BA0(void *a0) { + D_801855C4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019FFE8; +extern u8 D_8019FFE9; +extern u8 D_8019FFEA; +extern u8 D_8019FFEB; +extern u8 D_8019FFEC; +extern u8 D_8019FFED; +extern u8 D_8019FFEE; +extern u8 D_8019FFEF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019FFE8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019FFE9 = 0xf0; + *(u8 *)base = 0xf0; + D_8019FFEA = 0xc0; + D_8019FFEE = 0; + D_8019FFED = 0; + D_8019FFEC = 0; + D_8019FFEF = 0; + D_8019FFEB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019FFE8; +extern u8 D_8019FFE9; +extern u8 D_8019FFEA; + +s32 func_80164E40(void) { + u8 *p = &D_8019FFE8; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019FFE9 != 0) { + D_8019FFE9 -= 0x10; + } + if (D_8019FFEA != 0) { + D_8019FFEA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801855D4[])(void); + +void func_80164EA4(void *a0) { + D_801855D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A0034[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A0034[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A0028[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A0028[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A0028[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A0028; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A0028; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801855E8[]; + extern u32 D_80185608, D_8018560C, D_80185610, D_80185614; + extern u32 D_80185608, D_8018560C, D_80185610, D_80185614; + extern u32 D_80185608, D_8018560C, D_80185610, D_80185614; + extern u32 D_80185608, D_8018560C, D_80185610, D_80185614; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801855E8[0x00], p); + ApplyMatrixSV(mat, &D_801855E8[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801855E8[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801855E8[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80185610; + *(u32 *)(prim + 0x24) = D_80185608; + *(u32 *)(prim + 0x28) = D_80185614; + *(u32 *)(prim + 0x2c) = D_8018560C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80185618[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80185618[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80185618[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80185618[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80185694[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80185694[a1 & 0x7F]; +} + + + +extern s32 D_801856B4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801856B4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80185730[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80185730[a1 & 0x7F]; +} + + + +extern u8 D_80185750[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80185750[a1 & 0x7F]; +} + + + +extern u8 D_80185770[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80185770[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80185790[])(void); + D_80185790[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018580C[])(void); + +void func_80165AC8(void) { + D_8018580C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80185888[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80185888[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019F80C; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019F80C, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80185894[])(void); + +void func_80166018(void *a0) { + D_80185894[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018589C[])(void); + +void func_801663FC(void *a0) { + D_8018589C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80185964[])(void); + +void func_80166618(void *a0) { + D_80185964[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80185974[])(void); + +void func_80166654(void *a0) { + D_80185974[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A00A8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A00A8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A00A8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A00A8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A00A8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A00A8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A00A8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801858B8[]; + extern u8 D_801858A4[]; + extern u8 D_801858CC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801858B8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801858A4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801858CC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80167714); + + +extern void (*D_80185984[])(void); + +void func_801678B4(void *a0) { + D_80185984[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80185990[])(void); + +void func_80167A9C(void *a0) { + D_80185990[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80185A9C; + extern u8 D_80185AB0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80185A9C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185AB0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801858F0[]; +extern u8 D_80185904[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801858F0; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80185904; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801859A8[])(void); + +void func_80168744(void *a0) { + D_801859A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80185998 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80185998[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80185998; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801859B0[])(void); + +void func_801689D8(void *a0) { + D_801859B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801859B8[])(void); + +void func_80168AA8(void *a0) { + D_801859B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801859C0[])(void); + +void func_80168D58(void *a0) { + D_801859C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801859C8[])(void); + +void func_8016901C(void *a0) { + D_801859C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_008/nonmatchings/ov_SC05_008_jr_8015C32C", func_80169228); + + +extern void (*D_801859D0[])(void); + +void func_801693CC(void *a0) { + D_801859D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801859D8[])(void); + +void func_80169830(void *a0) { + D_801859D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80185A8C[])(void); + +void func_80169B80(void *a0) { + D_80185A8C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801859E0[]; + extern u8 D_80185A50[]; + extern u8 D_80185A80[]; + extern u8 D_801A11A0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80185A80, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801859E0[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A11A0; + RotMatrixYXZ(rot, D_801A11A0); + func_80048D9C(D_801A11A0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80185A50); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80185A94[])(void); + +void func_80169F00(void *a0) { + D_80185A94[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80185A44[]; +extern char D_80185A04[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80185A44, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80185A04); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80185ACC[])(void); + +void func_8016A020(void *a0) { + D_80185ACC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80185A9C; + extern u8 D_80185AB0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80185A9C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80185AB0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80185AD8[])(void); + +void func_8016A700(void *a0) { + D_80185AD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80185B20[])(void); + +void func_8016AB30(void *a0) { + D_80185B20[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_009/ov_SC05_009_jr_8015AE2C.c b/src/ov_SC05_009/ov_SC05_009_jr_8015AE2C.c index 7553ed753..da121bbc7 100644 --- a/src/ov_SC05_009/ov_SC05_009_jr_8015AE2C.c +++ b/src/ov_SC05_009/ov_SC05_009_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801812EC[])(void); - -void func_8015C714(void *a0) { - D_801812EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181160[])(void*); - extern int D_80181104; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181104); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181160[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181160[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181160[])(void*); - extern int D_80181104; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181104); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801812FC[])(void); - D_801812FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181160[])(struct Ent_8015CD20 *); - extern u8 D_80181114; - extern u8 D_80181304; - extern u8 D_80181314; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181160[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181114); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181304); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181314); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181160[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181334[])(void); - D_80181334[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181324; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181324 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181160[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181390; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181390, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180474[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180474; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80181398[])(void); - D_80181398[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801813A4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801813A4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801813A4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801813A4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181160[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801813A4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80181124[]; - extern u8 D_80181134[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181124); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181134); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801813D8[])(void); - D_801813D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181160[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801813E0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801813F8[])(void); - D_801813F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181160[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801813E0[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181418[])(void); - D_80181418[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181160[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181160)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181428; -extern u16 D_8018142A; -extern u16 D_8018142C; -extern s32 D_80181430; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181428 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018142A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018142C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181430, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181438; - -void func_8015E588(void) { - func_8013C9C4(&D_80181438); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181160[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181160)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018144C[])(void); - D_8018144C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181160[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181160[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181454[])(void); - D_80181454[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80181144; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181144); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181160[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018145C[])(void); - D_8018145C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181160[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181160[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181464[])(void); - D_80181464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181160[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018146C; - extern s32 D_8018147C; - extern s32 D_8018148C; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181160[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018146C); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018147C); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181160[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018148C); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018149C[])(void); - D_8018149C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181160[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181160[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181160[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801814A8[])(void); - D_801814A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181160[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181160[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181160[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181160[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801814BC[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801814BC[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181160[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181160)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181160[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181160[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181538[])(void); - D_80181538[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181160[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181160)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181548[])(void); - D_80181548[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181160[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181160[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181160[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181160[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181160[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181160[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181160[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181550[])(void); - D_80181550[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181160[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181160)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181160[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181160)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018155C[])(void); - D_8018155C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181160 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181160[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181160[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181160[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018156C[])(void); - -void func_80160EA4(void *a0) { - D_8018156C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181160[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181160[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018159C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018159C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181600; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181600); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80195940[]; - extern u8 D_801815CC[]; - extern u8 D_801815EC[]; - extern u8 D_8019594C[]; - extern u8 D_80195974[]; - extern u8 D_8019598C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80195940[0] = p; - func_80024054(&D_801815CC, &D_8019594C); - func_8001CE28(p, &D_8019594C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80195940[1] = p; - func_80024054(&D_801815EC, &D_80195974); - func_8001CE28(p, &D_80195974); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80195940[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019598C, 0x84); - func_8001CE68(p, &D_8019598C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019598C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80195940[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80195940; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181600; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181600; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181600; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181600; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80195940[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80195940; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181624[])(void); - -void func_80162330(void *a0) { - D_80181624[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80195998[i] via `extern int D_80195998[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181630[]; - extern s32 D_80181648; - extern u8 D_801959A4[]; - extern u8 D_801959CC[]; - extern u8 D_801959E8[]; - extern int D_80195998[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80195998[0] = (s32)item; - func_80024054(D_80181630, D_801959A4); - func_8001CE28(item, D_801959A4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80195998[1] = (s32)item; - func_80024054(((u8 *)&D_80181648), D_801959CC); - func_8001CE28(item, D_801959CC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80195998[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801959E8, 0x84); - func_8001CE68(item, D_801959E8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801959E8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80195998[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80195998; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018166C[])(void); - -void func_80162834(void *a0) { - D_8018166C[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018165C; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018165C, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80195210[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80195210, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80195210[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80195210, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181674[])(void); - -void func_80163A58(void *a0) { - D_80181674[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80195218; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80195218; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801816C8[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801816C8[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181690; -extern s16 D_801816C4; -extern s16 D_801816C2; -extern s16 D_801816C0; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181690; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801816C4 = 0x80; - D_801816C2 = 0x80; - D_801816C0 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801816C4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801816C4` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801816C4 - 8; - D_801816C4 = nv; - D_801816C2 = nv; - D_801816C0 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801816D4[])(void); - -void func_80164BA0(void *a0) { - D_801816D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801959F8; -extern u8 D_801959F9; -extern u8 D_801959FA; -extern u8 D_801959FB; -extern u8 D_801959FC; -extern u8 D_801959FD; -extern u8 D_801959FE; -extern u8 D_801959FF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801959F8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801959F9 = 0xf0; - *(u8 *)base = 0xf0; - D_801959FA = 0xc0; - D_801959FE = 0; - D_801959FD = 0; - D_801959FC = 0; - D_801959FF = 0; - D_801959FB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801959F8; -extern u8 D_801959F9; -extern u8 D_801959FA; - -s32 func_80164E40(void) { - u8 *p = &D_801959F8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801959F9 != 0) { - D_801959F9 -= 0x10; - } - if (D_801959FA != 0) { - D_801959FA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801816E4[])(void); - -void func_80164EA4(void *a0) { - D_801816E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80195A44[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80195A44[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80195A38[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80195A38[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80195A38[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80195A38; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80195A38; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801816F8[]; - extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; - extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; - extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; - extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801816F8[0x00], p); - ApplyMatrixSV(mat, &D_801816F8[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801816F8[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801816F8[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181720; - *(u32 *)(prim + 0x24) = D_80181718; - *(u32 *)(prim + 0x28) = D_80181724; - *(u32 *)(prim + 0x2c) = D_8018171C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181728[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181728[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181728[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181728[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801817A4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801817A4[a1 & 0x7F]; -} - - - -extern s32 D_801817C4[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801817C4[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181840[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181840[a1 & 0x7F]; -} - - - -extern u8 D_80181860[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80181860[a1 & 0x7F]; -} - - - -extern u8 D_80181880[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181880[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801818A0[])(void); - D_801818A0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018191C[])(void); - -void func_80165AC8(void) { - D_8018191C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181998[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181998[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80195220; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80195220, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801819A4[])(void); - -void func_80166018(void *a0) { - D_801819A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801819AC[])(void); - -void func_801663FC(void *a0) { - D_801819AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80181A74[])(void); - -void func_80166618(void *a0) { - D_80181A74[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181A84[])(void); - -void func_80166654(void *a0) { - D_80181A84[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80195AB8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80195AB8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80195AB8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80195AB8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80195AB8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80195AB8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80195AB8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801819C8[]; - extern u8 D_801819B4[]; - extern u8 D_801819DC[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801819C8; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801819B4; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801819DC; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80167714); - - -extern void (*D_80181A94[])(void); - -void func_801678B4(void *a0) { - D_80181A94[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181AA0[])(void); - -void func_80167A9C(void *a0) { - D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181BAC; - extern u8 D_80181BC0[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181BAC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181BC0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80181A00[]; -extern u8 D_80181A14[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80181A00; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181A14; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181AB8[])(void); - -void func_80168744(void *a0) { - D_80181AB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181AA8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181AA8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181AA8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181AC0[])(void); - -void func_801689D8(void *a0) { - D_80181AC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181AC8[])(void); - -void func_80168AA8(void *a0) { - D_80181AC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181AD0[])(void); - -void func_80168D58(void *a0) { - D_80181AD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181AD8[])(void); - -void func_8016901C(void *a0) { - D_80181AD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015AE2C", func_80169228); - - -extern void (*D_80181AE0[])(void); - -void func_801693CC(void *a0) { - D_80181AE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181AE8[])(void); - -void func_80169830(void *a0) { - D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181B9C[])(void); - -void func_80169B80(void *a0) { - D_80181B9C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181AF0[]; - extern u8 D_80181B60[]; - extern u8 D_80181B90[]; - extern u8 D_80196B00[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181B90, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181AF0[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_80196B00; - RotMatrixYXZ(rot, D_80196B00); - func_80048D9C(D_80196B00, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181B60); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181BA4[])(void); - -void func_80169F00(void *a0) { - D_80181BA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80181B54[]; -extern char D_80181B14[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80181B54, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181B14); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181BDC[])(void); - -void func_8016A020(void *a0) { - D_80181BDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181BAC; - extern u8 D_80181BC0[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181BAC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181BC0; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181BE8[])(void); - -void func_8016A700(void *a0) { - D_80181BE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80181C30[])(void); - -void func_8016AB30(void *a0) { - D_80181C30[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c b/src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c new file mode 100644 index 000000000..8035b314b --- /dev/null +++ b/src/ov_SC05_009/ov_SC05_009_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180FFC; +extern u8 D_80180F6C; +extern u8 D_80180F48; +extern u8 D_80180F24; +extern u8 D_80180FD8; +extern u8 D_80180FB4; +extern u8 D_80180F90; +extern u8 D_80180F00; +extern void func_80145934(void); +extern u8 D_8018108C; +extern u8 D_80181068; +extern u8 D_80181044; +extern u8 D_80181020; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180484[]; +extern unsigned char D_801804B4[]; +extern unsigned char D_80180504[]; +extern unsigned char D_80180534[]; +extern unsigned char D_80180564[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801805B4[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018067C[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180704[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018070C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801958E8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801958EC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018073C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801807E4[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180808[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801807F8; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018081C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180828[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180838[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80180850[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180840; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80180864[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80180880[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80180870; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80180894[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801808A8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801808BC; +extern void (*D_801808E4[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801808C4; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80180930[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80180934[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180D98[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180DA8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80195920; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180DD0[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180DB0; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180DC0; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180E10[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180E18[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180DE4; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80180E24[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180DF4; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80195928; +extern s32 D_80195934; +extern s32 D_80195938; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180E60[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80180E34[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80195930; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801810B0[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180ED0[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181154[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801812A8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801810C4; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801812B0[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801810D4; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801810F4; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801812B8[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801812E0[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181160[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801812EC[])(void); + +void func_8015C714(void *a0) { + D_801812EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181160[])(void*); + extern int D_80181104; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181104); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181160[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181160[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181160[])(void*); + extern int D_80181104; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80181104); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801812FC[])(void); + D_801812FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181160[])(struct Ent_8015CD20 *); + extern u8 D_80181114; + extern u8 D_80181304; + extern u8 D_80181314; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181160[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181114); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181304); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181314); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181160[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181334[])(void); + D_80181334[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181324; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181324 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181160[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181390; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181390, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180474[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180474; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80181398[])(void); + D_80181398[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801813A4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801813A4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801813A4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801813A4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181160[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801813A4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80181124[]; + extern u8 D_80181134[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181124); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80181134); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801813A4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801813D8[])(void); + D_801813D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181160[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801813E0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801813F8[])(void); + D_801813F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181160[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801813E0[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801813E0[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181418[])(void); + D_80181418[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181160[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181160)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181428; +extern u16 D_8018142A; +extern u16 D_8018142C; +extern s32 D_80181430; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181428 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018142A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018142C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181430, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181438; + +void func_8015E588(void) { + func_8013C9C4(&D_80181438); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181160[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181160)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018144C[])(void); + D_8018144C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181160[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181160[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181454[])(void); + D_80181454[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80181144; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181144); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181160[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018145C[])(void); + D_8018145C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181160[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181160[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181464[])(void); + D_80181464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181160[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018146C; + extern s32 D_8018147C; + extern s32 D_8018148C; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181160[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018146C); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018147C); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181160[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018148C); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018149C[])(void); + D_8018149C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181160[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181160[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181160[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801814A8[])(void); + D_801814A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181160[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181160[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181160[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181160[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801814BC[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801814BC[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181160[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181160)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181160[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181160[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181538[])(void); + D_80181538[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181160[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181160)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181548[])(void); + D_80181548[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181160[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181160[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181160[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181160[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181160[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181160[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181160[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181550[])(void); + D_80181550[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181160[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181160)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181160[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181160)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018155C[])(void); + D_8018155C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181160 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181160[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181160[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181160[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018156C[])(void); + +void func_80160EA4(void *a0) { + D_8018156C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181160[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181160[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018159C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018159C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181600; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181600); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80195940[]; + extern u8 D_801815CC[]; + extern u8 D_801815EC[]; + extern u8 D_8019594C[]; + extern u8 D_80195974[]; + extern u8 D_8019598C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80195940[0] = p; + func_80024054(&D_801815CC, &D_8019594C); + func_8001CE28(p, &D_8019594C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80195940[1] = p; + func_80024054(&D_801815EC, &D_80195974); + func_8001CE28(p, &D_80195974); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80195940[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019598C, 0x84); + func_8001CE68(p, &D_8019598C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019598C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80195940[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80195940; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181600; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181600; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181600; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181600; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80195940[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80195940; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181624[])(void); + +void func_80162330(void *a0) { + D_80181624[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80195998[i] via `extern int D_80195998[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181630[]; + extern s32 D_80181648; + extern u8 D_801959A4[]; + extern u8 D_801959CC[]; + extern u8 D_801959E8[]; + extern int D_80195998[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80195998[0] = (s32)item; + func_80024054(D_80181630, D_801959A4); + func_8001CE28(item, D_801959A4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80195998[1] = (s32)item; + func_80024054(((u8 *)&D_80181648), D_801959CC); + func_8001CE28(item, D_801959CC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80195998[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801959E8, 0x84); + func_8001CE68(item, D_801959E8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801959E8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80195998[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80195998; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_801627E8); + + +extern void (*D_8018166C[])(void); + +void func_80162834(void *a0) { + D_8018166C[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018165C; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018165C, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80195210[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80195210, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80195210[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80195210, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181674[])(void); + +void func_80163A58(void *a0) { + D_80181674[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80195218; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80195218; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801816C8[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801816C8[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181690; +extern s16 D_801816C4; +extern s16 D_801816C2; +extern s16 D_801816C0; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181690; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801816C4 = 0x80; + D_801816C2 = 0x80; + D_801816C0 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801816C4 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801816C4` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801816C4 - 8; + D_801816C4 = nv; + D_801816C2 = nv; + D_801816C0 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801816D4[])(void); + +void func_80164BA0(void *a0) { + D_801816D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801959F8; +extern u8 D_801959F9; +extern u8 D_801959FA; +extern u8 D_801959FB; +extern u8 D_801959FC; +extern u8 D_801959FD; +extern u8 D_801959FE; +extern u8 D_801959FF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801959F8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801959F9 = 0xf0; + *(u8 *)base = 0xf0; + D_801959FA = 0xc0; + D_801959FE = 0; + D_801959FD = 0; + D_801959FC = 0; + D_801959FF = 0; + D_801959FB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801959F8; +extern u8 D_801959F9; +extern u8 D_801959FA; + +s32 func_80164E40(void) { + u8 *p = &D_801959F8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801959F9 != 0) { + D_801959F9 -= 0x10; + } + if (D_801959FA != 0) { + D_801959FA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801816E4[])(void); + +void func_80164EA4(void *a0) { + D_801816E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80195A44[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80195A44[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80195A38[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80195A38[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80195A38[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80195A38; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80195A38; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801816F8[]; + extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; + extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; + extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; + extern u32 D_80181718, D_8018171C, D_80181720, D_80181724; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801816F8[0x00], p); + ApplyMatrixSV(mat, &D_801816F8[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801816F8[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801816F8[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181720; + *(u32 *)(prim + 0x24) = D_80181718; + *(u32 *)(prim + 0x28) = D_80181724; + *(u32 *)(prim + 0x2c) = D_8018171C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181728[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181728[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181728[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181728[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801817A4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801817A4[a1 & 0x7F]; +} + + + +extern s32 D_801817C4[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801817C4[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181840[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181840[a1 & 0x7F]; +} + + + +extern u8 D_80181860[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80181860[a1 & 0x7F]; +} + + + +extern u8 D_80181880[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181880[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801818A0[])(void); + D_801818A0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018191C[])(void); + +void func_80165AC8(void) { + D_8018191C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181998[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181998[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80195220; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80195220, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801819A4[])(void); + +void func_80166018(void *a0) { + D_801819A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801819AC[])(void); + +void func_801663FC(void *a0) { + D_801819AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80181A74[])(void); + +void func_80166618(void *a0) { + D_80181A74[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181A84[])(void); + +void func_80166654(void *a0) { + D_80181A84[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80195AB8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80195AB8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80195AB8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80195AB8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80195AB8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80195AB8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80195AB8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801819C8[]; + extern u8 D_801819B4[]; + extern u8 D_801819DC[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801819C8; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801819B4; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801819DC; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80167714); + + +extern void (*D_80181A94[])(void); + +void func_801678B4(void *a0) { + D_80181A94[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181AA0[])(void); + +void func_80167A9C(void *a0) { + D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181BAC; + extern u8 D_80181BC0[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181BAC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181BC0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80181A00[]; +extern u8 D_80181A14[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80181A00; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181A14; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181AB8[])(void); + +void func_80168744(void *a0) { + D_80181AB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181AA8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181AA8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181AA8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181AC0[])(void); + +void func_801689D8(void *a0) { + D_80181AC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181AC8[])(void); + +void func_80168AA8(void *a0) { + D_80181AC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181AD0[])(void); + +void func_80168D58(void *a0) { + D_80181AD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181AD8[])(void); + +void func_8016901C(void *a0) { + D_80181AD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_009/nonmatchings/ov_SC05_009_jr_8015C32C", func_80169228); + + +extern void (*D_80181AE0[])(void); + +void func_801693CC(void *a0) { + D_80181AE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181AE8[])(void); + +void func_80169830(void *a0) { + D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181B9C[])(void); + +void func_80169B80(void *a0) { + D_80181B9C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181AF0[]; + extern u8 D_80181B60[]; + extern u8 D_80181B90[]; + extern u8 D_80196B00[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181B90, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181AF0[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_80196B00; + RotMatrixYXZ(rot, D_80196B00); + func_80048D9C(D_80196B00, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181B60); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181BA4[])(void); + +void func_80169F00(void *a0) { + D_80181BA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80181B54[]; +extern char D_80181B14[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80181B54, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181B14); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181BDC[])(void); + +void func_8016A020(void *a0) { + D_80181BDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181BAC; + extern u8 D_80181BC0[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181BAC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181BC0; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181BE8[])(void); + +void func_8016A700(void *a0) { + D_80181BE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80181C30[])(void); + +void func_8016AB30(void *a0) { + D_80181C30[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_010/ov_SC05_010_jr_8015AE2C.c b/src/ov_SC05_010/ov_SC05_010_jr_8015AE2C.c index 83ad90d99..4033f58b0 100644 --- a/src/ov_SC05_010/ov_SC05_010_jr_8015AE2C.c +++ b/src/ov_SC05_010/ov_SC05_010_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018B1C8[])(void); - -void func_8015C714(void *a0) { - D_8018B1C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018B03C[])(void*); - extern int D_8018AFE0; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018B03C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018B03C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018AFE0); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018B03C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018B03C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018B03C[])(void*); - extern int D_8018AFE0; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018B03C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018AFE0); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018B03C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018B1D8[])(void); - D_8018B1D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018B03C[])(struct Ent_8015CD20 *); - extern u8 D_8018AFF0; - extern u8 D_8018B1E0; - extern u8 D_8018B1F0; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018B03C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AFF0); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018B1E0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018B1F0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018B03C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018B210[])(void); - D_8018B210[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018B200; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018B200 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018B03C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018B26C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018B26C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018A350[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018A350; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018B274[])(void); - D_8018B274[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018B280[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018B280[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018B280[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018B280[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018B03C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018B280[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018B000[]; - extern u8 D_8018B010[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018B000); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018B010); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018B280[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018B280[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018B280[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018B2B4[])(void); - D_8018B2B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018B03C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018B2BC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018B2D4[])(void); - D_8018B2D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018B03C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018B2BC[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018B2F4[])(void); - D_8018B2F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018B03C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018B03C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018B304; -extern u16 D_8018B306; -extern u16 D_8018B308; -extern s32 D_8018B30C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018B304 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018B306 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018B308 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018B30C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018B314; - -void func_8015E588(void) { - func_8013C9C4(&D_8018B314); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018B03C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018B03C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018B328[])(void); - D_8018B328[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018B03C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018B03C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018B330[])(void); - D_8018B330[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018B020; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018B020); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018B03C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018B338[])(void); - D_8018B338[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018B03C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018B03C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018B340[])(void); - D_8018B340[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018B03C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018B348; - extern s32 D_8018B358; - extern s32 D_8018B368; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018B03C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018B348); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018B358); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018B03C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018B368); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018B378[])(void); - D_8018B378[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018B03C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018B03C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018B03C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018B03C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018B384[])(void); - D_8018B384[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018B03C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018B03C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018B03C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018B03C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018B398[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018B398[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018B03C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018B03C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018B03C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018B03C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018B414[])(void); - D_8018B414[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018B03C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018B03C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018B424[])(void); - D_8018B424[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018B03C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018B03C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018B03C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018B03C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018B03C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018B03C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018B03C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018B42C[])(void); - D_8018B42C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018B03C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018B03C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018B03C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018B03C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018B438[])(void); - D_8018B438[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018B03C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018B03C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018B03C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018B03C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018B448[])(void); - -void func_80160EA4(void *a0) { - D_8018B448[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018B03C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018B03C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018B478[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018B478[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018B4DC; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018B4DC); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801C5D90[]; - extern u8 D_8018B4A8[]; - extern u8 D_8018B4C8[]; - extern u8 D_801C5D9C[]; - extern u8 D_801C5DC4[]; - extern u8 D_801C5DDC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801C5D90[0] = p; - func_80024054(&D_8018B4A8, &D_801C5D9C); - func_8001CE28(p, &D_801C5D9C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801C5D90[1] = p; - func_80024054(&D_8018B4C8, &D_801C5DC4); - func_8001CE28(p, &D_801C5DC4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801C5D90[2] = p; - func_800242D0((s16)func_801620C4(), &D_801C5DDC, 0x84); - func_8001CE68(p, &D_801C5DDC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801C5DDC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C5D90[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801C5D90; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018B4DC; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018B4DC; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018B4DC; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018B4DC; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801C5D90[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801C5D90; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018B500[])(void); - -void func_80162330(void *a0) { - D_8018B500[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801C5DE8[i] via `extern int D_801C5DE8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018B50C[]; - extern s32 D_8018B524; - extern u8 D_801C5DF4[]; - extern u8 D_801C5E1C[]; - extern u8 D_801C5E38[]; - extern int D_801C5DE8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801C5DE8[0] = (s32)item; - func_80024054(D_8018B50C, D_801C5DF4); - func_8001CE28(item, D_801C5DF4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801C5DE8[1] = (s32)item; - func_80024054(((u8 *)&D_8018B524), D_801C5E1C); - func_8001CE28(item, D_801C5E1C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801C5DE8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801C5E38, 0x84); - func_8001CE68(item, D_801C5E38); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801C5E38, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801C5DE8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801C5DE8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018B548[])(void); - -void func_80162834(void *a0) { - D_8018B548[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018B538; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018B538, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801C5444[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801C5444, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801C5444[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801C5444, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018B550[])(void); - -void func_80163A58(void *a0) { - D_8018B550[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801C544C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801C544C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018B5A4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018B5A4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018B56C; -extern s16 D_8018B5A0; -extern s16 D_8018B59E; -extern s16 D_8018B59C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018B56C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018B5A0 = 0x80; - D_8018B59E = 0x80; - D_8018B59C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018B5A0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018B5A0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018B5A0 - 8; - D_8018B5A0 = nv; - D_8018B59E = nv; - D_8018B59C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018B5B0[])(void); - -void func_80164BA0(void *a0) { - D_8018B5B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801C5E48; -extern u8 D_801C5E49; -extern u8 D_801C5E4A; -extern u8 D_801C5E4B; -extern u8 D_801C5E4C; -extern u8 D_801C5E4D; -extern u8 D_801C5E4E; -extern u8 D_801C5E4F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801C5E48; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801C5E49 = 0xf0; - *(u8 *)base = 0xf0; - D_801C5E4A = 0xc0; - D_801C5E4E = 0; - D_801C5E4D = 0; - D_801C5E4C = 0; - D_801C5E4F = 0; - D_801C5E4B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801C5E48; -extern u8 D_801C5E49; -extern u8 D_801C5E4A; - -s32 func_80164E40(void) { - u8 *p = &D_801C5E48; - if (*p != 0) { - *p -= 0x10; - } - if (D_801C5E49 != 0) { - D_801C5E49 -= 0x10; - } - if (D_801C5E4A != 0) { - D_801C5E4A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018B5C0[])(void); - -void func_80164EA4(void *a0) { - D_8018B5C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801C5E94[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801C5E94[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801C5E88[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801C5E88[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801C5E88[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801C5E88; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801C5E88; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018B5D4[]; - extern u32 D_8018B5F4, D_8018B5F8, D_8018B5FC, D_8018B600; - extern u32 D_8018B5F4, D_8018B5F8, D_8018B5FC, D_8018B600; - extern u32 D_8018B5F4, D_8018B5F8, D_8018B5FC, D_8018B600; - extern u32 D_8018B5F4, D_8018B5F8, D_8018B5FC, D_8018B600; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018B5D4[0x00], p); - ApplyMatrixSV(mat, &D_8018B5D4[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018B5D4[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018B5D4[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018B5FC; - *(u32 *)(prim + 0x24) = D_8018B5F4; - *(u32 *)(prim + 0x28) = D_8018B600; - *(u32 *)(prim + 0x2c) = D_8018B5F8; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018B604[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018B604[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018B604[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018B604[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018B680[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018B680[a1 & 0x7F]; -} - - - -extern s32 D_8018B6A0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018B6A0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018B71C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018B71C[a1 & 0x7F]; -} - - - -extern u8 D_8018B73C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018B73C[a1 & 0x7F]; -} - - - -extern u8 D_8018B75C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018B75C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018B77C[])(void); - D_8018B77C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018B7F8[])(void); - -void func_80165AC8(void) { - D_8018B7F8[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018B874[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018B874[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801C5454; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801C5454, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018B880[])(void); - -void func_80166018(void *a0) { - D_8018B880[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018B888[])(void); - -void func_801663FC(void *a0) { - D_8018B888[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018B950[])(void); - -void func_80166618(void *a0) { - D_8018B950[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018B960[])(void); - -void func_80166654(void *a0) { - D_8018B960[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801C5F08[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801C5F08[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C5F08). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801C5F08[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801C5F08)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801C5F08[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801C5F08[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018B8A4[]; - extern u8 D_8018B890[]; - extern u8 D_8018B8B8[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018B8A4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018B890; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018B8B8; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80167714); - - -extern void (*D_8018B970[])(void); - -void func_801678B4(void *a0) { - D_8018B970[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018B97C[])(void); - -void func_80167A9C(void *a0) { - D_8018B97C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018BA88; - extern u8 D_8018BA9C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018BA88); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018BA9C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018B8DC[]; -extern u8 D_8018B8F0[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018B8DC; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018B8F0; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018B994[])(void); - -void func_80168744(void *a0) { - D_8018B994[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018B984 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018B984[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018B984; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018B99C[])(void); - -void func_801689D8(void *a0) { - D_8018B99C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018B9A4[])(void); - -void func_80168AA8(void *a0) { - D_8018B9A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018B9AC[])(void); - -void func_80168D58(void *a0) { - D_8018B9AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018B9B4[])(void); - -void func_8016901C(void *a0) { - D_8018B9B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015AE2C", func_80169228); - - -extern void (*D_8018B9BC[])(void); - -void func_801693CC(void *a0) { - D_8018B9BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018B9C4[])(void); - -void func_80169830(void *a0) { - D_8018B9C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018BA78[])(void); - -void func_80169B80(void *a0) { - D_8018BA78[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018B9CC[]; - extern u8 D_8018BA3C[]; - extern u8 D_8018BA6C[]; - extern u8 D_801C7EE8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018BA6C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018B9CC[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801C7EE8; - RotMatrixYXZ(rot, D_801C7EE8); - func_80048D9C(D_801C7EE8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018BA3C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018BA80[])(void); - -void func_80169F00(void *a0) { - D_8018BA80[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018BA30[]; -extern char D_8018B9F0[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018BA30, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018B9F0); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018BAB8[])(void); - -void func_8016A020(void *a0) { - D_8018BAB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018BA88; - extern u8 D_8018BA9C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018BA88); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018BA9C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018BAC4[])(void); - -void func_8016A700(void *a0) { - D_8018BAC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018BB0C[])(void); - -void func_8016AB30(void *a0) { - D_8018BB0C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c b/src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c new file mode 100644 index 000000000..4259d151e --- /dev/null +++ b/src/ov_SC05_010/ov_SC05_010_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018AED8; +extern u8 D_8018AE48; +extern u8 D_8018AE24; +extern u8 D_8018AE00; +extern u8 D_8018AEB4; +extern u8 D_8018AE90; +extern u8 D_8018AE6C; +extern u8 D_8018ADDC; +extern void func_80145934(void); +extern u8 D_8018AF68; +extern u8 D_8018AF44; +extern u8 D_8018AF20; +extern u8 D_8018AEFC; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018A360[]; +extern unsigned char D_8018A390[]; +extern unsigned char D_8018A3E0[]; +extern unsigned char D_8018A410[]; +extern unsigned char D_8018A440[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018A490[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018A558[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018A5E0[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018A5E8; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801C5D38; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801C5D3C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018A618; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018A6C0[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018A6E4[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018A6D4; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018A6F8[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018A704[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018A714[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018A72C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018A71C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018A740[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018A75C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018A74C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018A770[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018A784[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018A798; +extern void (*D_8018A7C0[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018A7A0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018A80C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018A810[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018AC74[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018AC84[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801C5D70; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018ACAC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018AC8C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018AC9C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018ACEC[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018ACF4[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018ACC0; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018AD00[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018ACD0; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801C5D78; +extern s32 D_801C5D84; +extern s32 D_801C5D88; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018AD3C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018AD10[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801C5D80; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018AF8C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018ADAC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018B030[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018B184[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018AFA0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018B18C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018AFB0; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018AFD0; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018B194[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018B1BC[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018B03C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018B1C8[])(void); + +void func_8015C714(void *a0) { + D_8018B1C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018B03C[])(void*); + extern int D_8018AFE0; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018B03C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018B03C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018AFE0); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018B03C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018B03C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018B03C[])(void*); + extern int D_8018AFE0; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018B03C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018AFE0); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018B03C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018B1D8[])(void); + D_8018B1D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018B03C[])(struct Ent_8015CD20 *); + extern u8 D_8018AFF0; + extern u8 D_8018B1E0; + extern u8 D_8018B1F0; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018B03C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AFF0); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018B1E0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018B1F0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018B03C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018B210[])(void); + D_8018B210[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018B200; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018B200 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018B03C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018B26C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018B26C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018A350[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018A350; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018B274[])(void); + D_8018B274[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018B280[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018B280[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018B280[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018B280[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018B03C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018B280[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018B000[]; + extern u8 D_8018B010[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018B000); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018B010); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018B280[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018B280[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018B280[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018B2B4[])(void); + D_8018B2B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018B03C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018B2BC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018B2D4[])(void); + D_8018B2D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018B03C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018B2BC[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018B2BC[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018B2F4[])(void); + D_8018B2F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018B03C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018B03C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018B304; +extern u16 D_8018B306; +extern u16 D_8018B308; +extern s32 D_8018B30C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018B304 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018B306 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018B308 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018B30C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018B314; + +void func_8015E588(void) { + func_8013C9C4(&D_8018B314); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018B03C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018B03C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018B328[])(void); + D_8018B328[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018B03C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018B03C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018B330[])(void); + D_8018B330[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018B020; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018B020); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018B03C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018B338[])(void); + D_8018B338[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018B03C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018B03C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018B340[])(void); + D_8018B340[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018B03C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018B348; + extern s32 D_8018B358; + extern s32 D_8018B368; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018B348); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018B358); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018B03C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018B368); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018B378[])(void); + D_8018B378[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018B03C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018B03C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018B03C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018B03C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018B384[])(void); + D_8018B384[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018B03C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018B03C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018B03C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018B03C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018B398[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018B398[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018B03C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018B03C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018B03C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018B03C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018B414[])(void); + D_8018B414[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018B03C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018B03C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018B424[])(void); + D_8018B424[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018B03C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018B03C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018B03C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018B03C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018B03C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018B03C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018B03C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018B42C[])(void); + D_8018B42C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018B03C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018B03C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018B03C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018B03C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018B438[])(void); + D_8018B438[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018B03C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018B03C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018B03C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018B03C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018B448[])(void); + +void func_80160EA4(void *a0) { + D_8018B448[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018B03C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018B03C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018B478[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018B478[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018B4DC; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018B4DC); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801C5D90[]; + extern u8 D_8018B4A8[]; + extern u8 D_8018B4C8[]; + extern u8 D_801C5D9C[]; + extern u8 D_801C5DC4[]; + extern u8 D_801C5DDC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801C5D90[0] = p; + func_80024054(&D_8018B4A8, &D_801C5D9C); + func_8001CE28(p, &D_801C5D9C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801C5D90[1] = p; + func_80024054(&D_8018B4C8, &D_801C5DC4); + func_8001CE28(p, &D_801C5DC4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801C5D90[2] = p; + func_800242D0((s16)func_801620C4(), &D_801C5DDC, 0x84); + func_8001CE68(p, &D_801C5DDC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801C5DDC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C5D90[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801C5D90; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018B4DC; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018B4DC; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018B4DC; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018B4DC; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801C5D90[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801C5D90; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018B500[])(void); + +void func_80162330(void *a0) { + D_8018B500[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801C5DE8[i] via `extern int D_801C5DE8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018B50C[]; + extern s32 D_8018B524; + extern u8 D_801C5DF4[]; + extern u8 D_801C5E1C[]; + extern u8 D_801C5E38[]; + extern int D_801C5DE8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801C5DE8[0] = (s32)item; + func_80024054(D_8018B50C, D_801C5DF4); + func_8001CE28(item, D_801C5DF4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801C5DE8[1] = (s32)item; + func_80024054(((u8 *)&D_8018B524), D_801C5E1C); + func_8001CE28(item, D_801C5E1C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801C5DE8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801C5E38, 0x84); + func_8001CE68(item, D_801C5E38); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801C5E38, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801C5DE8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801C5DE8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_801627E8); + + +extern void (*D_8018B548[])(void); + +void func_80162834(void *a0) { + D_8018B548[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018B538; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018B538, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801C5444[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801C5444, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801C5444[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801C5444, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018B550[])(void); + +void func_80163A58(void *a0) { + D_8018B550[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801C544C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801C544C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018B5A4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018B5A4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018B56C; +extern s16 D_8018B5A0; +extern s16 D_8018B59E; +extern s16 D_8018B59C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018B56C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018B5A0 = 0x80; + D_8018B59E = 0x80; + D_8018B59C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018B5A0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018B5A0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018B5A0 - 8; + D_8018B5A0 = nv; + D_8018B59E = nv; + D_8018B59C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018B5B0[])(void); + +void func_80164BA0(void *a0) { + D_8018B5B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801C5E48; +extern u8 D_801C5E49; +extern u8 D_801C5E4A; +extern u8 D_801C5E4B; +extern u8 D_801C5E4C; +extern u8 D_801C5E4D; +extern u8 D_801C5E4E; +extern u8 D_801C5E4F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801C5E48; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801C5E49 = 0xf0; + *(u8 *)base = 0xf0; + D_801C5E4A = 0xc0; + D_801C5E4E = 0; + D_801C5E4D = 0; + D_801C5E4C = 0; + D_801C5E4F = 0; + D_801C5E4B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801C5E48; +extern u8 D_801C5E49; +extern u8 D_801C5E4A; + +s32 func_80164E40(void) { + u8 *p = &D_801C5E48; + if (*p != 0) { + *p -= 0x10; + } + if (D_801C5E49 != 0) { + D_801C5E49 -= 0x10; + } + if (D_801C5E4A != 0) { + D_801C5E4A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018B5C0[])(void); + +void func_80164EA4(void *a0) { + D_8018B5C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801C5E94[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801C5E94[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801C5E88[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801C5E88[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801C5E88[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801C5E88; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801C5E88; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018B5D4[]; + extern u32 D_8018B5F4, D_8018B5F8, D_8018B5FC, D_8018B600; + extern u32 D_8018B5F4, D_8018B5F8, D_8018B5FC, D_8018B600; + extern u32 D_8018B5F4, D_8018B5F8, D_8018B5FC, D_8018B600; + extern u32 D_8018B5F4, D_8018B5F8, D_8018B5FC, D_8018B600; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018B5D4[0x00], p); + ApplyMatrixSV(mat, &D_8018B5D4[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018B5D4[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018B5D4[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018B5FC; + *(u32 *)(prim + 0x24) = D_8018B5F4; + *(u32 *)(prim + 0x28) = D_8018B600; + *(u32 *)(prim + 0x2c) = D_8018B5F8; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018B604[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018B604[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018B604[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018B604[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018B680[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018B680[a1 & 0x7F]; +} + + + +extern s32 D_8018B6A0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018B6A0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018B71C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018B71C[a1 & 0x7F]; +} + + + +extern u8 D_8018B73C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018B73C[a1 & 0x7F]; +} + + + +extern u8 D_8018B75C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018B75C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018B77C[])(void); + D_8018B77C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018B7F8[])(void); + +void func_80165AC8(void) { + D_8018B7F8[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018B874[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018B874[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801C5454; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801C5454, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018B880[])(void); + +void func_80166018(void *a0) { + D_8018B880[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018B888[])(void); + +void func_801663FC(void *a0) { + D_8018B888[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018B950[])(void); + +void func_80166618(void *a0) { + D_8018B950[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018B960[])(void); + +void func_80166654(void *a0) { + D_8018B960[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801C5F08[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801C5F08[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801C5F08). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801C5F08[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801C5F08)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801C5F08[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801C5F08[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018B8A4[]; + extern u8 D_8018B890[]; + extern u8 D_8018B8B8[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018B8A4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018B890; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018B8B8; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80167714); + + +extern void (*D_8018B970[])(void); + +void func_801678B4(void *a0) { + D_8018B970[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018B97C[])(void); + +void func_80167A9C(void *a0) { + D_8018B97C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018BA88; + extern u8 D_8018BA9C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018BA88); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018BA9C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018B8DC[]; +extern u8 D_8018B8F0[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018B8DC; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018B8F0; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018B994[])(void); + +void func_80168744(void *a0) { + D_8018B994[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018B984 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018B984[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018B984; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018B99C[])(void); + +void func_801689D8(void *a0) { + D_8018B99C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018B9A4[])(void); + +void func_80168AA8(void *a0) { + D_8018B9A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018B9AC[])(void); + +void func_80168D58(void *a0) { + D_8018B9AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018B9B4[])(void); + +void func_8016901C(void *a0) { + D_8018B9B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_010/nonmatchings/ov_SC05_010_jr_8015C32C", func_80169228); + + +extern void (*D_8018B9BC[])(void); + +void func_801693CC(void *a0) { + D_8018B9BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018B9C4[])(void); + +void func_80169830(void *a0) { + D_8018B9C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018BA78[])(void); + +void func_80169B80(void *a0) { + D_8018BA78[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018B9CC[]; + extern u8 D_8018BA3C[]; + extern u8 D_8018BA6C[]; + extern u8 D_801C7EE8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018BA6C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018B9CC[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801C7EE8; + RotMatrixYXZ(rot, D_801C7EE8); + func_80048D9C(D_801C7EE8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018BA3C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018BA80[])(void); + +void func_80169F00(void *a0) { + D_8018BA80[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018BA30[]; +extern char D_8018B9F0[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018BA30, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018B9F0); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018BAB8[])(void); + +void func_8016A020(void *a0) { + D_8018BAB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018BA88; + extern u8 D_8018BA9C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018BA88); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018BA9C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018BAC4[])(void); + +void func_8016A700(void *a0) { + D_8018BAC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018BB0C[])(void); + +void func_8016AB30(void *a0) { + D_8018BB0C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_011/ov_SC05_011_jr_8015AE2C.c b/src/ov_SC05_011/ov_SC05_011_jr_8015AE2C.c index 0ad9643ad..85c2b2fd3 100644 --- a/src/ov_SC05_011/ov_SC05_011_jr_8015AE2C.c +++ b/src/ov_SC05_011/ov_SC05_011_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80180540[])(void); - -void func_8015C714(void *a0) { - D_80180540[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801803B4[])(void*); - extern int D_80180358; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801803B4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801803B4)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180358); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801803B4[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801803B4[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801803B4[])(void*); - extern int D_80180358; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801803B4)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180358); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801803B4)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80180550[])(void); - D_80180550[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801803B4[])(struct Ent_8015CD20 *); - extern u8 D_80180368; - extern u8 D_80180558; - extern u8 D_80180568; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801803B4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180368); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180558); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180568); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801803B4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80180588[])(void); - D_80180588[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80180578; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80180578 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801803B4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801805E4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801805E4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8017F6C8[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8017F6C8; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801805EC[])(void); - D_801805EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801805F8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801805F8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801805F8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801805F8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801803B4[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801805F8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80180378[]; - extern u8 D_80180388[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80180378); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80180388); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801805F8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801805F8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801805F8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018062C[])(void); - D_8018062C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801803B4[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180634[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018064C[])(void); - D_8018064C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801803B4[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80180634[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018066C[])(void); - D_8018066C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801803B4[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801803B4)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018067C; -extern u16 D_8018067E; -extern u16 D_80180680; -extern s32 D_80180684; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018067C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018067E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80180680 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180684, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018068C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018068C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801803B4[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801803B4)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801806A0[])(void); - D_801806A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801803B4[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801803B4[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801806A8[])(void); - D_801806A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80180398; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80180398); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801803B4[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801806B0[])(void); - D_801806B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801803B4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801803B4[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801806B8[])(void); - D_801806B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801803B4[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801806C0; - extern s32 D_801806D0; - extern s32 D_801806E0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801803B4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801806C0); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801806D0); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801803B4[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801806E0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801806F0[])(void); - D_801806F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801803B4[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801803B4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801803B4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801803B4[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801806FC[])(void); - D_801806FC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801803B4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801803B4[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801803B4[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801803B4[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80180710[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80180710[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801803B4[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801803B4)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801803B4[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801803B4[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018078C[])(void); - D_8018078C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801803B4[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801803B4)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018079C[])(void); - D_8018079C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801803B4[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801803B4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801803B4[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801803B4[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801803B4[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801803B4[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801803B4[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801807A4[])(void); - D_801807A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801803B4[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801803B4)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801803B4[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801803B4)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801807B0[])(void); - D_801807B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801803B4 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801803B4[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801803B4[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801803B4[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801807C0[])(void); - -void func_80160EA4(void *a0) { - D_801807C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801803B4[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801803B4[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801807F0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801807F0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80180854; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80180854); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019BF18[]; - extern u8 D_80180820[]; - extern u8 D_80180840[]; - extern u8 D_8019BF24[]; - extern u8 D_8019BF4C[]; - extern u8 D_8019BF64[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019BF18[0] = p; - func_80024054(&D_80180820, &D_8019BF24); - func_8001CE28(p, &D_8019BF24); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019BF18[1] = p; - func_80024054(&D_80180840, &D_8019BF4C); - func_8001CE28(p, &D_8019BF4C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019BF18[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019BF64, 0x84); - func_8001CE68(p, &D_8019BF64); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019BF64, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019BF18[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019BF18; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80180854; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80180854; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80180854; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80180854; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019BF18[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019BF18; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80180878[])(void); - -void func_80162330(void *a0) { - D_80180878[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019BF70[i] via `extern int D_8019BF70[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80180884[]; - extern s32 D_8018089C; - extern u8 D_8019BF7C[]; - extern u8 D_8019BFA4[]; - extern u8 D_8019BFC0[]; - extern int D_8019BF70[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019BF70[0] = (s32)item; - func_80024054(D_80180884, D_8019BF7C); - func_8001CE28(item, D_8019BF7C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019BF70[1] = (s32)item; - func_80024054(((u8 *)&D_8018089C), D_8019BFA4); - func_8001CE28(item, D_8019BFA4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019BF70[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019BFC0, 0x84); - func_8001CE68(item, D_8019BFC0); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019BFC0, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019BF70[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019BF70; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_801627E8); - - -extern void (*D_801808C0[])(void); - -void func_80162834(void *a0) { - D_801808C0[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801808B0; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801808B0, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019B7A8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019B7A8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019B7A8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019B7A8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801808C8[])(void); - -void func_80163A58(void *a0) { - D_801808C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019B7B0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019B7B0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018091C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018091C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801808E4; -extern s16 D_80180918; -extern s16 D_80180916; -extern s16 D_80180914; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801808E4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80180918 = 0x80; - D_80180916 = 0x80; - D_80180914 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80180918 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180918` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80180918 - 8; - D_80180918 = nv; - D_80180916 = nv; - D_80180914 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80180928[])(void); - -void func_80164BA0(void *a0) { - D_80180928[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019BFD0; -extern u8 D_8019BFD1; -extern u8 D_8019BFD2; -extern u8 D_8019BFD3; -extern u8 D_8019BFD4; -extern u8 D_8019BFD5; -extern u8 D_8019BFD6; -extern u8 D_8019BFD7; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019BFD0; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019BFD1 = 0xf0; - *(u8 *)base = 0xf0; - D_8019BFD2 = 0xc0; - D_8019BFD6 = 0; - D_8019BFD5 = 0; - D_8019BFD4 = 0; - D_8019BFD7 = 0; - D_8019BFD3 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019BFD0; -extern u8 D_8019BFD1; -extern u8 D_8019BFD2; - -s32 func_80164E40(void) { - u8 *p = &D_8019BFD0; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019BFD1 != 0) { - D_8019BFD1 -= 0x10; - } - if (D_8019BFD2 != 0) { - D_8019BFD2 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80180938[])(void); - -void func_80164EA4(void *a0) { - D_80180938[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019C01C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019C01C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019C010[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019C010[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019C010[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019C010; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019C010; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018094C[]; - extern u32 D_8018096C, D_80180970, D_80180974, D_80180978; - extern u32 D_8018096C, D_80180970, D_80180974, D_80180978; - extern u32 D_8018096C, D_80180970, D_80180974, D_80180978; - extern u32 D_8018096C, D_80180970, D_80180974, D_80180978; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018094C[0x00], p); - ApplyMatrixSV(mat, &D_8018094C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018094C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018094C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80180974; - *(u32 *)(prim + 0x24) = D_8018096C; - *(u32 *)(prim + 0x28) = D_80180978; - *(u32 *)(prim + 0x2c) = D_80180970; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018097C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018097C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018097C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018097C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801809F8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801809F8[a1 & 0x7F]; -} - - - -extern s32 D_80180A18[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80180A18[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80180A94[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80180A94[a1 & 0x7F]; -} - - - -extern u8 D_80180AB4[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80180AB4[a1 & 0x7F]; -} - - - -extern u8 D_80180AD4[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80180AD4[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80180AF4[])(void); - D_80180AF4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80180B70[])(void); - -void func_80165AC8(void) { - D_80180B70[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80180BEC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80180BEC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019B7B8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019B7B8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80180BF8[])(void); - -void func_80166018(void *a0) { - D_80180BF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80180C00[])(void); - -void func_801663FC(void *a0) { - D_80180C00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80180CC8[])(void); - -void func_80166618(void *a0) { - D_80180CC8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80180CD8[])(void); - -void func_80166654(void *a0) { - D_80180CD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019C090[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019C090[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019C090). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019C090[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019C090)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019C090[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019C090[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80180C1C[]; - extern u8 D_80180C08[]; - extern u8 D_80180C30[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80180C1C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80180C08; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80180C30; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80167714); - - -extern void (*D_80180CE8[])(void); - -void func_801678B4(void *a0) { - D_80180CE8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80180CF4[])(void); - -void func_80167A9C(void *a0) { - D_80180CF4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80180E00; - extern u8 D_80180E14[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80180E00); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80180E14; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80180C54[]; -extern u8 D_80180C68[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80180C54; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80180C68; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80180D0C[])(void); - -void func_80168744(void *a0) { - D_80180D0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80180CFC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80180CFC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80180CFC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80180D14[])(void); - -void func_801689D8(void *a0) { - D_80180D14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80180D1C[])(void); - -void func_80168AA8(void *a0) { - D_80180D1C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80180D24[])(void); - -void func_80168D58(void *a0) { - D_80180D24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80180D2C[])(void); - -void func_8016901C(void *a0) { - D_80180D2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015AE2C", func_80169228); - - -extern void (*D_80180D34[])(void); - -void func_801693CC(void *a0) { - D_80180D34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80180D3C[])(void); - -void func_80169830(void *a0) { - D_80180D3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80180DF0[])(void); - -void func_80169B80(void *a0) { - D_80180DF0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80180D44[]; - extern u8 D_80180DB4[]; - extern u8 D_80180DE4[]; - extern u8 D_8019D098[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80180DE4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80180D44[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019D098; - RotMatrixYXZ(rot, D_8019D098); - func_80048D9C(D_8019D098, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80180DB4); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80180DF8[])(void); - -void func_80169F00(void *a0) { - D_80180DF8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80180DA8[]; -extern char D_80180D68[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80180DA8, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80180D68); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80180E30[])(void); - -void func_8016A020(void *a0) { - D_80180E30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80180E00; - extern u8 D_80180E14[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80180E00); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80180E14; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80180E3C[])(void); - -void func_8016A700(void *a0) { - D_80180E3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80180E84[])(void); - -void func_8016AB30(void *a0) { - D_80180E84[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c b/src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c new file mode 100644 index 000000000..d3700b55c --- /dev/null +++ b/src/ov_SC05_011/ov_SC05_011_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180250; +extern u8 D_801801C0; +extern u8 D_8018019C; +extern u8 D_80180178; +extern u8 D_8018022C; +extern u8 D_80180208; +extern u8 D_801801E4; +extern u8 D_80180154; +extern void func_80145934(void); +extern u8 D_801802E0; +extern u8 D_801802BC; +extern u8 D_80180298; +extern u8 D_80180274; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8017F6D8[]; +extern unsigned char D_8017F708[]; +extern unsigned char D_8017F758[]; +extern unsigned char D_8017F788[]; +extern unsigned char D_8017F7B8[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8017F808[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8017F8D0[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8017F958[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8017F960; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019BEC0; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019BEC4; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8017F990; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8017FA38[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8017FA5C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8017FA4C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8017FA70[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8017FA7C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8017FA8C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8017FAA4[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8017FA94; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8017FAB8[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8017FAD4[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8017FAC4; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8017FAE8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8017FAFC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8017FB10; +extern void (*D_8017FB38[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8017FB18; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8017FB84[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8017FB88[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8017FFEC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8017FFFC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019BEF8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180024[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180004; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180014; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180064[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018006C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180038; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80180078[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180048; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019BF00; +extern s32 D_8019BF0C; +extern s32 D_8019BF10; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801800B4[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80180088[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019BF08; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80180304[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180124[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801803A8[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801804FC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80180318; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80180504[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80180328; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80180348; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018050C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80180534[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801803B4[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80180540[])(void); + +void func_8015C714(void *a0) { + D_80180540[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801803B4[])(void*); + extern int D_80180358; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801803B4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801803B4)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180358); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801803B4[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801803B4[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801803B4[])(void*); + extern int D_80180358; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801803B4)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80180358); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801803B4)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80180550[])(void); + D_80180550[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801803B4[])(struct Ent_8015CD20 *); + extern u8 D_80180368; + extern u8 D_80180558; + extern u8 D_80180568; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801803B4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180368); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180558); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80180568); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801803B4[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80180588[])(void); + D_80180588[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80180578; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80180578 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801803B4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801805E4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801805E4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8017F6C8[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8017F6C8; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801805EC[])(void); + D_801805EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801805F8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801805F8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801805F8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801805F8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801803B4[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801805F8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80180378[]; + extern u8 D_80180388[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80180378); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80180388); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801805F8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801805F8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801805F8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018062C[])(void); + D_8018062C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801803B4[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180634[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018064C[])(void); + D_8018064C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801803B4[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80180634[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80180634[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018066C[])(void); + D_8018066C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801803B4[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801803B4)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018067C; +extern u16 D_8018067E; +extern u16 D_80180680; +extern s32 D_80180684; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018067C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018067E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80180680 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80180684, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018068C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018068C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801803B4[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801803B4)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801806A0[])(void); + D_801806A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801803B4[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801803B4[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801806A8[])(void); + D_801806A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80180398; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80180398); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801803B4[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801806B0[])(void); + D_801806B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801803B4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801803B4[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801806B8[])(void); + D_801806B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801803B4[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801806C0; + extern s32 D_801806D0; + extern s32 D_801806E0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801806C0); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801806D0); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801803B4[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801806E0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801806F0[])(void); + D_801806F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801803B4[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801803B4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801803B4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801803B4[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801806FC[])(void); + D_801806FC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801803B4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801803B4[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801803B4[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801803B4[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80180710[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80180710[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801803B4[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801803B4)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801803B4[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801803B4[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018078C[])(void); + D_8018078C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801803B4[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801803B4)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018079C[])(void); + D_8018079C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801803B4[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801803B4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801803B4[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801803B4[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801803B4[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801803B4[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801803B4[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801807A4[])(void); + D_801807A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801803B4[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801803B4)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801803B4[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801803B4)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801807B0[])(void); + D_801807B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801803B4 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801803B4[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801803B4[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801803B4[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801807C0[])(void); + +void func_80160EA4(void *a0) { + D_801807C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801803B4[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801803B4[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801807F0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801807F0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80180854; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80180854); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019BF18[]; + extern u8 D_80180820[]; + extern u8 D_80180840[]; + extern u8 D_8019BF24[]; + extern u8 D_8019BF4C[]; + extern u8 D_8019BF64[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019BF18[0] = p; + func_80024054(&D_80180820, &D_8019BF24); + func_8001CE28(p, &D_8019BF24); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019BF18[1] = p; + func_80024054(&D_80180840, &D_8019BF4C); + func_8001CE28(p, &D_8019BF4C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019BF18[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019BF64, 0x84); + func_8001CE68(p, &D_8019BF64); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019BF64, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019BF18[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019BF18; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80180854; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80180854; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80180854; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80180854; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019BF18[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019BF18; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80180878[])(void); + +void func_80162330(void *a0) { + D_80180878[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019BF70[i] via `extern int D_8019BF70[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80180884[]; + extern s32 D_8018089C; + extern u8 D_8019BF7C[]; + extern u8 D_8019BFA4[]; + extern u8 D_8019BFC0[]; + extern int D_8019BF70[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019BF70[0] = (s32)item; + func_80024054(D_80180884, D_8019BF7C); + func_8001CE28(item, D_8019BF7C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019BF70[1] = (s32)item; + func_80024054(((u8 *)&D_8018089C), D_8019BFA4); + func_8001CE28(item, D_8019BFA4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019BF70[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019BFC0, 0x84); + func_8001CE68(item, D_8019BFC0); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019BFC0, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019BF70[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019BF70; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_801627E8); + + +extern void (*D_801808C0[])(void); + +void func_80162834(void *a0) { + D_801808C0[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801808B0; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801808B0, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019B7A8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019B7A8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019B7A8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019B7A8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801808C8[])(void); + +void func_80163A58(void *a0) { + D_801808C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019B7B0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019B7B0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018091C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018091C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801808E4; +extern s16 D_80180918; +extern s16 D_80180916; +extern s16 D_80180914; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801808E4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80180918 = 0x80; + D_80180916 = 0x80; + D_80180914 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80180918 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80180918` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80180918 - 8; + D_80180918 = nv; + D_80180916 = nv; + D_80180914 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80180928[])(void); + +void func_80164BA0(void *a0) { + D_80180928[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019BFD0; +extern u8 D_8019BFD1; +extern u8 D_8019BFD2; +extern u8 D_8019BFD3; +extern u8 D_8019BFD4; +extern u8 D_8019BFD5; +extern u8 D_8019BFD6; +extern u8 D_8019BFD7; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019BFD0; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019BFD1 = 0xf0; + *(u8 *)base = 0xf0; + D_8019BFD2 = 0xc0; + D_8019BFD6 = 0; + D_8019BFD5 = 0; + D_8019BFD4 = 0; + D_8019BFD7 = 0; + D_8019BFD3 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019BFD0; +extern u8 D_8019BFD1; +extern u8 D_8019BFD2; + +s32 func_80164E40(void) { + u8 *p = &D_8019BFD0; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019BFD1 != 0) { + D_8019BFD1 -= 0x10; + } + if (D_8019BFD2 != 0) { + D_8019BFD2 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80180938[])(void); + +void func_80164EA4(void *a0) { + D_80180938[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019C01C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019C01C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019C010[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019C010[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019C010[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019C010; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019C010; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018094C[]; + extern u32 D_8018096C, D_80180970, D_80180974, D_80180978; + extern u32 D_8018096C, D_80180970, D_80180974, D_80180978; + extern u32 D_8018096C, D_80180970, D_80180974, D_80180978; + extern u32 D_8018096C, D_80180970, D_80180974, D_80180978; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018094C[0x00], p); + ApplyMatrixSV(mat, &D_8018094C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018094C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018094C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80180974; + *(u32 *)(prim + 0x24) = D_8018096C; + *(u32 *)(prim + 0x28) = D_80180978; + *(u32 *)(prim + 0x2c) = D_80180970; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018097C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018097C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018097C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018097C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801809F8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801809F8[a1 & 0x7F]; +} + + + +extern s32 D_80180A18[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80180A18[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80180A94[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80180A94[a1 & 0x7F]; +} + + + +extern u8 D_80180AB4[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80180AB4[a1 & 0x7F]; +} + + + +extern u8 D_80180AD4[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80180AD4[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80180AF4[])(void); + D_80180AF4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80180B70[])(void); + +void func_80165AC8(void) { + D_80180B70[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80180BEC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80180BEC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019B7B8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019B7B8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80180BF8[])(void); + +void func_80166018(void *a0) { + D_80180BF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80180C00[])(void); + +void func_801663FC(void *a0) { + D_80180C00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80180CC8[])(void); + +void func_80166618(void *a0) { + D_80180CC8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80180CD8[])(void); + +void func_80166654(void *a0) { + D_80180CD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019C090[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019C090[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019C090). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019C090[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019C090)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019C090[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019C090[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80180C1C[]; + extern u8 D_80180C08[]; + extern u8 D_80180C30[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80180C1C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80180C08; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80180C30; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80167714); + + +extern void (*D_80180CE8[])(void); + +void func_801678B4(void *a0) { + D_80180CE8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80180CF4[])(void); + +void func_80167A9C(void *a0) { + D_80180CF4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80180E00; + extern u8 D_80180E14[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80180E00); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80180E14; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80180C54[]; +extern u8 D_80180C68[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80180C54; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80180C68; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80180D0C[])(void); + +void func_80168744(void *a0) { + D_80180D0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80180CFC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80180CFC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80180CFC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80180D14[])(void); + +void func_801689D8(void *a0) { + D_80180D14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80180D1C[])(void); + +void func_80168AA8(void *a0) { + D_80180D1C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80180D24[])(void); + +void func_80168D58(void *a0) { + D_80180D24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80180D2C[])(void); + +void func_8016901C(void *a0) { + D_80180D2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_011/nonmatchings/ov_SC05_011_jr_8015C32C", func_80169228); + + +extern void (*D_80180D34[])(void); + +void func_801693CC(void *a0) { + D_80180D34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80180D3C[])(void); + +void func_80169830(void *a0) { + D_80180D3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80180DF0[])(void); + +void func_80169B80(void *a0) { + D_80180DF0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80180D44[]; + extern u8 D_80180DB4[]; + extern u8 D_80180DE4[]; + extern u8 D_8019D098[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80180DE4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80180D44[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019D098; + RotMatrixYXZ(rot, D_8019D098); + func_80048D9C(D_8019D098, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80180DB4); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80180DF8[])(void); + +void func_80169F00(void *a0) { + D_80180DF8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80180DA8[]; +extern char D_80180D68[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80180DA8, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80180D68); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80180E30[])(void); + +void func_8016A020(void *a0) { + D_80180E30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80180E00; + extern u8 D_80180E14[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80180E00); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80180E14; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80180E3C[])(void); + +void func_8016A700(void *a0) { + D_80180E3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80180E84[])(void); + +void func_8016AB30(void *a0) { + D_80180E84[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_017/ov_SC05_017_jr_8015AE2C.c b/src/ov_SC05_017/ov_SC05_017_jr_8015AE2C.c index bcf3ad43f..40e1fe5b8 100644 --- a/src/ov_SC05_017/ov_SC05_017_jr_8015AE2C.c +++ b/src/ov_SC05_017/ov_SC05_017_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018FA00[])(void); - -void func_8015C714(void *a0) { - D_8018FA00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018F874[])(void*); - extern int D_8018F818; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018F874)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018F874)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F818); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018F874[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018F874[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018F874[])(void*); - extern int D_8018F818; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018F874)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F818); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018F874)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018FA10[])(void); - D_8018FA10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018F874[])(struct Ent_8015CD20 *); - extern u8 D_8018F828; - extern u8 D_8018FA18; - extern u8 D_8018FA28; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018F874[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F828); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA18); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA28); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018F874[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018FA48[])(void); - D_8018FA48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018FA38; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018FA38 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018F874[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018FAA4; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018FAA4, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018EB88[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018EB88; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018FAAC[])(void); - D_8018FAAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018FAB8[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018FAB8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018FAB8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018FAB8[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018F874[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018FAB8[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018F838[]; - extern u8 D_8018F848[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F838); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F848); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018FAB8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018FAB8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018FAB8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018FAEC[])(void); - D_8018FAEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018F874[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018FAF4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018FB0C[])(void); - D_8018FB0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018F874[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018FAF4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018FB2C[])(void); - D_8018FB2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018F874[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018F874)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018FB3C; -extern u16 D_8018FB3E; -extern u16 D_8018FB40; -extern s32 D_8018FB44; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018FB3C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018FB3E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018FB40 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018FB44, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018FB4C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018FB4C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018F874[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018F874)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018FB60[])(void); - D_8018FB60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018F874[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018F874[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018FB68[])(void); - D_8018FB68[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018F858; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018F858); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018F874[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018FB70[])(void); - D_8018FB70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018F874[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018F874[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018FB78[])(void); - D_8018FB78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018F874[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018FB80; - extern s32 D_8018FB90; - extern s32 D_8018FBA0; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018F874[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FB80); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FB90); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018F874[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBA0); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018FBB0[])(void); - D_8018FBB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018F874[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018F874[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018F874[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018F874[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018FBBC[])(void); - D_8018FBBC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018F874[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018F874[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018F874[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018F874[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018FBD0[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018FBD0[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018F874[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018F874)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018F874[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018F874[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018FC4C[])(void); - D_8018FC4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018F874[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018F874)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018FC5C[])(void); - D_8018FC5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018F874[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018F874[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018F874[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018F874[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018F874[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018F874[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018F874[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018FC64[])(void); - D_8018FC64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018F874[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018F874)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018F874[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018F874)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018FC70[])(void); - D_8018FC70[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018F874 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018F874[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018F874[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018F874[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018FC80[])(void); - -void func_80160EA4(void *a0) { - D_8018FC80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018F874[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018F874[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018FCB0[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018FCB0[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018FD14; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018FD14); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801EBA58[]; - extern u8 D_8018FCE0[]; - extern u8 D_8018FD00[]; - extern u8 D_801EBA64[]; - extern u8 D_801EBA8C[]; - extern u8 D_801EBAA4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801EBA58[0] = p; - func_80024054(&D_8018FCE0, &D_801EBA64); - func_8001CE28(p, &D_801EBA64); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801EBA58[1] = p; - func_80024054(&D_8018FD00, &D_801EBA8C); - func_8001CE28(p, &D_801EBA8C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801EBA58[2] = p; - func_800242D0((s16)func_801620C4(), &D_801EBAA4, 0x84); - func_8001CE68(p, &D_801EBAA4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801EBAA4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EBA58[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801EBA58; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018FD14; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018FD14; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018FD14; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018FD14; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801EBA58[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801EBA58; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018FD38[])(void); - -void func_80162330(void *a0) { - D_8018FD38[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801EBAB0[i] via `extern int D_801EBAB0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018FD44[]; - extern s32 D_8018FD5C; - extern u8 D_801EBABC[]; - extern u8 D_801EBAE4[]; - extern u8 D_801EBB00[]; - extern int D_801EBAB0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801EBAB0[0] = (s32)item; - func_80024054(D_8018FD44, D_801EBABC); - func_8001CE28(item, D_801EBABC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801EBAB0[1] = (s32)item; - func_80024054(((u8 *)&D_8018FD5C), D_801EBAE4); - func_8001CE28(item, D_801EBAE4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801EBAB0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801EBB00, 0x84); - func_8001CE68(item, D_801EBB00); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801EBB00, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801EBAB0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801EBAB0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018FD80[])(void); - -void func_80162834(void *a0) { - D_8018FD80[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018FD70; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018FD70, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801EAE90[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801EAE90, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801EAE90[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801EAE90, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018FD88[])(void); - -void func_80163A58(void *a0) { - D_8018FD88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801EAE98; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801EAE98; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018FDDC[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018FDDC[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018FDA4; -extern s16 D_8018FDD8; -extern s16 D_8018FDD6; -extern s16 D_8018FDD4; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018FDA4; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018FDD8 = 0x80; - D_8018FDD6 = 0x80; - D_8018FDD4 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018FDD8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018FDD8` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018FDD8 - 8; - D_8018FDD8 = nv; - D_8018FDD6 = nv; - D_8018FDD4 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018FDE8[])(void); - -void func_80164BA0(void *a0) { - D_8018FDE8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801EBB10; -extern u8 D_801EBB11; -extern u8 D_801EBB12; -extern u8 D_801EBB13; -extern u8 D_801EBB14; -extern u8 D_801EBB15; -extern u8 D_801EBB16; -extern u8 D_801EBB17; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801EBB10; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801EBB11 = 0xf0; - *(u8 *)base = 0xf0; - D_801EBB12 = 0xc0; - D_801EBB16 = 0; - D_801EBB15 = 0; - D_801EBB14 = 0; - D_801EBB17 = 0; - D_801EBB13 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801EBB10; -extern u8 D_801EBB11; -extern u8 D_801EBB12; - -s32 func_80164E40(void) { - u8 *p = &D_801EBB10; - if (*p != 0) { - *p -= 0x10; - } - if (D_801EBB11 != 0) { - D_801EBB11 -= 0x10; - } - if (D_801EBB12 != 0) { - D_801EBB12 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018FDF8[])(void); - -void func_80164EA4(void *a0) { - D_8018FDF8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801EBB5C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801EBB5C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801EBB50[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801EBB50[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801EBB50[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801EBB50; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801EBB50; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018FE0C[]; - extern u32 D_8018FE2C, D_8018FE30, D_8018FE34, D_8018FE38; - extern u32 D_8018FE2C, D_8018FE30, D_8018FE34, D_8018FE38; - extern u32 D_8018FE2C, D_8018FE30, D_8018FE34, D_8018FE38; - extern u32 D_8018FE2C, D_8018FE30, D_8018FE34, D_8018FE38; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018FE0C[0x00], p); - ApplyMatrixSV(mat, &D_8018FE0C[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018FE0C[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018FE0C[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018FE34; - *(u32 *)(prim + 0x24) = D_8018FE2C; - *(u32 *)(prim + 0x28) = D_8018FE38; - *(u32 *)(prim + 0x2c) = D_8018FE30; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018FE3C[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018FE3C[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018FE3C[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018FE3C[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018FEB8[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018FEB8[a1 & 0x7F]; -} - - - -extern s32 D_8018FED8[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018FED8[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018FF54[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018FF54[a1 & 0x7F]; -} - - - -extern u8 D_8018FF74[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018FF74[a1 & 0x7F]; -} - - - -extern u8 D_8018FF94[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018FF94[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018FFB4[])(void); - D_8018FFB4[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80190030[])(void); - -void func_80165AC8(void) { - D_80190030[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801900AC[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801900AC[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801EAEA0; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801EAEA0, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801900B8[])(void); - -void func_80166018(void *a0) { - D_801900B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801900C0[])(void); - -void func_801663FC(void *a0) { - D_801900C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80190188[])(void); - -void func_80166618(void *a0) { - D_80190188[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80190198[])(void); - -void func_80166654(void *a0) { - D_80190198[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801EBBD0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801EBBD0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EBBD0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801EBBD0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801EBBD0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801EBBD0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801EBBD0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801900DC[]; - extern u8 D_801900C8[]; - extern u8 D_801900F0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801900DC; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801900C8; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801900F0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80167714); - - -extern void (*D_801901A8[])(void); - -void func_801678B4(void *a0) { - D_801901A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801901B4[])(void); - -void func_80167A9C(void *a0) { - D_801901B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801902C0; - extern u8 D_801902D4[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801902C0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801902D4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80190114[]; -extern u8 D_80190128[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80190114; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80190128; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801901CC[])(void); - -void func_80168744(void *a0) { - D_801901CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801901BC differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801901BC[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801901BC; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801901D4[])(void); - -void func_801689D8(void *a0) { - D_801901D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801901DC[])(void); - -void func_80168AA8(void *a0) { - D_801901DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801901E4[])(void); - -void func_80168D58(void *a0) { - D_801901E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_801901EC[])(void); - -void func_8016901C(void *a0) { - D_801901EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015AE2C", func_80169228); - - -extern void (*D_801901F4[])(void); - -void func_801693CC(void *a0) { - D_801901F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_801901FC[])(void); - -void func_80169830(void *a0) { - D_801901FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801902B0[])(void); - -void func_80169B80(void *a0) { - D_801902B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80190204[]; - extern u8 D_80190274[]; - extern u8 D_801902A4[]; - extern u8 D_801ED818[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801902A4, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80190204[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801ED818; - RotMatrixYXZ(rot, D_801ED818); - func_80048D9C(D_801ED818, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80190274); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801902B8[])(void); - -void func_80169F00(void *a0) { - D_801902B8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80190268[]; -extern char D_80190228[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80190268, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80190228); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_801902F0[])(void); - -void func_8016A020(void *a0) { - D_801902F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801902C0; - extern u8 D_801902D4[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801902C0); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_801902D4; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_801902FC[])(void); - -void func_8016A700(void *a0) { - D_801902FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80190344[])(void); - -void func_8016AB30(void *a0) { - D_80190344[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c b/src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c new file mode 100644 index 000000000..3e7fc5580 --- /dev/null +++ b/src/ov_SC05_017/ov_SC05_017_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018F710; +extern u8 D_8018F680; +extern u8 D_8018F65C; +extern u8 D_8018F638; +extern u8 D_8018F6EC; +extern u8 D_8018F6C8; +extern u8 D_8018F6A4; +extern u8 D_8018F614; +extern void func_80145934(void); +extern u8 D_8018F7A0; +extern u8 D_8018F77C; +extern u8 D_8018F758; +extern u8 D_8018F734; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018EB98[]; +extern unsigned char D_8018EBC8[]; +extern unsigned char D_8018EC18[]; +extern unsigned char D_8018EC48[]; +extern unsigned char D_8018EC78[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018ECC8[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_8018ED90[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018EE18[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018EE20; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801EBA00; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801EBA04; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018EE50; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_8018EEF8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_8018EF1C[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_8018EF0C; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018EF30[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_8018EF3C[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_8018EF4C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018EF64[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018EF54; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018EF78[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018EF94[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018EF84; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018EFA8[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018EFBC[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018EFD0; +extern void (*D_8018EFF8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018EFD8; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018F044[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018F048[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018F4AC[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018F4BC[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801EBA38; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018F4E4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018F4C4; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018F4D4; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018F524[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018F52C[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018F4F8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018F538[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018F508; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801EBA40; +extern s32 D_801EBA4C; +extern s32 D_801EBA50; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018F574[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018F548[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801EBA48; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018F7C4[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018F5E4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018F868[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018F9BC[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018F7D8; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018F9C4[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018F7E8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018F808; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018F9CC[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018F9F4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018F874[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018FA00[])(void); + +void func_8015C714(void *a0) { + D_8018FA00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018F874[])(void*); + extern int D_8018F818; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018F874)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018F874)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F818); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018F874[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018F874[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018F874[])(void*); + extern int D_8018F818; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018F874)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018F818); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018F874)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018FA10[])(void); + D_8018FA10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018F874[])(struct Ent_8015CD20 *); + extern u8 D_8018F828; + extern u8 D_8018FA18; + extern u8 D_8018FA28; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018F874[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018F828); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA18); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018FA28); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018F874[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018FA48[])(void); + D_8018FA48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018FA38; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018FA38 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018F874[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018FAA4; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018FAA4, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018EB88[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018EB88; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018FAAC[])(void); + D_8018FAAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018FAB8[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018FAB8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018FAB8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018FAB8[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018F874[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018FAB8[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018F838[]; + extern u8 D_8018F848[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F838); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018F848); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018FAB8[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018FAB8[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018FAB8[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018FAEC[])(void); + D_8018FAEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018F874[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018FAF4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018FB0C[])(void); + D_8018FB0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018F874[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018FAF4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018FAF4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018FB2C[])(void); + D_8018FB2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018F874[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018F874)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018FB3C; +extern u16 D_8018FB3E; +extern u16 D_8018FB40; +extern s32 D_8018FB44; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018FB3C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018FB3E + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018FB40 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018FB44, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018FB4C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018FB4C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018F874[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018F874)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018FB60[])(void); + D_8018FB60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018F874[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018F874[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018FB68[])(void); + D_8018FB68[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018F858; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018F858); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018F874[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018FB70[])(void); + D_8018FB70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018F874[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018F874[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018FB78[])(void); + D_8018FB78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018F874[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018FB80; + extern s32 D_8018FB90; + extern s32 D_8018FBA0; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FB80); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FB90); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018F874[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018FBA0); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018FBB0[])(void); + D_8018FBB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018F874[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018F874[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018F874[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018F874[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018FBBC[])(void); + D_8018FBBC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018F874[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018F874[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018F874[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018F874[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018FBD0[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018FBD0[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018F874[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018F874)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018F874[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018F874[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018FC4C[])(void); + D_8018FC4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018F874[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018F874)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018FC5C[])(void); + D_8018FC5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018F874[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018F874[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018F874[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018F874[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018F874[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018F874[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018F874[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018FC64[])(void); + D_8018FC64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018F874[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018F874)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018F874[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018F874)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018FC70[])(void); + D_8018FC70[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018F874 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018F874[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018F874[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018F874[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018FC80[])(void); + +void func_80160EA4(void *a0) { + D_8018FC80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018F874[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018F874[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018FCB0[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018FCB0[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018FD14; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018FD14); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801EBA58[]; + extern u8 D_8018FCE0[]; + extern u8 D_8018FD00[]; + extern u8 D_801EBA64[]; + extern u8 D_801EBA8C[]; + extern u8 D_801EBAA4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801EBA58[0] = p; + func_80024054(&D_8018FCE0, &D_801EBA64); + func_8001CE28(p, &D_801EBA64); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801EBA58[1] = p; + func_80024054(&D_8018FD00, &D_801EBA8C); + func_8001CE28(p, &D_801EBA8C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801EBA58[2] = p; + func_800242D0((s16)func_801620C4(), &D_801EBAA4, 0x84); + func_8001CE68(p, &D_801EBAA4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801EBAA4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EBA58[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801EBA58; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018FD14; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018FD14; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018FD14; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018FD14; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801EBA58[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801EBA58; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018FD38[])(void); + +void func_80162330(void *a0) { + D_8018FD38[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801EBAB0[i] via `extern int D_801EBAB0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018FD44[]; + extern s32 D_8018FD5C; + extern u8 D_801EBABC[]; + extern u8 D_801EBAE4[]; + extern u8 D_801EBB00[]; + extern int D_801EBAB0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801EBAB0[0] = (s32)item; + func_80024054(D_8018FD44, D_801EBABC); + func_8001CE28(item, D_801EBABC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801EBAB0[1] = (s32)item; + func_80024054(((u8 *)&D_8018FD5C), D_801EBAE4); + func_8001CE28(item, D_801EBAE4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801EBAB0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801EBB00, 0x84); + func_8001CE68(item, D_801EBB00); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801EBB00, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801EBAB0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801EBAB0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_801627E8); + + +extern void (*D_8018FD80[])(void); + +void func_80162834(void *a0) { + D_8018FD80[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018FD70; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018FD70, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801EAE90[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801EAE90, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801EAE90[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801EAE90, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018FD88[])(void); + +void func_80163A58(void *a0) { + D_8018FD88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801EAE98; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801EAE98; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018FDDC[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018FDDC[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018FDA4; +extern s16 D_8018FDD8; +extern s16 D_8018FDD6; +extern s16 D_8018FDD4; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018FDA4; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018FDD8 = 0x80; + D_8018FDD6 = 0x80; + D_8018FDD4 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018FDD8 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018FDD8` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018FDD8 - 8; + D_8018FDD8 = nv; + D_8018FDD6 = nv; + D_8018FDD4 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018FDE8[])(void); + +void func_80164BA0(void *a0) { + D_8018FDE8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801EBB10; +extern u8 D_801EBB11; +extern u8 D_801EBB12; +extern u8 D_801EBB13; +extern u8 D_801EBB14; +extern u8 D_801EBB15; +extern u8 D_801EBB16; +extern u8 D_801EBB17; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801EBB10; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801EBB11 = 0xf0; + *(u8 *)base = 0xf0; + D_801EBB12 = 0xc0; + D_801EBB16 = 0; + D_801EBB15 = 0; + D_801EBB14 = 0; + D_801EBB17 = 0; + D_801EBB13 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801EBB10; +extern u8 D_801EBB11; +extern u8 D_801EBB12; + +s32 func_80164E40(void) { + u8 *p = &D_801EBB10; + if (*p != 0) { + *p -= 0x10; + } + if (D_801EBB11 != 0) { + D_801EBB11 -= 0x10; + } + if (D_801EBB12 != 0) { + D_801EBB12 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018FDF8[])(void); + +void func_80164EA4(void *a0) { + D_8018FDF8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801EBB5C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801EBB5C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801EBB50[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801EBB50[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801EBB50[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801EBB50; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801EBB50; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018FE0C[]; + extern u32 D_8018FE2C, D_8018FE30, D_8018FE34, D_8018FE38; + extern u32 D_8018FE2C, D_8018FE30, D_8018FE34, D_8018FE38; + extern u32 D_8018FE2C, D_8018FE30, D_8018FE34, D_8018FE38; + extern u32 D_8018FE2C, D_8018FE30, D_8018FE34, D_8018FE38; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018FE0C[0x00], p); + ApplyMatrixSV(mat, &D_8018FE0C[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018FE0C[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018FE0C[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018FE34; + *(u32 *)(prim + 0x24) = D_8018FE2C; + *(u32 *)(prim + 0x28) = D_8018FE38; + *(u32 *)(prim + 0x2c) = D_8018FE30; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018FE3C[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018FE3C[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018FE3C[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018FE3C[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018FEB8[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018FEB8[a1 & 0x7F]; +} + + + +extern s32 D_8018FED8[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018FED8[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018FF54[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018FF54[a1 & 0x7F]; +} + + + +extern u8 D_8018FF74[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018FF74[a1 & 0x7F]; +} + + + +extern u8 D_8018FF94[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018FF94[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018FFB4[])(void); + D_8018FFB4[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80190030[])(void); + +void func_80165AC8(void) { + D_80190030[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801900AC[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801900AC[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801EAEA0; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801EAEA0, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801900B8[])(void); + +void func_80166018(void *a0) { + D_801900B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801900C0[])(void); + +void func_801663FC(void *a0) { + D_801900C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80190188[])(void); + +void func_80166618(void *a0) { + D_80190188[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80190198[])(void); + +void func_80166654(void *a0) { + D_80190198[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801EBBD0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801EBBD0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801EBBD0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801EBBD0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801EBBD0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801EBBD0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801EBBD0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801900DC[]; + extern u8 D_801900C8[]; + extern u8 D_801900F0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801900DC; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801900C8; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801900F0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80167714); + + +extern void (*D_801901A8[])(void); + +void func_801678B4(void *a0) { + D_801901A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801901B4[])(void); + +void func_80167A9C(void *a0) { + D_801901B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801902C0; + extern u8 D_801902D4[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801902C0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801902D4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80190114[]; +extern u8 D_80190128[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80190114; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80190128; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801901CC[])(void); + +void func_80168744(void *a0) { + D_801901CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801901BC differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801901BC[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801901BC; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801901D4[])(void); + +void func_801689D8(void *a0) { + D_801901D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801901DC[])(void); + +void func_80168AA8(void *a0) { + D_801901DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801901E4[])(void); + +void func_80168D58(void *a0) { + D_801901E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_801901EC[])(void); + +void func_8016901C(void *a0) { + D_801901EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_017/nonmatchings/ov_SC05_017_jr_8015C32C", func_80169228); + + +extern void (*D_801901F4[])(void); + +void func_801693CC(void *a0) { + D_801901F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_801901FC[])(void); + +void func_80169830(void *a0) { + D_801901FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801902B0[])(void); + +void func_80169B80(void *a0) { + D_801902B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80190204[]; + extern u8 D_80190274[]; + extern u8 D_801902A4[]; + extern u8 D_801ED818[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801902A4, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80190204[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801ED818; + RotMatrixYXZ(rot, D_801ED818); + func_80048D9C(D_801ED818, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80190274); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801902B8[])(void); + +void func_80169F00(void *a0) { + D_801902B8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80190268[]; +extern char D_80190228[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80190268, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80190228); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_801902F0[])(void); + +void func_8016A020(void *a0) { + D_801902F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801902C0; + extern u8 D_801902D4[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801902C0); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_801902D4; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_801902FC[])(void); + +void func_8016A700(void *a0) { + D_801902FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80190344[])(void); + +void func_8016AB30(void *a0) { + D_80190344[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_018/ov_SC05_018_jr_8015AE2C.c b/src/ov_SC05_018/ov_SC05_018_jr_8015AE2C.c index b646a2bc5..2e0fb04b3 100644 --- a/src/ov_SC05_018/ov_SC05_018_jr_8015AE2C.c +++ b/src/ov_SC05_018/ov_SC05_018_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018915C[])(void); - -void func_8015C714(void *a0) { - D_8018915C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80188FD0[])(void*); - extern int D_80188F74; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80188FD0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80188FD0)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188F74); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80188FD0[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80188FD0[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80188FD0[])(void*); - extern int D_80188F74; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80188FD0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188F74); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80188FD0)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018916C[])(void); - D_8018916C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80188FD0[])(struct Ent_8015CD20 *); - extern u8 D_80188F84; - extern u8 D_80189174; - extern u8 D_80189184; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80188FD0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188F84); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189174); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189184); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80188FD0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801891A4[])(void); - D_801891A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80189194; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80189194 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80188FD0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80189200; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80189200, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801882E4[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801882E4; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80189208[])(void); - D_80189208[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80189214[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80189214[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80189214[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80189214[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80188FD0[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80189214[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80188F94[]; - extern u8 D_80188FA4[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188F94); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188FA4); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80189214[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80189214[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80189214[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80189248[])(void); - D_80189248[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188FD0[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80189250[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80189268[])(void); - D_80189268[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80188FD0[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80189250[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80189288[])(void); - D_80189288[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80188FD0[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188FD0)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80189298; -extern u16 D_8018929A; -extern u16 D_8018929C; -extern s32 D_801892A0; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80189298 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018929A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018929C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801892A0, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801892A8; - -void func_8015E588(void) { - func_8013C9C4(&D_801892A8); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80188FD0[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80188FD0)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801892BC[])(void); - D_801892BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80188FD0[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80188FD0[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801892C4[])(void); - D_801892C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80188FB4; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188FB4); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80188FD0[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801892CC[])(void); - D_801892CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80188FD0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80188FD0[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801892D4[])(void); - D_801892D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80188FD0[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801892DC; - extern s32 D_801892EC; - extern s32 D_801892FC; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80188FD0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801892DC); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801892EC); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80188FD0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801892FC); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018930C[])(void); - D_8018930C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80188FD0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80188FD0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80188FD0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80188FD0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80189318[])(void); - D_80189318[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80188FD0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80188FD0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80188FD0[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188FD0[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018932C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018932C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80188FD0[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80188FD0)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80188FD0[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80188FD0[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801893A8[])(void); - D_801893A8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80188FD0[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80188FD0)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801893B8[])(void); - D_801893B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80188FD0[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80188FD0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80188FD0[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80188FD0[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80188FD0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80188FD0[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80188FD0[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801893C0[])(void); - D_801893C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80188FD0[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80188FD0)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80188FD0[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80188FD0)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801893CC[])(void); - D_801893CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188FD0 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80188FD0[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80188FD0[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80188FD0[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801893DC[])(void); - -void func_80160EA4(void *a0) { - D_801893DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80188FD0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80188FD0[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018940C[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018940C[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80189470; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80189470); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801E5198[]; - extern u8 D_8018943C[]; - extern u8 D_8018945C[]; - extern u8 D_801E51A4[]; - extern u8 D_801E51CC[]; - extern u8 D_801E51E4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801E5198[0] = p; - func_80024054(&D_8018943C, &D_801E51A4); - func_8001CE28(p, &D_801E51A4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801E5198[1] = p; - func_80024054(&D_8018945C, &D_801E51CC); - func_8001CE28(p, &D_801E51CC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801E5198[2] = p; - func_800242D0((s16)func_801620C4(), &D_801E51E4, 0x84); - func_8001CE68(p, &D_801E51E4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801E51E4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E5198[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801E5198; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80189470; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80189470; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80189470; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80189470; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801E5198[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801E5198; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80189494[])(void); - -void func_80162330(void *a0) { - D_80189494[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801E51F0[i] via `extern int D_801E51F0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801894A0[]; - extern s32 D_801894B8; - extern u8 D_801E51FC[]; - extern u8 D_801E5224[]; - extern u8 D_801E5240[]; - extern int D_801E51F0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801E51F0[0] = (s32)item; - func_80024054(D_801894A0, D_801E51FC); - func_8001CE28(item, D_801E51FC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801E51F0[1] = (s32)item; - func_80024054(((u8 *)&D_801894B8), D_801E5224); - func_8001CE28(item, D_801E5224); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801E51F0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801E5240, 0x84); - func_8001CE68(item, D_801E5240); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801E5240, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801E51F0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801E51F0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_801627E8); - - -extern void (*D_801894DC[])(void); - -void func_80162834(void *a0) { - D_801894DC[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801894CC; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801894CC, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801E4A04[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801E4A04, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801E4A04[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801E4A04, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801894E4[])(void); - -void func_80163A58(void *a0) { - D_801894E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801E4A0C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801E4A0C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80189538[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80189538[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80189500; -extern s16 D_80189534; -extern s16 D_80189532; -extern s16 D_80189530; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80189500; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80189534 = 0x80; - D_80189532 = 0x80; - D_80189530 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80189534 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80189534` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80189534 - 8; - D_80189534 = nv; - D_80189532 = nv; - D_80189530 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80189544[])(void); - -void func_80164BA0(void *a0) { - D_80189544[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801E5250; -extern u8 D_801E5251; -extern u8 D_801E5252; -extern u8 D_801E5253; -extern u8 D_801E5254; -extern u8 D_801E5255; -extern u8 D_801E5256; -extern u8 D_801E5257; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801E5250; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801E5251 = 0xf0; - *(u8 *)base = 0xf0; - D_801E5252 = 0xc0; - D_801E5256 = 0; - D_801E5255 = 0; - D_801E5254 = 0; - D_801E5257 = 0; - D_801E5253 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801E5250; -extern u8 D_801E5251; -extern u8 D_801E5252; - -s32 func_80164E40(void) { - u8 *p = &D_801E5250; - if (*p != 0) { - *p -= 0x10; - } - if (D_801E5251 != 0) { - D_801E5251 -= 0x10; - } - if (D_801E5252 != 0) { - D_801E5252 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80189554[])(void); - -void func_80164EA4(void *a0) { - D_80189554[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801E529C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801E529C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801E5290[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801E5290[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801E5290[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801E5290; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801E5290; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80189568[]; - extern u32 D_80189588, D_8018958C, D_80189590, D_80189594; - extern u32 D_80189588, D_8018958C, D_80189590, D_80189594; - extern u32 D_80189588, D_8018958C, D_80189590, D_80189594; - extern u32 D_80189588, D_8018958C, D_80189590, D_80189594; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80189568[0x00], p); - ApplyMatrixSV(mat, &D_80189568[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80189568[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80189568[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80189590; - *(u32 *)(prim + 0x24) = D_80189588; - *(u32 *)(prim + 0x28) = D_80189594; - *(u32 *)(prim + 0x2c) = D_8018958C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80189598[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80189598[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80189598[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80189598[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80189614[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80189614[a1 & 0x7F]; -} - - - -extern s32 D_80189634[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80189634[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801896B0[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801896B0[a1 & 0x7F]; -} - - - -extern u8 D_801896D0[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801896D0[a1 & 0x7F]; -} - - - -extern u8 D_801896F0[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801896F0[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80189710[])(void); - D_80189710[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018978C[])(void); - -void func_80165AC8(void) { - D_8018978C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80189808[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80189808[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801E4A14; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801E4A14, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80189814[])(void); - -void func_80166018(void *a0) { - D_80189814[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018981C[])(void); - -void func_801663FC(void *a0) { - D_8018981C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801898E4[])(void); - -void func_80166618(void *a0) { - D_801898E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801898F4[])(void); - -void func_80166654(void *a0) { - D_801898F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801E5310[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801E5310[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E5310). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801E5310[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801E5310)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801E5310[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801E5310[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80189838[]; - extern u8 D_80189824[]; - extern u8 D_8018984C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80189838; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80189824; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018984C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80167714); - - -extern void (*D_80189904[])(void); - -void func_801678B4(void *a0) { - D_80189904[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80189910[])(void); - -void func_80167A9C(void *a0) { - D_80189910[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80189A1C; - extern u8 D_80189A30[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80189A1C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80189A30; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80189870[]; -extern u8 D_80189884[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80189870; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80189884; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80189928[])(void); - -void func_80168744(void *a0) { - D_80189928[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80189918 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80189918[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80189918; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80189930[])(void); - -void func_801689D8(void *a0) { - D_80189930[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80189938[])(void); - -void func_80168AA8(void *a0) { - D_80189938[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80189940[])(void); - -void func_80168D58(void *a0) { - D_80189940[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80189948[])(void); - -void func_8016901C(void *a0) { - D_80189948[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015AE2C", func_80169228); - - -extern void (*D_80189950[])(void); - -void func_801693CC(void *a0) { - D_80189950[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80189958[])(void); - -void func_80169830(void *a0) { - D_80189958[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80189A0C[])(void); - -void func_80169B80(void *a0) { - D_80189A0C[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80189960[]; - extern u8 D_801899D0[]; - extern u8 D_80189A00[]; - extern u8 D_801E6718[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80189A00, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80189960[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801E6718; - RotMatrixYXZ(rot, D_801E6718); - func_80048D9C(D_801E6718, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801899D0); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80189A14[])(void); - -void func_80169F00(void *a0) { - D_80189A14[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801899C4[]; -extern char D_80189984[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801899C4, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80189984); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80189A4C[])(void); - -void func_8016A020(void *a0) { - D_80189A4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80189A1C; - extern u8 D_80189A30[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80189A1C); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80189A30; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80189A58[])(void); - -void func_8016A700(void *a0) { - D_80189A58[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80189AA0[])(void); - -void func_8016AB30(void *a0) { - D_80189AA0[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c b/src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c new file mode 100644 index 000000000..ad8e349f0 --- /dev/null +++ b/src/ov_SC05_018/ov_SC05_018_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80188E6C; +extern u8 D_80188DDC; +extern u8 D_80188DB8; +extern u8 D_80188D94; +extern u8 D_80188E48; +extern u8 D_80188E24; +extern u8 D_80188E00; +extern u8 D_80188D70; +extern void func_80145934(void); +extern u8 D_80188EFC; +extern u8 D_80188ED8; +extern u8 D_80188EB4; +extern u8 D_80188E90; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801882F4[]; +extern unsigned char D_80188324[]; +extern unsigned char D_80188374[]; +extern unsigned char D_801883A4[]; +extern unsigned char D_801883D4[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80188424[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801884EC[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80188574[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018857C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801E5140; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801E5144; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801885AC; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80188654[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80188678[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80188668; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018868C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80188698[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801886A8[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801886C0[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801886B0; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801886D4[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801886F0[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801886E0; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80188704[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80188718[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018872C; +extern void (*D_80188754[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80188734; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801887A0[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801887A4[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80188C08[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80188C18[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801E5178; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80188C40[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80188C20; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80188C30; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80188C80[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80188C88[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80188C54; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80188C94[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80188C64; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801E5180; +extern s32 D_801E518C; +extern s32 D_801E5190; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80188CD0[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80188CA4[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801E5188; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80188F20[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80188D40[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80188FC4[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80189118[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80188F34; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80189120[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80188F44; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80188F64; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80189128[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80189150[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80188FD0[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018915C[])(void); + +void func_8015C714(void *a0) { + D_8018915C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80188FD0[])(void*); + extern int D_80188F74; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80188FD0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80188FD0)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188F74); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80188FD0[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80188FD0[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80188FD0[])(void*); + extern int D_80188F74; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80188FD0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80188F74); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80188FD0)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018916C[])(void); + D_8018916C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80188FD0[])(struct Ent_8015CD20 *); + extern u8 D_80188F84; + extern u8 D_80189174; + extern u8 D_80189184; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80188FD0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188F84); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189174); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189184); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80188FD0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801891A4[])(void); + D_801891A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80189194; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80189194 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80188FD0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80189200; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80189200, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801882E4[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801882E4; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80189208[])(void); + D_80189208[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80189214[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80189214[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80189214[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80189214[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80188FD0[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80189214[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80188F94[]; + extern u8 D_80188FA4[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188F94); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80188FA4); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80189214[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80189214[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80189214[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80189248[])(void); + D_80189248[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188FD0[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80189250[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80189268[])(void); + D_80189268[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80188FD0[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80189250[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80189250[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80189288[])(void); + D_80189288[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80188FD0[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188FD0)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80189298; +extern u16 D_8018929A; +extern u16 D_8018929C; +extern s32 D_801892A0; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80189298 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018929A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018929C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801892A0, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801892A8; + +void func_8015E588(void) { + func_8013C9C4(&D_801892A8); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80188FD0[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80188FD0)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801892BC[])(void); + D_801892BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80188FD0[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80188FD0[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801892C4[])(void); + D_801892C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80188FB4; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80188FB4); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80188FD0[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801892CC[])(void); + D_801892CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80188FD0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80188FD0[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801892D4[])(void); + D_801892D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80188FD0[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801892DC; + extern s32 D_801892EC; + extern s32 D_801892FC; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801892DC); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801892EC); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80188FD0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801892FC); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018930C[])(void); + D_8018930C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80188FD0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80188FD0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80188FD0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80188FD0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80189318[])(void); + D_80189318[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80188FD0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80188FD0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80188FD0[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188FD0[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018932C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018932C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80188FD0[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80188FD0)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80188FD0[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80188FD0[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801893A8[])(void); + D_801893A8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80188FD0[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80188FD0)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801893B8[])(void); + D_801893B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80188FD0[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80188FD0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80188FD0[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80188FD0[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80188FD0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80188FD0[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80188FD0[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801893C0[])(void); + D_801893C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80188FD0[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80188FD0)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80188FD0[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80188FD0)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801893CC[])(void); + D_801893CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80188FD0 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80188FD0[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80188FD0[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80188FD0[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801893DC[])(void); + +void func_80160EA4(void *a0) { + D_801893DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80188FD0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80188FD0[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018940C[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018940C[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80189470; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80189470); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801E5198[]; + extern u8 D_8018943C[]; + extern u8 D_8018945C[]; + extern u8 D_801E51A4[]; + extern u8 D_801E51CC[]; + extern u8 D_801E51E4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801E5198[0] = p; + func_80024054(&D_8018943C, &D_801E51A4); + func_8001CE28(p, &D_801E51A4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801E5198[1] = p; + func_80024054(&D_8018945C, &D_801E51CC); + func_8001CE28(p, &D_801E51CC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801E5198[2] = p; + func_800242D0((s16)func_801620C4(), &D_801E51E4, 0x84); + func_8001CE68(p, &D_801E51E4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801E51E4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E5198[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801E5198; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80189470; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80189470; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80189470; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80189470; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801E5198[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801E5198; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80189494[])(void); + +void func_80162330(void *a0) { + D_80189494[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801E51F0[i] via `extern int D_801E51F0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801894A0[]; + extern s32 D_801894B8; + extern u8 D_801E51FC[]; + extern u8 D_801E5224[]; + extern u8 D_801E5240[]; + extern int D_801E51F0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801E51F0[0] = (s32)item; + func_80024054(D_801894A0, D_801E51FC); + func_8001CE28(item, D_801E51FC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801E51F0[1] = (s32)item; + func_80024054(((u8 *)&D_801894B8), D_801E5224); + func_8001CE28(item, D_801E5224); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801E51F0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801E5240, 0x84); + func_8001CE68(item, D_801E5240); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801E5240, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801E51F0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801E51F0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_801627E8); + + +extern void (*D_801894DC[])(void); + +void func_80162834(void *a0) { + D_801894DC[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801894CC; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801894CC, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801E4A04[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801E4A04, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801E4A04[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801E4A04, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801894E4[])(void); + +void func_80163A58(void *a0) { + D_801894E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801E4A0C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801E4A0C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80189538[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80189538[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80189500; +extern s16 D_80189534; +extern s16 D_80189532; +extern s16 D_80189530; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80189500; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80189534 = 0x80; + D_80189532 = 0x80; + D_80189530 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80189534 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80189534` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80189534 - 8; + D_80189534 = nv; + D_80189532 = nv; + D_80189530 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80189544[])(void); + +void func_80164BA0(void *a0) { + D_80189544[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801E5250; +extern u8 D_801E5251; +extern u8 D_801E5252; +extern u8 D_801E5253; +extern u8 D_801E5254; +extern u8 D_801E5255; +extern u8 D_801E5256; +extern u8 D_801E5257; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801E5250; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801E5251 = 0xf0; + *(u8 *)base = 0xf0; + D_801E5252 = 0xc0; + D_801E5256 = 0; + D_801E5255 = 0; + D_801E5254 = 0; + D_801E5257 = 0; + D_801E5253 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801E5250; +extern u8 D_801E5251; +extern u8 D_801E5252; + +s32 func_80164E40(void) { + u8 *p = &D_801E5250; + if (*p != 0) { + *p -= 0x10; + } + if (D_801E5251 != 0) { + D_801E5251 -= 0x10; + } + if (D_801E5252 != 0) { + D_801E5252 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80189554[])(void); + +void func_80164EA4(void *a0) { + D_80189554[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801E529C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801E529C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801E5290[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801E5290[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801E5290[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801E5290; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801E5290; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80189568[]; + extern u32 D_80189588, D_8018958C, D_80189590, D_80189594; + extern u32 D_80189588, D_8018958C, D_80189590, D_80189594; + extern u32 D_80189588, D_8018958C, D_80189590, D_80189594; + extern u32 D_80189588, D_8018958C, D_80189590, D_80189594; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80189568[0x00], p); + ApplyMatrixSV(mat, &D_80189568[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80189568[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80189568[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80189590; + *(u32 *)(prim + 0x24) = D_80189588; + *(u32 *)(prim + 0x28) = D_80189594; + *(u32 *)(prim + 0x2c) = D_8018958C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80189598[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80189598[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80189598[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80189598[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80189614[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80189614[a1 & 0x7F]; +} + + + +extern s32 D_80189634[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80189634[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801896B0[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801896B0[a1 & 0x7F]; +} + + + +extern u8 D_801896D0[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801896D0[a1 & 0x7F]; +} + + + +extern u8 D_801896F0[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801896F0[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80189710[])(void); + D_80189710[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018978C[])(void); + +void func_80165AC8(void) { + D_8018978C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80189808[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80189808[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801E4A14; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801E4A14, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80189814[])(void); + +void func_80166018(void *a0) { + D_80189814[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018981C[])(void); + +void func_801663FC(void *a0) { + D_8018981C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801898E4[])(void); + +void func_80166618(void *a0) { + D_801898E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801898F4[])(void); + +void func_80166654(void *a0) { + D_801898F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801E5310[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801E5310[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801E5310). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801E5310[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801E5310)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801E5310[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801E5310[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80189838[]; + extern u8 D_80189824[]; + extern u8 D_8018984C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80189838; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80189824; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018984C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80167714); + + +extern void (*D_80189904[])(void); + +void func_801678B4(void *a0) { + D_80189904[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80189910[])(void); + +void func_80167A9C(void *a0) { + D_80189910[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80189A1C; + extern u8 D_80189A30[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80189A1C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80189A30; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80189870[]; +extern u8 D_80189884[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80189870; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80189884; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80189928[])(void); + +void func_80168744(void *a0) { + D_80189928[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80189918 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80189918[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80189918; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80189930[])(void); + +void func_801689D8(void *a0) { + D_80189930[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80189938[])(void); + +void func_80168AA8(void *a0) { + D_80189938[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80189940[])(void); + +void func_80168D58(void *a0) { + D_80189940[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80189948[])(void); + +void func_8016901C(void *a0) { + D_80189948[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_018/nonmatchings/ov_SC05_018_jr_8015C32C", func_80169228); + + +extern void (*D_80189950[])(void); + +void func_801693CC(void *a0) { + D_80189950[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80189958[])(void); + +void func_80169830(void *a0) { + D_80189958[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80189A0C[])(void); + +void func_80169B80(void *a0) { + D_80189A0C[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80189960[]; + extern u8 D_801899D0[]; + extern u8 D_80189A00[]; + extern u8 D_801E6718[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80189A00, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80189960[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801E6718; + RotMatrixYXZ(rot, D_801E6718); + func_80048D9C(D_801E6718, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801899D0); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80189A14[])(void); + +void func_80169F00(void *a0) { + D_80189A14[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801899C4[]; +extern char D_80189984[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801899C4, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80189984); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80189A4C[])(void); + +void func_8016A020(void *a0) { + D_80189A4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80189A1C; + extern u8 D_80189A30[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80189A1C); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80189A30; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80189A58[])(void); + +void func_8016A700(void *a0) { + D_80189A58[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80189AA0[])(void); + +void func_8016AB30(void *a0) { + D_80189AA0[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC05_019/ov_SC05_019_jr_8015AE2C.c b/src/ov_SC05_019/ov_SC05_019_jr_8015AE2C.c index 2dd01f41f..14dedb55a 100644 --- a/src/ov_SC05_019/ov_SC05_019_jr_8015AE2C.c +++ b/src/ov_SC05_019/ov_SC05_019_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80181AA0[])(void); - -void func_8015C714(void *a0) { - D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181914[])(void*); - extern int D_801818B8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181914[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181914[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181914[])(void*); - extern int D_801818B8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181AB0[])(void); - D_80181AB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181914[])(struct Ent_8015CD20 *); - extern u8 D_801818C8; - extern u8 D_80181AB8; - extern u8 D_80181AC8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801818C8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AB8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AC8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80181AE8[])(void); - D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80181AD8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80181AD8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181B44; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181B44, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180C28[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180C28; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80181B4C[])(void); - D_80181B4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80181B58[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80181B58[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181914[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80181B58[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801818D8[]; - extern u8 D_801818E8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818D8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818E8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80181B8C[])(void); - D_80181B8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181914[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181B94[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181BAC[])(void); - D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181914[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80181B94[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181BCC[])(void); - D_80181BCC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181914[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181914)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181BDC; -extern u16 D_80181BDE; -extern u16 D_80181BE0; -extern s32 D_80181BE4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181BDC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80181BDE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181BE0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181BE4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181BEC; - -void func_8015E588(void) { - func_8013C9C4(&D_80181BEC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181914[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181914)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181C00[])(void); - D_80181C00[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181914[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181914[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181C08[])(void); - D_80181C08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801818F8; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801818F8); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181914[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181C10[])(void); - D_80181C10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181914[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181914[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181C18[])(void); - D_80181C18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181914[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181C20; - extern s32 D_80181C30; - extern s32 D_80181C40; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181914[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C20); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C30); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181914[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C40); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80181C50[])(void); - D_80181C50[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181914[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181914[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80181C5C[])(void); - D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181914[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181914[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181914[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80181C70[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80181C70[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181914[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181914)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181914[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181914[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181CEC[])(void); - D_80181CEC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181914[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181914)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181CFC[])(void); - D_80181CFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181914[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181914[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181D04[])(void); - D_80181D04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181914[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181914)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181914[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181914)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181D10[])(void); - D_80181D10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181914 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181914[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181914[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181914[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181D20[])(void); - -void func_80160EA4(void *a0) { - D_80181D20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181914[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181914[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80181D50[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80181D50[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181DB4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181DB4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8018E868[]; - extern u8 D_80181D80[]; - extern u8 D_80181DA0[]; - extern u8 D_8018E874[]; - extern u8 D_8018E89C[]; - extern u8 D_8018E8B4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8018E868[0] = p; - func_80024054(&D_80181D80, &D_8018E874); - func_8001CE28(p, &D_8018E874); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8018E868[1] = p; - func_80024054(&D_80181DA0, &D_8018E89C); - func_8001CE28(p, &D_8018E89C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8018E868[2] = p; - func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); - func_8001CE68(p, &D_8018E8B4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E868[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8018E868; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181DB4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181DB4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181DB4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181DB4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8018E868[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8018E868; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80181DD8[])(void); - -void func_80162330(void *a0) { - D_80181DD8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8018E8C0[i] via `extern int D_8018E8C0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181DE4[]; - extern s32 D_80181DFC; - extern u8 D_8018E8CC[]; - extern u8 D_8018E8F4[]; - extern u8 D_8018E910[]; - extern int D_8018E8C0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8018E8C0[0] = (s32)item; - func_80024054(D_80181DE4, D_8018E8CC); - func_8001CE28(item, D_8018E8CC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8018E8C0[1] = (s32)item; - func_80024054(((u8 *)&D_80181DFC), D_8018E8F4); - func_8001CE28(item, D_8018E8F4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8018E8C0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); - func_8001CE68(item, D_8018E910); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8018E8C0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8018E8C0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181E20[])(void); - -void func_80162834(void *a0) { - D_80181E20[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181E10; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181E10, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8018E118[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8018E118, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8018E118[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8018E118, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181E28[])(void); - -void func_80163A58(void *a0) { - D_80181E28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8018E120; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8018E120; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80181E7C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80181E7C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181E44; -extern s16 D_80181E78; -extern s16 D_80181E76; -extern s16 D_80181E74; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181E44; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181E78 = 0x80; - D_80181E76 = 0x80; - D_80181E74 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181E78 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181E78` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181E78 - 8; - D_80181E78 = nv; - D_80181E76 = nv; - D_80181E74 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181E88[])(void); - -void func_80164BA0(void *a0) { - D_80181E88[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8018E920; -extern u8 D_8018E921; -extern u8 D_8018E922; -extern u8 D_8018E923; -extern u8 D_8018E924; -extern u8 D_8018E925; -extern u8 D_8018E926; -extern u8 D_8018E927; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8018E920; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8018E921 = 0xf0; - *(u8 *)base = 0xf0; - D_8018E922 = 0xc0; - D_8018E926 = 0; - D_8018E925 = 0; - D_8018E924 = 0; - D_8018E927 = 0; - D_8018E923 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8018E920; -extern u8 D_8018E921; -extern u8 D_8018E922; - -s32 func_80164E40(void) { - u8 *p = &D_8018E920; - if (*p != 0) { - *p -= 0x10; - } - if (D_8018E921 != 0) { - D_8018E921 -= 0x10; - } - if (D_8018E922 != 0) { - D_8018E922 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80181E98[])(void); - -void func_80164EA4(void *a0) { - D_80181E98[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8018E96C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8018E96C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8018E960[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8018E960[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8018E960[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8018E960; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8018E960; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181EAC[]; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181EAC[0x00], p); - ApplyMatrixSV(mat, &D_80181EAC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181EAC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181EAC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181ED4; - *(u32 *)(prim + 0x24) = D_80181ECC; - *(u32 *)(prim + 0x28) = D_80181ED8; - *(u32 *)(prim + 0x2c) = D_80181ED0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181EDC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181EDC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181EDC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181EDC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80181F58[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80181F58[a1 & 0x7F]; -} - - - -extern s32 D_80181F78[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181F78[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181FF4[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181FF4[a1 & 0x7F]; -} - - - -extern u8 D_80182014[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182014[a1 & 0x7F]; -} - - - -extern u8 D_80182034[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182034[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80182054[])(void); - D_80182054[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801820D0[])(void); - -void func_80165AC8(void) { - D_801820D0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018214C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018214C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8018E128; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8018E128, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80182158[])(void); - -void func_80166018(void *a0) { - D_80182158[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80182160[])(void); - -void func_801663FC(void *a0) { - D_80182160[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182228[])(void); - -void func_80166618(void *a0) { - D_80182228[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182238[])(void); - -void func_80166654(void *a0) { - D_80182238[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8018E9E0[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8018E9E0[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018E9E0). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8018E9E0[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8018E9E0)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8018E9E0[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8018E9E0[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018217C[]; - extern u8 D_80182168[]; - extern u8 D_80182190[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018217C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80182168; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182190; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80167714); - - -extern void (*D_80182248[])(void); - -void func_801678B4(void *a0) { - D_80182248[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80182254[])(void); - -void func_80167A9C(void *a0) { - D_80182254[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80182360; - extern u8 D_80182374[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80182360); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182374; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801821B4[]; -extern u8 D_801821C8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801821B4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801821C8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018226C[])(void); - -void func_80168744(void *a0) { - D_8018226C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018225C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018225C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018225C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80182274[])(void); - -void func_801689D8(void *a0) { - D_80182274[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018227C[])(void); - -void func_80168AA8(void *a0) { - D_8018227C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80182284[])(void); - -void func_80168D58(void *a0) { - D_80182284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018228C[])(void); - -void func_8016901C(void *a0) { - D_8018228C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015AE2C", func_80169228); - - -extern void (*D_80182294[])(void); - -void func_801693CC(void *a0) { - D_80182294[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018229C[])(void); - -void func_80169830(void *a0) { - D_8018229C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80182350[])(void); - -void func_80169B80(void *a0) { - D_80182350[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_801822A4[]; - extern u8 D_80182314[]; - extern u8 D_80182344[]; - extern u8 D_8018F9E0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80182344, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_801822A4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8018F9E0; - RotMatrixYXZ(rot, D_8018F9E0); - func_80048D9C(D_8018F9E0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182314); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80182358[])(void); - -void func_80169F00(void *a0) { - D_80182358[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80182308[]; -extern char D_801822C8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80182308, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801822C8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80182390[])(void); - -void func_8016A020(void *a0) { - D_80182390[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80182360; - extern u8 D_80182374[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80182360); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80182374; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018239C[])(void); - -void func_8016A700(void *a0) { - D_8018239C[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801823E4[])(void); - -void func_8016AB30(void *a0) { - D_801823E4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c b/src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c new file mode 100644 index 000000000..2bf2fc9ff --- /dev/null +++ b/src/ov_SC05_019/ov_SC05_019_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801817B0; +extern u8 D_80181720; +extern u8 D_801816FC; +extern u8 D_801816D8; +extern u8 D_8018178C; +extern u8 D_80181768; +extern u8 D_80181744; +extern u8 D_801816B4; +extern void func_80145934(void); +extern u8 D_80181840; +extern u8 D_8018181C; +extern u8 D_801817F8; +extern u8 D_801817D4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180C38[]; +extern unsigned char D_80180C68[]; +extern unsigned char D_80180CB8[]; +extern unsigned char D_80180CE8[]; +extern unsigned char D_80180D18[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80180D68[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80180E30[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80180EB8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180EC0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8018E810; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8018E814; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180EF0; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80180F98[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180FBC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180FAC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180FD0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180FDC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180FEC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181004[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180FF4; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181018[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181034[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181024; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181048[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018105C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80181070; +extern void (*D_80181098[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80181078; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801810E4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801810E8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018154C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018155C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8018E848; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80181584[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80181564; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80181574; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801815C4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801815CC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80181598; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801815D8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801815A8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8018E850; +extern s32 D_8018E85C; +extern s32 D_8018E860; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80181614[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801815E8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8018E858; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80181864[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80181684[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181908[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80181A5C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80181878; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80181A64[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80181888; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801818A8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80181A6C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80181A94[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181914[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80181AA0[])(void); + +void func_8015C714(void *a0) { + D_80181AA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181914[])(void*); + extern int D_801818B8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181914[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181914[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181914[])(void*); + extern int D_801818B8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801818B8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181AB0[])(void); + D_80181AB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181914[])(struct Ent_8015CD20 *); + extern u8 D_801818C8; + extern u8 D_80181AB8; + extern u8 D_80181AC8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801818C8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AB8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80181AC8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181914[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80181AE8[])(void); + D_80181AE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80181AD8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80181AD8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181B44; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181B44, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180C28[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180C28; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80181B4C[])(void); + D_80181B4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80181B58[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80181B58[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181914[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80181B58[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801818D8[]; + extern u8 D_801818E8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818D8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801818E8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181B58[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80181B8C[])(void); + D_80181B8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181914[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181B94[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181BAC[])(void); + D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181914[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80181B94[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80181B94[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181BCC[])(void); + D_80181BCC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181914[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181914)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181BDC; +extern u16 D_80181BDE; +extern u16 D_80181BE0; +extern s32 D_80181BE4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181BDC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80181BDE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181BE0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181BE4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181BEC; + +void func_8015E588(void) { + func_8013C9C4(&D_80181BEC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181914[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181914)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181C00[])(void); + D_80181C00[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181914[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181914[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181C08[])(void); + D_80181C08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801818F8; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801818F8); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181914[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181C10[])(void); + D_80181C10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181914[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181914[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181C18[])(void); + D_80181C18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181914[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181C20; + extern s32 D_80181C30; + extern s32 D_80181C40; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181914[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C20); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C30); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181914[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181C40); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80181C50[])(void); + D_80181C50[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181914[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181914[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80181C5C[])(void); + D_80181C5C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181914[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181914[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181914[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80181C70[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80181C70[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181914[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181914)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181914[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181914[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181CEC[])(void); + D_80181CEC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181914[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181914)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181CFC[])(void); + D_80181CFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181914[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181914[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181D04[])(void); + D_80181D04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181914[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181914)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181914[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181914)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181D10[])(void); + D_80181D10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181914 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181914[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181914[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181914[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181D20[])(void); + +void func_80160EA4(void *a0) { + D_80181D20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181914[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181914[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80181D50[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80181D50[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181DB4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181DB4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8018E868[]; + extern u8 D_80181D80[]; + extern u8 D_80181DA0[]; + extern u8 D_8018E874[]; + extern u8 D_8018E89C[]; + extern u8 D_8018E8B4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8018E868[0] = p; + func_80024054(&D_80181D80, &D_8018E874); + func_8001CE28(p, &D_8018E874); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8018E868[1] = p; + func_80024054(&D_80181DA0, &D_8018E89C); + func_8001CE28(p, &D_8018E89C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8018E868[2] = p; + func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); + func_8001CE68(p, &D_8018E8B4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8018E8B4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E868[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8018E868; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181DB4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181DB4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181DB4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181DB4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8018E868[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8018E868; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80181DD8[])(void); + +void func_80162330(void *a0) { + D_80181DD8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8018E8C0[i] via `extern int D_8018E8C0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181DE4[]; + extern s32 D_80181DFC; + extern u8 D_8018E8CC[]; + extern u8 D_8018E8F4[]; + extern u8 D_8018E910[]; + extern int D_8018E8C0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8018E8C0[0] = (s32)item; + func_80024054(D_80181DE4, D_8018E8CC); + func_8001CE28(item, D_8018E8CC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8018E8C0[1] = (s32)item; + func_80024054(((u8 *)&D_80181DFC), D_8018E8F4); + func_8001CE28(item, D_8018E8F4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8018E8C0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); + func_8001CE68(item, D_8018E910); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8018E910, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8018E8C0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8018E8C0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_801627E8); + + +extern void (*D_80181E20[])(void); + +void func_80162834(void *a0) { + D_80181E20[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181E10; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181E10, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8018E118[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8018E118, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8018E118[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8018E118, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181E28[])(void); + +void func_80163A58(void *a0) { + D_80181E28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8018E120; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8018E120; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80181E7C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80181E7C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181E44; +extern s16 D_80181E78; +extern s16 D_80181E76; +extern s16 D_80181E74; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181E44; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181E78 = 0x80; + D_80181E76 = 0x80; + D_80181E74 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181E78 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181E78` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181E78 - 8; + D_80181E78 = nv; + D_80181E76 = nv; + D_80181E74 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181E88[])(void); + +void func_80164BA0(void *a0) { + D_80181E88[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8018E920; +extern u8 D_8018E921; +extern u8 D_8018E922; +extern u8 D_8018E923; +extern u8 D_8018E924; +extern u8 D_8018E925; +extern u8 D_8018E926; +extern u8 D_8018E927; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8018E920; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8018E921 = 0xf0; + *(u8 *)base = 0xf0; + D_8018E922 = 0xc0; + D_8018E926 = 0; + D_8018E925 = 0; + D_8018E924 = 0; + D_8018E927 = 0; + D_8018E923 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8018E920; +extern u8 D_8018E921; +extern u8 D_8018E922; + +s32 func_80164E40(void) { + u8 *p = &D_8018E920; + if (*p != 0) { + *p -= 0x10; + } + if (D_8018E921 != 0) { + D_8018E921 -= 0x10; + } + if (D_8018E922 != 0) { + D_8018E922 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80181E98[])(void); + +void func_80164EA4(void *a0) { + D_80181E98[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8018E96C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8018E96C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8018E960[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8018E960[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8018E960[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8018E960; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8018E960; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181EAC[]; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + extern u32 D_80181ECC, D_80181ED0, D_80181ED4, D_80181ED8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181EAC[0x00], p); + ApplyMatrixSV(mat, &D_80181EAC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181EAC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181EAC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181ED4; + *(u32 *)(prim + 0x24) = D_80181ECC; + *(u32 *)(prim + 0x28) = D_80181ED8; + *(u32 *)(prim + 0x2c) = D_80181ED0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181EDC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181EDC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181EDC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181EDC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80181F58[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80181F58[a1 & 0x7F]; +} + + + +extern s32 D_80181F78[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181F78[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181FF4[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181FF4[a1 & 0x7F]; +} + + + +extern u8 D_80182014[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182014[a1 & 0x7F]; +} + + + +extern u8 D_80182034[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182034[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80182054[])(void); + D_80182054[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801820D0[])(void); + +void func_80165AC8(void) { + D_801820D0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018214C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018214C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8018E128; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8018E128, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80182158[])(void); + +void func_80166018(void *a0) { + D_80182158[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80182160[])(void); + +void func_801663FC(void *a0) { + D_80182160[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182228[])(void); + +void func_80166618(void *a0) { + D_80182228[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182238[])(void); + +void func_80166654(void *a0) { + D_80182238[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8018E9E0[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8018E9E0[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8018E9E0). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8018E9E0[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8018E9E0)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8018E9E0[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8018E9E0[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018217C[]; + extern u8 D_80182168[]; + extern u8 D_80182190[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018217C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80182168; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182190; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80167714); + + +extern void (*D_80182248[])(void); + +void func_801678B4(void *a0) { + D_80182248[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80182254[])(void); + +void func_80167A9C(void *a0) { + D_80182254[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80182360; + extern u8 D_80182374[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80182360); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182374; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801821B4[]; +extern u8 D_801821C8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801821B4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801821C8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018226C[])(void); + +void func_80168744(void *a0) { + D_8018226C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018225C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018225C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018225C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80182274[])(void); + +void func_801689D8(void *a0) { + D_80182274[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018227C[])(void); + +void func_80168AA8(void *a0) { + D_8018227C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80182284[])(void); + +void func_80168D58(void *a0) { + D_80182284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018228C[])(void); + +void func_8016901C(void *a0) { + D_8018228C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC05_019/nonmatchings/ov_SC05_019_jr_8015C32C", func_80169228); + + +extern void (*D_80182294[])(void); + +void func_801693CC(void *a0) { + D_80182294[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018229C[])(void); + +void func_80169830(void *a0) { + D_8018229C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80182350[])(void); + +void func_80169B80(void *a0) { + D_80182350[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_801822A4[]; + extern u8 D_80182314[]; + extern u8 D_80182344[]; + extern u8 D_8018F9E0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80182344, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_801822A4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8018F9E0; + RotMatrixYXZ(rot, D_8018F9E0); + func_80048D9C(D_8018F9E0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182314); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80182358[])(void); + +void func_80169F00(void *a0) { + D_80182358[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80182308[]; +extern char D_801822C8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80182308, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801822C8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80182390[])(void); + +void func_8016A020(void *a0) { + D_80182390[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80182360; + extern u8 D_80182374[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80182360); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80182374; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018239C[])(void); + +void func_8016A700(void *a0) { + D_8018239C[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801823E4[])(void); + +void func_8016AB30(void *a0) { + D_801823E4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_000/ov_SC06_000_jr_8015AE2C.c b/src/ov_SC06_000/ov_SC06_000_jr_8015AE2C.c index 0dd8fb3fe..8eeaad8e0 100644 --- a/src/ov_SC06_000/ov_SC06_000_jr_8015AE2C.c +++ b/src/ov_SC06_000/ov_SC06_000_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018AAB0[])(void); - -void func_8015C714(void *a0) { - D_8018AAB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018A924[])(void*); - extern int D_8018A8C8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018A924)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018A924)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018A8C8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018A924[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018A924[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018A924[])(void*); - extern int D_8018A8C8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018A924)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018A8C8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018A924)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018AAC0[])(void); - D_8018AAC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018A924[])(struct Ent_8015CD20 *); - extern u8 D_8018A8D8; - extern u8 D_8018AAC8; - extern u8 D_8018AAD8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018A924[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A8D8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AAC8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AAD8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018A924[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018AAF8[])(void); - D_8018AAF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018AAE8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018AAE8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018A924[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_8018AB54; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_8018AB54, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80189C38[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80189C38; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018AB5C[])(void); - D_8018AB5C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018AB68[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018AB68[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018AB68[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018AB68[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018A924[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018AB68[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018A8E8[]; - extern u8 D_8018A8F8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018A8E8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018A8F8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018AB68[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018AB68[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018AB68[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018AB9C[])(void); - D_8018AB9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018A924[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018ABA4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_8018ABBC[])(void); - D_8018ABBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018A924[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018ABA4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_8018ABDC[])(void); - D_8018ABDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018A924[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018A924)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_8018ABEC; -extern u16 D_8018ABEE; -extern u16 D_8018ABF0; -extern s32 D_8018ABF4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_8018ABEC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018ABEE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018ABF0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018ABF4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018ABFC; - -void func_8015E588(void) { - func_8013C9C4(&D_8018ABFC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018A924[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018A924)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018AC10[])(void); - D_8018AC10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018A924[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018A924[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018AC18[])(void); - D_8018AC18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018A908; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018A908); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018A924[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_8018AC20[])(void); - D_8018AC20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018A924[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018A924[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018AC28[])(void); - D_8018AC28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018A924[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_8018AC30; - extern s32 D_8018AC40; - extern s32 D_8018AC50; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018A924[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018AC30); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018AC40); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018A924[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018AC50); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_8018AC60[])(void); - D_8018AC60[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018A924[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018A924[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018A924[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018A924[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018AC6C[])(void); - D_8018AC6C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018A924[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018A924[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018A924[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018A924[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018AC80[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018AC80[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018A924[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018A924)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018A924[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018A924[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018ACFC[])(void); - D_8018ACFC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018A924[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018A924)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018AD0C[])(void); - D_8018AD0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018A924[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018A924[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018A924[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018A924[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018A924[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018A924[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018A924[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018AD14[])(void); - D_8018AD14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018A924[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018A924)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018A924[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018A924)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_8018AD20[])(void); - D_8018AD20[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018A924 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018A924[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018A924[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018A924[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_8018AD30[])(void); - -void func_80160EA4(void *a0) { - D_8018AD30[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018A924[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018A924[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_8018AD60[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_8018AD60[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018ADC4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018ADC4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801AD4D8[]; - extern u8 D_8018AD90[]; - extern u8 D_8018ADB0[]; - extern u8 D_801AD4E4[]; - extern u8 D_801AD50C[]; - extern u8 D_801AD524[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801AD4D8[0] = p; - func_80024054(&D_8018AD90, &D_801AD4E4); - func_8001CE28(p, &D_801AD4E4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801AD4D8[1] = p; - func_80024054(&D_8018ADB0, &D_801AD50C); - func_8001CE28(p, &D_801AD50C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801AD4D8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801AD524, 0x84); - func_8001CE68(p, &D_801AD524); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801AD524, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801AD4D8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801AD4D8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018ADC4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018ADC4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018ADC4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018ADC4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801AD4D8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801AD4D8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018ADE8[])(void); - -void func_80162330(void *a0) { - D_8018ADE8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801AD530[i] via `extern int D_801AD530[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018ADF4[]; - extern s32 D_8018AE0C; - extern u8 D_801AD53C[]; - extern u8 D_801AD564[]; - extern u8 D_801AD580[]; - extern int D_801AD530[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801AD530[0] = (s32)item; - func_80024054(D_8018ADF4, D_801AD53C); - func_8001CE28(item, D_801AD53C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801AD530[1] = (s32)item; - func_80024054(((u8 *)&D_8018AE0C), D_801AD564); - func_8001CE28(item, D_801AD564); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801AD530[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801AD580, 0x84); - func_8001CE68(item, D_801AD580); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801AD580, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801AD530[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801AD530; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_801627E8); - - -extern void (*D_8018AE30[])(void); - -void func_80162834(void *a0) { - D_8018AE30[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_8018AE20; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_8018AE20, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801ACD90[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801ACD90, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801ACD90[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801ACD90, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018AE38[])(void); - -void func_80163A58(void *a0) { - D_8018AE38[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801ACD98; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801ACD98; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018AE8C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018AE8C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018AE54; -extern s16 D_8018AE88; -extern s16 D_8018AE86; -extern s16 D_8018AE84; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018AE54; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_8018AE88 = 0x80; - D_8018AE86 = 0x80; - D_8018AE84 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_8018AE88 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018AE88` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_8018AE88 - 8; - D_8018AE88 = nv; - D_8018AE86 = nv; - D_8018AE84 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_8018AE98[])(void); - -void func_80164BA0(void *a0) { - D_8018AE98[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801AD590; -extern u8 D_801AD591; -extern u8 D_801AD592; -extern u8 D_801AD593; -extern u8 D_801AD594; -extern u8 D_801AD595; -extern u8 D_801AD596; -extern u8 D_801AD597; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801AD590; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801AD591 = 0xf0; - *(u8 *)base = 0xf0; - D_801AD592 = 0xc0; - D_801AD596 = 0; - D_801AD595 = 0; - D_801AD594 = 0; - D_801AD597 = 0; - D_801AD593 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801AD590; -extern u8 D_801AD591; -extern u8 D_801AD592; - -s32 func_80164E40(void) { - u8 *p = &D_801AD590; - if (*p != 0) { - *p -= 0x10; - } - if (D_801AD591 != 0) { - D_801AD591 -= 0x10; - } - if (D_801AD592 != 0) { - D_801AD592 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_8018AEA8[])(void); - -void func_80164EA4(void *a0) { - D_8018AEA8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801AD5DC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801AD5DC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801AD5D0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801AD5D0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801AD5D0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801AD5D0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801AD5D0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_8018AEBC[]; - extern u32 D_8018AEDC, D_8018AEE0, D_8018AEE4, D_8018AEE8; - extern u32 D_8018AEDC, D_8018AEE0, D_8018AEE4, D_8018AEE8; - extern u32 D_8018AEDC, D_8018AEE0, D_8018AEE4, D_8018AEE8; - extern u32 D_8018AEDC, D_8018AEE0, D_8018AEE4, D_8018AEE8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_8018AEBC[0x00], p); - ApplyMatrixSV(mat, &D_8018AEBC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_8018AEBC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_8018AEBC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018AEE4; - *(u32 *)(prim + 0x24) = D_8018AEDC; - *(u32 *)(prim + 0x28) = D_8018AEE8; - *(u32 *)(prim + 0x2c) = D_8018AEE0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_8018AEEC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_8018AEEC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_8018AEEC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_8018AEEC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_8018AF68[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_8018AF68[a1 & 0x7F]; -} - - - -extern s32 D_8018AF88[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_8018AF88[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018B004[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018B004[a1 & 0x7F]; -} - - - -extern u8 D_8018B024[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018B024[a1 & 0x7F]; -} - - - -extern u8 D_8018B044[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018B044[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018B064[])(void); - D_8018B064[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018B0E0[])(void); - -void func_80165AC8(void) { - D_8018B0E0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018B15C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018B15C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801ACDA0; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801ACDA0, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_8018B168[])(void); - -void func_80166018(void *a0) { - D_8018B168[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_8018B170[])(void); - -void func_801663FC(void *a0) { - D_8018B170[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_8018B238[])(void); - -void func_80166618(void *a0) { - D_8018B238[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_8018B248[])(void); - -void func_80166654(void *a0) { - D_8018B248[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801AD650[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801AD650[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801AD650). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801AD650[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801AD650)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801AD650[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801AD650[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018B18C[]; - extern u8 D_8018B178[]; - extern u8 D_8018B1A0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018B18C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_8018B178; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018B1A0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80167714); - - -extern void (*D_8018B258[])(void); - -void func_801678B4(void *a0) { - D_8018B258[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018B264[])(void); - -void func_80167A9C(void *a0) { - D_8018B264[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_8018B370; - extern u8 D_8018B384[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_8018B370); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018B384; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018B1C4[]; -extern u8 D_8018B1D8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018B1C4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_8018B1D8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_8018B27C[])(void); - -void func_80168744(void *a0) { - D_8018B27C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_8018B26C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_8018B26C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_8018B26C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018B284[])(void); - -void func_801689D8(void *a0) { - D_8018B284[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_8018B28C[])(void); - -void func_80168AA8(void *a0) { - D_8018B28C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018B294[])(void); - -void func_80168D58(void *a0) { - D_8018B294[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_8018B29C[])(void); - -void func_8016901C(void *a0) { - D_8018B29C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015AE2C", func_80169228); - - -extern void (*D_8018B2A4[])(void); - -void func_801693CC(void *a0) { - D_8018B2A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_8018B2AC[])(void); - -void func_80169830(void *a0) { - D_8018B2AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_8018B360[])(void); - -void func_80169B80(void *a0) { - D_8018B360[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018B2B4[]; - extern u8 D_8018B324[]; - extern u8 D_8018B354[]; - extern u8 D_801B2008[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018B354, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018B2B4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B2008; - RotMatrixYXZ(rot, D_801B2008); - func_80048D9C(D_801B2008, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_8018B324); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_8018B368[])(void); - -void func_80169F00(void *a0) { - D_8018B368[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_8018B318[]; -extern char D_8018B2D8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_8018B318, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018B2D8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018B3A0[])(void); - -void func_8016A020(void *a0) { - D_8018B3A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_8018B370; - extern u8 D_8018B384[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_8018B370); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018B384; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_8018B3AC[])(void); - -void func_8016A700(void *a0) { - D_8018B3AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018B3F4[])(void); - -void func_8016AB30(void *a0) { - D_8018B3F4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c b/src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c new file mode 100644 index 000000000..c1669243d --- /dev/null +++ b/src/ov_SC06_000/ov_SC06_000_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_8018A7C0; +extern u8 D_8018A730; +extern u8 D_8018A70C; +extern u8 D_8018A6E8; +extern u8 D_8018A79C; +extern u8 D_8018A778; +extern u8 D_8018A754; +extern u8 D_8018A6C4; +extern void func_80145934(void); +extern u8 D_8018A850; +extern u8 D_8018A82C; +extern u8 D_8018A808; +extern u8 D_8018A7E4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80189C48[]; +extern unsigned char D_80189C78[]; +extern unsigned char D_80189CC8[]; +extern unsigned char D_80189CF8[]; +extern unsigned char D_80189D28[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80189D78[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80189E40[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80189EC8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80189ED0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801AD480; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801AD484; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80189F00; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80189FA8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80189FCC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80189FBC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80189FE0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80189FEC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80189FFC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018A014[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018A004; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018A028[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018A044[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018A034; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018A058[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018A06C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018A080; +extern void (*D_8018A0A8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_8018A088; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018A0F4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_8018A0F8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018A55C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018A56C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801AD4B8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018A594[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018A574; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018A584; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018A5D4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_8018A5DC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_8018A5A8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018A5E8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_8018A5B8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801AD4C0; +extern s32 D_801AD4CC; +extern s32 D_801AD4D0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_8018A624[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018A5F8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801AD4C8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018A874[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018A694[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018A918[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018AA6C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_8018A888; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018AA74[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_8018A898; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_8018A8B8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018AA7C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018AAA4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018A924[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018AAB0[])(void); + +void func_8015C714(void *a0) { + D_8018AAB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018A924[])(void*); + extern int D_8018A8C8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018A924)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018A924)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018A8C8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018A924[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018A924[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018A924[])(void*); + extern int D_8018A8C8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018A924)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018A8C8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018A924)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018AAC0[])(void); + D_8018AAC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018A924[])(struct Ent_8015CD20 *); + extern u8 D_8018A8D8; + extern u8 D_8018AAC8; + extern u8 D_8018AAD8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018A924[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018A8D8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AAC8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018AAD8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018A924[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018AAF8[])(void); + D_8018AAF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018AAE8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018AAE8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018A924[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_8018AB54; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_8018AB54, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80189C38[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80189C38; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018AB5C[])(void); + D_8018AB5C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018AB68[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018AB68[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018AB68[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018AB68[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018A924[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018AB68[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018A8E8[]; + extern u8 D_8018A8F8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018A8E8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018A8F8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018AB68[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018AB68[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018AB68[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018AB9C[])(void); + D_8018AB9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018A924[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018ABA4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_8018ABBC[])(void); + D_8018ABBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018A924[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018ABA4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018ABA4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_8018ABDC[])(void); + D_8018ABDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018A924[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018A924)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_8018ABEC; +extern u16 D_8018ABEE; +extern u16 D_8018ABF0; +extern s32 D_8018ABF4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_8018ABEC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018ABEE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018ABF0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018ABF4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018ABFC; + +void func_8015E588(void) { + func_8013C9C4(&D_8018ABFC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018A924[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018A924)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018AC10[])(void); + D_8018AC10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018A924[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018A924[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018AC18[])(void); + D_8018AC18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018A908; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018A908); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018A924[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_8018AC20[])(void); + D_8018AC20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018A924[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018A924[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018AC28[])(void); + D_8018AC28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018A924[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_8018AC30; + extern s32 D_8018AC40; + extern s32 D_8018AC50; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018AC30); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018AC40); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018A924[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_8018AC50); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_8018AC60[])(void); + D_8018AC60[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018A924[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018A924[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018A924[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018A924[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018AC6C[])(void); + D_8018AC6C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018A924[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018A924[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018A924[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018A924[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018AC80[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018AC80[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018A924[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018A924)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018A924[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018A924[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018ACFC[])(void); + D_8018ACFC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018A924[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018A924)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018AD0C[])(void); + D_8018AD0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018A924[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018A924[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018A924[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018A924[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018A924[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018A924[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018A924[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018AD14[])(void); + D_8018AD14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018A924[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018A924)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018A924[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018A924)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_8018AD20[])(void); + D_8018AD20[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018A924 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018A924[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018A924[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018A924[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_8018AD30[])(void); + +void func_80160EA4(void *a0) { + D_8018AD30[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018A924[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018A924[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_8018AD60[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_8018AD60[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018ADC4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018ADC4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801AD4D8[]; + extern u8 D_8018AD90[]; + extern u8 D_8018ADB0[]; + extern u8 D_801AD4E4[]; + extern u8 D_801AD50C[]; + extern u8 D_801AD524[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801AD4D8[0] = p; + func_80024054(&D_8018AD90, &D_801AD4E4); + func_8001CE28(p, &D_801AD4E4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801AD4D8[1] = p; + func_80024054(&D_8018ADB0, &D_801AD50C); + func_8001CE28(p, &D_801AD50C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801AD4D8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801AD524, 0x84); + func_8001CE68(p, &D_801AD524); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801AD524, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801AD4D8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801AD4D8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018ADC4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018ADC4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018ADC4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018ADC4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801AD4D8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801AD4D8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018ADE8[])(void); + +void func_80162330(void *a0) { + D_8018ADE8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801AD530[i] via `extern int D_801AD530[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018ADF4[]; + extern s32 D_8018AE0C; + extern u8 D_801AD53C[]; + extern u8 D_801AD564[]; + extern u8 D_801AD580[]; + extern int D_801AD530[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801AD530[0] = (s32)item; + func_80024054(D_8018ADF4, D_801AD53C); + func_8001CE28(item, D_801AD53C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801AD530[1] = (s32)item; + func_80024054(((u8 *)&D_8018AE0C), D_801AD564); + func_8001CE28(item, D_801AD564); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801AD530[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801AD580, 0x84); + func_8001CE68(item, D_801AD580); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801AD580, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801AD530[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801AD530; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_801627E8); + + +extern void (*D_8018AE30[])(void); + +void func_80162834(void *a0) { + D_8018AE30[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_8018AE20; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_8018AE20, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801ACD90[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801ACD90, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801ACD90[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801ACD90, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018AE38[])(void); + +void func_80163A58(void *a0) { + D_8018AE38[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801ACD98; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801ACD98; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018AE8C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018AE8C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018AE54; +extern s16 D_8018AE88; +extern s16 D_8018AE86; +extern s16 D_8018AE84; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018AE54; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_8018AE88 = 0x80; + D_8018AE86 = 0x80; + D_8018AE84 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_8018AE88 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_8018AE88` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_8018AE88 - 8; + D_8018AE88 = nv; + D_8018AE86 = nv; + D_8018AE84 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_8018AE98[])(void); + +void func_80164BA0(void *a0) { + D_8018AE98[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801AD590; +extern u8 D_801AD591; +extern u8 D_801AD592; +extern u8 D_801AD593; +extern u8 D_801AD594; +extern u8 D_801AD595; +extern u8 D_801AD596; +extern u8 D_801AD597; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801AD590; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801AD591 = 0xf0; + *(u8 *)base = 0xf0; + D_801AD592 = 0xc0; + D_801AD596 = 0; + D_801AD595 = 0; + D_801AD594 = 0; + D_801AD597 = 0; + D_801AD593 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801AD590; +extern u8 D_801AD591; +extern u8 D_801AD592; + +s32 func_80164E40(void) { + u8 *p = &D_801AD590; + if (*p != 0) { + *p -= 0x10; + } + if (D_801AD591 != 0) { + D_801AD591 -= 0x10; + } + if (D_801AD592 != 0) { + D_801AD592 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_8018AEA8[])(void); + +void func_80164EA4(void *a0) { + D_8018AEA8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801AD5DC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801AD5DC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801AD5D0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801AD5D0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801AD5D0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801AD5D0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801AD5D0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_8018AEBC[]; + extern u32 D_8018AEDC, D_8018AEE0, D_8018AEE4, D_8018AEE8; + extern u32 D_8018AEDC, D_8018AEE0, D_8018AEE4, D_8018AEE8; + extern u32 D_8018AEDC, D_8018AEE0, D_8018AEE4, D_8018AEE8; + extern u32 D_8018AEDC, D_8018AEE0, D_8018AEE4, D_8018AEE8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_8018AEBC[0x00], p); + ApplyMatrixSV(mat, &D_8018AEBC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_8018AEBC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_8018AEBC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018AEE4; + *(u32 *)(prim + 0x24) = D_8018AEDC; + *(u32 *)(prim + 0x28) = D_8018AEE8; + *(u32 *)(prim + 0x2c) = D_8018AEE0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_8018AEEC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_8018AEEC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_8018AEEC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_8018AEEC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_8018AF68[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_8018AF68[a1 & 0x7F]; +} + + + +extern s32 D_8018AF88[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_8018AF88[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018B004[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018B004[a1 & 0x7F]; +} + + + +extern u8 D_8018B024[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018B024[a1 & 0x7F]; +} + + + +extern u8 D_8018B044[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018B044[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018B064[])(void); + D_8018B064[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018B0E0[])(void); + +void func_80165AC8(void) { + D_8018B0E0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018B15C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018B15C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801ACDA0; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801ACDA0, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_8018B168[])(void); + +void func_80166018(void *a0) { + D_8018B168[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_8018B170[])(void); + +void func_801663FC(void *a0) { + D_8018B170[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_8018B238[])(void); + +void func_80166618(void *a0) { + D_8018B238[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_8018B248[])(void); + +void func_80166654(void *a0) { + D_8018B248[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801AD650[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801AD650[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801AD650). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801AD650[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801AD650)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801AD650[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801AD650[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018B18C[]; + extern u8 D_8018B178[]; + extern u8 D_8018B1A0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018B18C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_8018B178; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018B1A0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80167714); + + +extern void (*D_8018B258[])(void); + +void func_801678B4(void *a0) { + D_8018B258[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018B264[])(void); + +void func_80167A9C(void *a0) { + D_8018B264[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_8018B370; + extern u8 D_8018B384[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_8018B370); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018B384; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018B1C4[]; +extern u8 D_8018B1D8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018B1C4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_8018B1D8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_8018B27C[])(void); + +void func_80168744(void *a0) { + D_8018B27C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_8018B26C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_8018B26C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_8018B26C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018B284[])(void); + +void func_801689D8(void *a0) { + D_8018B284[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_8018B28C[])(void); + +void func_80168AA8(void *a0) { + D_8018B28C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018B294[])(void); + +void func_80168D58(void *a0) { + D_8018B294[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_8018B29C[])(void); + +void func_8016901C(void *a0) { + D_8018B29C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_000/nonmatchings/ov_SC06_000_jr_8015C32C", func_80169228); + + +extern void (*D_8018B2A4[])(void); + +void func_801693CC(void *a0) { + D_8018B2A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_8018B2AC[])(void); + +void func_80169830(void *a0) { + D_8018B2AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_8018B360[])(void); + +void func_80169B80(void *a0) { + D_8018B360[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018B2B4[]; + extern u8 D_8018B324[]; + extern u8 D_8018B354[]; + extern u8 D_801B2008[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018B354, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018B2B4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B2008; + RotMatrixYXZ(rot, D_801B2008); + func_80048D9C(D_801B2008, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_8018B324); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_8018B368[])(void); + +void func_80169F00(void *a0) { + D_8018B368[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_8018B318[]; +extern char D_8018B2D8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_8018B318, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_8018B2D8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018B3A0[])(void); + +void func_8016A020(void *a0) { + D_8018B3A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_8018B370; + extern u8 D_8018B384[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_8018B370); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018B384; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_8018B3AC[])(void); + +void func_8016A700(void *a0) { + D_8018B3AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018B3F4[])(void); + +void func_8016AB30(void *a0) { + D_8018B3F4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_006/ov_SC06_006_jr_8015AE2C.c b/src/ov_SC06_006/ov_SC06_006_jr_8015AE2C.c index 651b7878a..a954d98a5 100644 --- a/src/ov_SC06_006/ov_SC06_006_jr_8015AE2C.c +++ b/src/ov_SC06_006/ov_SC06_006_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801845D4[])(void); - -void func_8015C714(void *a0) { - D_801845D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80184448[])(void*); - extern int D_801843EC; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80184448)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80184448)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801843EC); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80184448[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80184448[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80184448[])(void*); - extern int D_801843EC; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80184448)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801843EC); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80184448)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801845E4[])(void); - D_801845E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80184448[])(struct Ent_8015CD20 *); - extern u8 D_801843FC; - extern u8 D_801845EC; - extern u8 D_801845FC; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80184448[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801843FC); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801845EC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801845FC); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80184448[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018461C[])(void); - D_8018461C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018460C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018460C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80184448[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80184678; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80184678, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018375C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018375C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80184680[])(void); - D_80184680[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_8018468C[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_8018468C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_8018468C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_8018468C[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80184448[])(void *); -extern u8 D_80078E78[]; -extern u8 D_8018468C[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018440C[]; - extern u8 D_8018441C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018440C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018441C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_8018468C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018468C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018468C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801846C0[])(void); - D_801846C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184448[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801846C8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801846E0[])(void); - D_801846E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80184448[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801846C8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80184700[])(void); - D_80184700[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80184448[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184448)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80184710; -extern u16 D_80184712; -extern u16 D_80184714; -extern s32 D_80184718; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80184710 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80184712 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80184714 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184718, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80184720; - -void func_8015E588(void) { - func_8013C9C4(&D_80184720); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80184448[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80184448)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80184734[])(void); - D_80184734[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80184448[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80184448[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018473C[])(void); - D_8018473C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018442C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018442C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80184448[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80184744[])(void); - D_80184744[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80184448[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80184448[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018474C[])(void); - D_8018474C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80184448[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80184754; - extern s32 D_80184764; - extern s32 D_80184774; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80184448[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184754); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184764); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80184448[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184774); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80184784[])(void); - D_80184784[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80184448[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80184448[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80184448[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80184448[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80184790[])(void); - D_80184790[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80184448[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80184448[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80184448[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184448[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801847A4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801847A4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80184448[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80184448)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80184448[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80184448[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80184820[])(void); - D_80184820[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80184448[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80184448)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80184830[])(void); - D_80184830[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80184448[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80184448[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80184448[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80184448[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80184448[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80184448[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80184448[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80184838[])(void); - D_80184838[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80184448[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80184448)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80184448[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80184448)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80184844[])(void); - D_80184844[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184448 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80184448[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80184448[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80184448[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80184854[])(void); - -void func_80160EA4(void *a0) { - D_80184854[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80184448[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80184448[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80184884[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80184884[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801848E8; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801848E8); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801F6F20[]; - extern u8 D_801848B4[]; - extern u8 D_801848D4[]; - extern u8 D_801F6F2C[]; - extern u8 D_801F6F54[]; - extern u8 D_801F6F6C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801F6F20[0] = p; - func_80024054(&D_801848B4, &D_801F6F2C); - func_8001CE28(p, &D_801F6F2C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801F6F20[1] = p; - func_80024054(&D_801848D4, &D_801F6F54); - func_8001CE28(p, &D_801F6F54); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801F6F20[2] = p; - func_800242D0((s16)func_801620C4(), &D_801F6F6C, 0x84); - func_8001CE68(p, &D_801F6F6C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801F6F6C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801F6F20[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801F6F20; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801848E8; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801848E8; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801848E8; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801848E8; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801F6F20[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801F6F20; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018490C[])(void); - -void func_80162330(void *a0) { - D_8018490C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801F6F78[i] via `extern int D_801F6F78[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80184918[]; - extern s32 D_80184930; - extern u8 D_801F6F84[]; - extern u8 D_801F6FAC[]; - extern u8 D_801F6FC8[]; - extern int D_801F6F78[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801F6F78[0] = (s32)item; - func_80024054(D_80184918, D_801F6F84); - func_8001CE28(item, D_801F6F84); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801F6F78[1] = (s32)item; - func_80024054(((u8 *)&D_80184930), D_801F6FAC); - func_8001CE28(item, D_801F6FAC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801F6F78[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801F6FC8, 0x84); - func_8001CE68(item, D_801F6FC8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801F6FC8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801F6F78[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801F6F78; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_801627E8); - - -extern void (*D_80184954[])(void); - -void func_80162834(void *a0) { - D_80184954[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80184944; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80184944, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801F6698[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801F6698, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801F6698[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801F6698, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018495C[])(void); - -void func_80163A58(void *a0) { - D_8018495C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801F66A0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801F66A0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801849B0[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801849B0[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80184978; -extern s16 D_801849AC; -extern s16 D_801849AA; -extern s16 D_801849A8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80184978; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801849AC = 0x80; - D_801849AA = 0x80; - D_801849A8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801849AC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801849AC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801849AC - 8; - D_801849AC = nv; - D_801849AA = nv; - D_801849A8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801849BC[])(void); - -void func_80164BA0(void *a0) { - D_801849BC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801F6FD8; -extern u8 D_801F6FD9; -extern u8 D_801F6FDA; -extern u8 D_801F6FDB; -extern u8 D_801F6FDC; -extern u8 D_801F6FDD; -extern u8 D_801F6FDE; -extern u8 D_801F6FDF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801F6FD8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801F6FD9 = 0xf0; - *(u8 *)base = 0xf0; - D_801F6FDA = 0xc0; - D_801F6FDE = 0; - D_801F6FDD = 0; - D_801F6FDC = 0; - D_801F6FDF = 0; - D_801F6FDB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801F6FD8; -extern u8 D_801F6FD9; -extern u8 D_801F6FDA; - -s32 func_80164E40(void) { - u8 *p = &D_801F6FD8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801F6FD9 != 0) { - D_801F6FD9 -= 0x10; - } - if (D_801F6FDA != 0) { - D_801F6FDA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801849CC[])(void); - -void func_80164EA4(void *a0) { - D_801849CC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801F7024[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801F7024[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801F7018[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801F7018[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801F7018[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801F7018; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801F7018; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801849E0[]; - extern u32 D_80184A00, D_80184A04, D_80184A08, D_80184A0C; - extern u32 D_80184A00, D_80184A04, D_80184A08, D_80184A0C; - extern u32 D_80184A00, D_80184A04, D_80184A08, D_80184A0C; - extern u32 D_80184A00, D_80184A04, D_80184A08, D_80184A0C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801849E0[0x00], p); - ApplyMatrixSV(mat, &D_801849E0[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801849E0[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801849E0[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80184A08; - *(u32 *)(prim + 0x24) = D_80184A00; - *(u32 *)(prim + 0x28) = D_80184A0C; - *(u32 *)(prim + 0x2c) = D_80184A04; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80184A10[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80184A10[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80184A10[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80184A10[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80184A8C[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80184A8C[a1 & 0x7F]; -} - - - -extern s32 D_80184AAC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80184AAC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80184B28[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80184B28[a1 & 0x7F]; -} - - - -extern u8 D_80184B48[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80184B48[a1 & 0x7F]; -} - - - -extern u8 D_80184B68[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80184B68[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80184B88[])(void); - D_80184B88[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80184C04[])(void); - -void func_80165AC8(void) { - D_80184C04[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80184C80[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80184C80[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801F66A8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801F66A8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80184C8C[])(void); - -void func_80166018(void *a0) { - D_80184C8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80184C94[])(void); - -void func_801663FC(void *a0) { - D_80184C94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80184D5C[])(void); - -void func_80166618(void *a0) { - D_80184D5C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80184D6C[])(void); - -void func_80166654(void *a0) { - D_80184D6C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801F7098[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801F7098[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801F7098). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801F7098[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801F7098)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801F7098[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801F7098[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80184CB0[]; - extern u8 D_80184C9C[]; - extern u8 D_80184CC4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80184CB0; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80184C9C; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80184CC4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80167714); - - -extern void (*D_80184D7C[])(void); - -void func_801678B4(void *a0) { - D_80184D7C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80184D88[])(void); - -void func_80167A9C(void *a0) { - D_80184D88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80184E94; - extern u8 D_80184EA8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80184E94); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184EA8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80184CE8[]; -extern u8 D_80184CFC[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80184CE8; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80184CFC; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80184DA0[])(void); - -void func_80168744(void *a0) { - D_80184DA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80184D90 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80184D90[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80184D90; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80184DA8[])(void); - -void func_801689D8(void *a0) { - D_80184DA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80184DB0[])(void); - -void func_80168AA8(void *a0) { - D_80184DB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80184DB8[])(void); - -void func_80168D58(void *a0) { - D_80184DB8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80184DC0[])(void); - -void func_8016901C(void *a0) { - D_80184DC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015AE2C", func_80169228); - - -extern void (*D_80184DC8[])(void); - -void func_801693CC(void *a0) { - D_80184DC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80184DD0[])(void); - -void func_80169830(void *a0) { - D_80184DD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80184E84[])(void); - -void func_80169B80(void *a0) { - D_80184E84[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80184DD8[]; - extern u8 D_80184E48[]; - extern u8 D_80184E78[]; - extern u8 D_801F8A20[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80184E78, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80184DD8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801F8A20; - RotMatrixYXZ(rot, D_801F8A20); - func_80048D9C(D_801F8A20, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80184E48); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80184E8C[])(void); - -void func_80169F00(void *a0) { - D_80184E8C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80184E3C[]; -extern char D_80184DFC[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80184E3C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80184DFC); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80184EC4[])(void); - -void func_8016A020(void *a0) { - D_80184EC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80184E94; - extern u8 D_80184EA8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80184E94); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80184EA8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80184ED0[])(void); - -void func_8016A700(void *a0) { - D_80184ED0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80184F18[])(void); - -void func_8016AB30(void *a0) { - D_80184F18[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c b/src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c new file mode 100644 index 000000000..71a0b98b5 --- /dev/null +++ b/src/ov_SC06_006/ov_SC06_006_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801842E4; +extern u8 D_80184254; +extern u8 D_80184230; +extern u8 D_8018420C; +extern u8 D_801842C0; +extern u8 D_8018429C; +extern u8 D_80184278; +extern u8 D_801841E8; +extern void func_80145934(void); +extern u8 D_80184374; +extern u8 D_80184350; +extern u8 D_8018432C; +extern u8 D_80184308; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018376C[]; +extern unsigned char D_8018379C[]; +extern unsigned char D_801837EC[]; +extern unsigned char D_8018381C[]; +extern unsigned char D_8018384C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_8018389C[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80183964[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801839EC[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801839F4; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801F6EC8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801F6ECC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80183A24; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80183ACC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80183AF0[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80183AE0; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80183B04[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80183B10[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80183B20[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80183B38[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80183B28; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80183B4C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80183B68[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80183B58; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80183B7C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80183B90[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80183BA4; +extern void (*D_80183BCC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80183BAC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80183C18[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80183C1C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80184080[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80184090[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801F6F00; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801840B8[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80184098; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_801840A8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801840F8[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80184100[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801840CC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_8018410C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801840DC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801F6F08; +extern s32 D_801F6F14; +extern s32 D_801F6F18; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80184148[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_8018411C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801F6F10; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80184398[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801841B8[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018443C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80184590[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801843AC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80184598[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801843BC; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801843DC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801845A0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801845C8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80184448[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80184448[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80184448[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80184448[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80184448[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80184448[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80184448[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80184448[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801845D4[])(void); + +void func_8015C714(void *a0) { + D_801845D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80184448[])(void*); + extern int D_801843EC; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80184448)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80184448)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801843EC); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80184448[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80184448[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80184448[])(void*); + extern int D_801843EC; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80184448)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801843EC); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80184448)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801845E4[])(void); + D_801845E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80184448[])(struct Ent_8015CD20 *); + extern u8 D_801843FC; + extern u8 D_801845EC; + extern u8 D_801845FC; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80184448[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801843FC); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801845EC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801845FC); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80184448[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018461C[])(void); + D_8018461C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018460C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018460C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80184448[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80184678; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80184678, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018375C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018375C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80184680[])(void); + D_80184680[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_8018468C[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_8018468C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_8018468C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_8018468C[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80184448[])(void *); +extern u8 D_80078E78[]; +extern u8 D_8018468C[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018440C[]; + extern u8 D_8018441C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018440C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018441C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_8018468C[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_8018468C[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_8018468C[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801846C0[])(void); + D_801846C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184448[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801846C8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801846E0[])(void); + D_801846E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80184448[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801846C8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801846C8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80184700[])(void); + D_80184700[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80184448[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184448)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80184710; +extern u16 D_80184712; +extern u16 D_80184714; +extern s32 D_80184718; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80184710 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80184712 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80184714 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80184718, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80184720; + +void func_8015E588(void) { + func_8013C9C4(&D_80184720); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80184448[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80184448)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80184734[])(void); + D_80184734[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80184448[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80184448[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018473C[])(void); + D_8018473C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018442C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018442C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80184448[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80184744[])(void); + D_80184744[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80184448[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80184448[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018474C[])(void); + D_8018474C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80184448[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80184754; + extern s32 D_80184764; + extern s32 D_80184774; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80184448[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184754); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184764); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80184448[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80184774); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80184784[])(void); + D_80184784[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80184448[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80184448[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80184448[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80184448[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80184790[])(void); + D_80184790[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80184448[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80184448[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80184448[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184448[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801847A4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801847A4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80184448[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80184448)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80184448[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80184448[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80184820[])(void); + D_80184820[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80184448[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80184448)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80184830[])(void); + D_80184830[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80184448[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80184448[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80184448[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80184448[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80184448[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80184448[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80184448[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80184838[])(void); + D_80184838[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80184448[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80184448)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80184448[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80184448)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80184844[])(void); + D_80184844[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80184448 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80184448[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80184448[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80184448[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80184854[])(void); + +void func_80160EA4(void *a0) { + D_80184854[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80184448[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80184448[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80184884[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80184884[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801848E8; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801848E8); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801F6F20[]; + extern u8 D_801848B4[]; + extern u8 D_801848D4[]; + extern u8 D_801F6F2C[]; + extern u8 D_801F6F54[]; + extern u8 D_801F6F6C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801F6F20[0] = p; + func_80024054(&D_801848B4, &D_801F6F2C); + func_8001CE28(p, &D_801F6F2C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801F6F20[1] = p; + func_80024054(&D_801848D4, &D_801F6F54); + func_8001CE28(p, &D_801F6F54); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801F6F20[2] = p; + func_800242D0((s16)func_801620C4(), &D_801F6F6C, 0x84); + func_8001CE68(p, &D_801F6F6C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801F6F6C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801F6F20[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801F6F20; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801848E8; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801848E8; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801848E8; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801848E8; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801F6F20[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801F6F20; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018490C[])(void); + +void func_80162330(void *a0) { + D_8018490C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801F6F78[i] via `extern int D_801F6F78[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80184918[]; + extern s32 D_80184930; + extern u8 D_801F6F84[]; + extern u8 D_801F6FAC[]; + extern u8 D_801F6FC8[]; + extern int D_801F6F78[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801F6F78[0] = (s32)item; + func_80024054(D_80184918, D_801F6F84); + func_8001CE28(item, D_801F6F84); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801F6F78[1] = (s32)item; + func_80024054(((u8 *)&D_80184930), D_801F6FAC); + func_8001CE28(item, D_801F6FAC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801F6F78[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801F6FC8, 0x84); + func_8001CE68(item, D_801F6FC8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801F6FC8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801F6F78[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801F6F78; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_801627E8); + + +extern void (*D_80184954[])(void); + +void func_80162834(void *a0) { + D_80184954[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80184944; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80184944, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801F6698[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801F6698, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801F6698[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801F6698, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018495C[])(void); + +void func_80163A58(void *a0) { + D_8018495C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801F66A0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801F66A0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801849B0[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801849B0[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80184978; +extern s16 D_801849AC; +extern s16 D_801849AA; +extern s16 D_801849A8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80184978; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801849AC = 0x80; + D_801849AA = 0x80; + D_801849A8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801849AC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801849AC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801849AC - 8; + D_801849AC = nv; + D_801849AA = nv; + D_801849A8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801849BC[])(void); + +void func_80164BA0(void *a0) { + D_801849BC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801F6FD8; +extern u8 D_801F6FD9; +extern u8 D_801F6FDA; +extern u8 D_801F6FDB; +extern u8 D_801F6FDC; +extern u8 D_801F6FDD; +extern u8 D_801F6FDE; +extern u8 D_801F6FDF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801F6FD8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801F6FD9 = 0xf0; + *(u8 *)base = 0xf0; + D_801F6FDA = 0xc0; + D_801F6FDE = 0; + D_801F6FDD = 0; + D_801F6FDC = 0; + D_801F6FDF = 0; + D_801F6FDB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801F6FD8; +extern u8 D_801F6FD9; +extern u8 D_801F6FDA; + +s32 func_80164E40(void) { + u8 *p = &D_801F6FD8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801F6FD9 != 0) { + D_801F6FD9 -= 0x10; + } + if (D_801F6FDA != 0) { + D_801F6FDA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801849CC[])(void); + +void func_80164EA4(void *a0) { + D_801849CC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801F7024[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801F7024[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801F7018[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801F7018[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801F7018[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801F7018; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801F7018; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801849E0[]; + extern u32 D_80184A00, D_80184A04, D_80184A08, D_80184A0C; + extern u32 D_80184A00, D_80184A04, D_80184A08, D_80184A0C; + extern u32 D_80184A00, D_80184A04, D_80184A08, D_80184A0C; + extern u32 D_80184A00, D_80184A04, D_80184A08, D_80184A0C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801849E0[0x00], p); + ApplyMatrixSV(mat, &D_801849E0[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801849E0[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801849E0[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80184A08; + *(u32 *)(prim + 0x24) = D_80184A00; + *(u32 *)(prim + 0x28) = D_80184A0C; + *(u32 *)(prim + 0x2c) = D_80184A04; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80184A10[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80184A10[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80184A10[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80184A10[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80184A8C[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80184A8C[a1 & 0x7F]; +} + + + +extern s32 D_80184AAC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80184AAC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80184B28[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80184B28[a1 & 0x7F]; +} + + + +extern u8 D_80184B48[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80184B48[a1 & 0x7F]; +} + + + +extern u8 D_80184B68[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80184B68[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80184B88[])(void); + D_80184B88[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80184C04[])(void); + +void func_80165AC8(void) { + D_80184C04[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80184C80[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80184C80[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801F66A8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801F66A8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80184C8C[])(void); + +void func_80166018(void *a0) { + D_80184C8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80184C94[])(void); + +void func_801663FC(void *a0) { + D_80184C94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80184D5C[])(void); + +void func_80166618(void *a0) { + D_80184D5C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80184D6C[])(void); + +void func_80166654(void *a0) { + D_80184D6C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801F7098[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801F7098[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801F7098). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801F7098[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801F7098)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801F7098[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801F7098[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80184CB0[]; + extern u8 D_80184C9C[]; + extern u8 D_80184CC4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80184CB0; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80184C9C; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80184CC4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80167714); + + +extern void (*D_80184D7C[])(void); + +void func_801678B4(void *a0) { + D_80184D7C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80184D88[])(void); + +void func_80167A9C(void *a0) { + D_80184D88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80184E94; + extern u8 D_80184EA8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80184E94); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184EA8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80184CE8[]; +extern u8 D_80184CFC[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80184CE8; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80184CFC; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80184DA0[])(void); + +void func_80168744(void *a0) { + D_80184DA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80184D90 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80184D90[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80184D90; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80184DA8[])(void); + +void func_801689D8(void *a0) { + D_80184DA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80184DB0[])(void); + +void func_80168AA8(void *a0) { + D_80184DB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80184DB8[])(void); + +void func_80168D58(void *a0) { + D_80184DB8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80184DC0[])(void); + +void func_8016901C(void *a0) { + D_80184DC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_006/nonmatchings/ov_SC06_006_jr_8015C32C", func_80169228); + + +extern void (*D_80184DC8[])(void); + +void func_801693CC(void *a0) { + D_80184DC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80184DD0[])(void); + +void func_80169830(void *a0) { + D_80184DD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80184E84[])(void); + +void func_80169B80(void *a0) { + D_80184E84[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80184DD8[]; + extern u8 D_80184E48[]; + extern u8 D_80184E78[]; + extern u8 D_801F8A20[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80184E78, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80184DD8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801F8A20; + RotMatrixYXZ(rot, D_801F8A20); + func_80048D9C(D_801F8A20, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80184E48); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80184E8C[])(void); + +void func_80169F00(void *a0) { + D_80184E8C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80184E3C[]; +extern char D_80184DFC[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80184E3C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80184DFC); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80184EC4[])(void); + +void func_8016A020(void *a0) { + D_80184EC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80184E94; + extern u8 D_80184EA8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80184E94); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80184EA8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80184ED0[])(void); + +void func_8016A700(void *a0) { + D_80184ED0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80184F18[])(void); + +void func_8016AB30(void *a0) { + D_80184F18[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_008/ov_SC06_008_jr_8015AE2C.c b/src/ov_SC06_008/ov_SC06_008_jr_8015AE2C.c index c83424c1b..2d43f3da7 100644 --- a/src/ov_SC06_008/ov_SC06_008_jr_8015AE2C.c +++ b/src/ov_SC06_008/ov_SC06_008_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_8018803C[])(void); - -void func_8015C714(void *a0) { - D_8018803C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80187EB0[])(void*); - extern int D_80187E54; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80187EB0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80187EB0)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187E54); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80187EB0[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80187EB0[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80187EB0[])(void*); - extern int D_80187E54; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80187EB0)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187E54); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80187EB0)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_8018804C[])(void); - D_8018804C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80187EB0[])(struct Ent_8015CD20 *); - extern u8 D_80187E64; - extern u8 D_80188054; - extern u8 D_80188064; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80187EB0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187E64); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188054); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188064); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80187EB0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80188084[])(void); - D_80188084[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80188074; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80188074 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80187EB0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801880E0; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801880E0, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801871C4[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801871C4; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801880E8[])(void); - D_801880E8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801880F4[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801880F4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801880F4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801880F4[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80187EB0[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801880F4[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80187E74[]; - extern u8 D_80187E84[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187E74); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187E84); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801880F4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801880F4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801880F4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80188128[])(void); - D_80188128[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187EB0[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188130[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80188148[])(void); - D_80188148[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187EB0[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80188130[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80188168[])(void); - D_80188168[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80187EB0[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187EB0)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80188178; -extern u16 D_8018817A; -extern u16 D_8018817C; -extern s32 D_80188180; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80188178 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_8018817A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_8018817C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188180, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80188188; - -void func_8015E588(void) { - func_8013C9C4(&D_80188188); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80187EB0[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187EB0)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_8018819C[])(void); - D_8018819C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80187EB0[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80187EB0[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801881A4[])(void); - D_801881A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80187E94; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187E94); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80187EB0[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801881AC[])(void); - D_801881AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80187EB0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80187EB0[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801881B4[])(void); - D_801881B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80187EB0[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801881BC; - extern s32 D_801881CC; - extern s32 D_801881DC; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80187EB0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801881BC); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801881CC); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80187EB0[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801881DC); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801881EC[])(void); - D_801881EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80187EB0[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80187EB0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80187EB0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187EB0[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801881F8[])(void); - D_801881F8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80187EB0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187EB0[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80187EB0[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187EB0[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_8018820C[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_8018820C[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80187EB0[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80187EB0)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80187EB0[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187EB0[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80188288[])(void); - D_80188288[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80187EB0[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80187EB0)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80188298[])(void); - D_80188298[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80187EB0[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80187EB0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80187EB0[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80187EB0[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80187EB0[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80187EB0[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80187EB0[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801882A0[])(void); - D_801882A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80187EB0[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80187EB0)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80187EB0[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80187EB0)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801882AC[])(void); - D_801882AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187EB0 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80187EB0[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80187EB0[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80187EB0[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801882BC[])(void); - -void func_80160EA4(void *a0) { - D_801882BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80187EB0[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80187EB0[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801882EC[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801882EC[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80188350; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80188350); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A8EA0[]; - extern u8 D_8018831C[]; - extern u8 D_8018833C[]; - extern u8 D_801A8EAC[]; - extern u8 D_801A8ED4[]; - extern u8 D_801A8EEC[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A8EA0[0] = p; - func_80024054(&D_8018831C, &D_801A8EAC); - func_8001CE28(p, &D_801A8EAC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A8EA0[1] = p; - func_80024054(&D_8018833C, &D_801A8ED4); - func_8001CE28(p, &D_801A8ED4); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A8EA0[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A8EEC, 0x84); - func_8001CE68(p, &D_801A8EEC); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A8EEC, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A8EA0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A8EA0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80188350; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80188350; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80188350; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80188350; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A8EA0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A8EA0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80188374[])(void); - -void func_80162330(void *a0) { - D_80188374[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A8EF8[i] via `extern int D_801A8EF8[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80188380[]; - extern s32 D_80188398; - extern u8 D_801A8F04[]; - extern u8 D_801A8F2C[]; - extern u8 D_801A8F48[]; - extern int D_801A8EF8[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A8EF8[0] = (s32)item; - func_80024054(D_80188380, D_801A8F04); - func_8001CE28(item, D_801A8F04); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A8EF8[1] = (s32)item; - func_80024054(((u8 *)&D_80188398), D_801A8F2C); - func_8001CE28(item, D_801A8F2C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A8EF8[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A8F48, 0x84); - func_8001CE68(item, D_801A8F48); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A8F48, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A8EF8[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A8EF8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_801627E8); - - -extern void (*D_801883BC[])(void); - -void func_80162834(void *a0) { - D_801883BC[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_801883AC; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_801883AC, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801A8770[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801A8770, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801A8770[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801A8770, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801883C4[])(void); - -void func_80163A58(void *a0) { - D_801883C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801A8778; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801A8778; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80188418[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80188418[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801883E0; -extern s16 D_80188414; -extern s16 D_80188412; -extern s16 D_80188410; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801883E0; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80188414 = 0x80; - D_80188412 = 0x80; - D_80188410 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80188414 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188414` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80188414 - 8; - D_80188414 = nv; - D_80188412 = nv; - D_80188410 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80188424[])(void); - -void func_80164BA0(void *a0) { - D_80188424[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A8F58; -extern u8 D_801A8F59; -extern u8 D_801A8F5A; -extern u8 D_801A8F5B; -extern u8 D_801A8F5C; -extern u8 D_801A8F5D; -extern u8 D_801A8F5E; -extern u8 D_801A8F5F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A8F58; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A8F59 = 0xf0; - *(u8 *)base = 0xf0; - D_801A8F5A = 0xc0; - D_801A8F5E = 0; - D_801A8F5D = 0; - D_801A8F5C = 0; - D_801A8F5F = 0; - D_801A8F5B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A8F58; -extern u8 D_801A8F59; -extern u8 D_801A8F5A; - -s32 func_80164E40(void) { - u8 *p = &D_801A8F58; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A8F59 != 0) { - D_801A8F59 -= 0x10; - } - if (D_801A8F5A != 0) { - D_801A8F5A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80188434[])(void); - -void func_80164EA4(void *a0) { - D_80188434[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A8FA4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A8FA4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A8F98[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A8F98[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A8F98[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A8F98; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A8F98; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80188448[]; - extern u32 D_80188468, D_8018846C, D_80188470, D_80188474; - extern u32 D_80188468, D_8018846C, D_80188470, D_80188474; - extern u32 D_80188468, D_8018846C, D_80188470, D_80188474; - extern u32 D_80188468, D_8018846C, D_80188470, D_80188474; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80188448[0x00], p); - ApplyMatrixSV(mat, &D_80188448[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80188448[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80188448[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80188470; - *(u32 *)(prim + 0x24) = D_80188468; - *(u32 *)(prim + 0x28) = D_80188474; - *(u32 *)(prim + 0x2c) = D_8018846C; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80188478[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80188478[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80188478[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80188478[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801884F4[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801884F4[a1 & 0x7F]; -} - - - -extern s32 D_80188514[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80188514[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80188590[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80188590[a1 & 0x7F]; -} - - - -extern u8 D_801885B0[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801885B0[a1 & 0x7F]; -} - - - -extern u8 D_801885D0[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801885D0[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801885F0[])(void); - D_801885F0[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_8018866C[])(void); - -void func_80165AC8(void) { - D_8018866C[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801886E8[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801886E8[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801A8780; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801A8780, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801886F4[])(void); - -void func_80166018(void *a0) { - D_801886F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801886FC[])(void); - -void func_801663FC(void *a0) { - D_801886FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801887C4[])(void); - -void func_80166618(void *a0) { - D_801887C4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801887D4[])(void); - -void func_80166654(void *a0) { - D_801887D4[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A9018[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A9018[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A9018). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A9018[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A9018)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A9018[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A9018[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80188718[]; - extern u8 D_80188704[]; - extern u8 D_8018872C[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80188718; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80188704; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_8018872C; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80167714); - - -extern void (*D_801887E4[])(void); - -void func_801678B4(void *a0) { - D_801887E4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801887F0[])(void); - -void func_80167A9C(void *a0) { - D_801887F0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_801888FC; - extern u8 D_80188910[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_801888FC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188910; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80188750[]; -extern u8 D_80188764[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80188750; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80188764; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80188808[])(void); - -void func_80168744(void *a0) { - D_80188808[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801887F8 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801887F8[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801887F8; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80188810[])(void); - -void func_801689D8(void *a0) { - D_80188810[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80188818[])(void); - -void func_80168AA8(void *a0) { - D_80188818[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80188820[])(void); - -void func_80168D58(void *a0) { - D_80188820[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80188828[])(void); - -void func_8016901C(void *a0) { - D_80188828[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015AE2C", func_80169228); - - -extern void (*D_80188830[])(void); - -void func_801693CC(void *a0) { - D_80188830[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80188838[])(void); - -void func_80169830(void *a0) { - D_80188838[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_801888EC[])(void); - -void func_80169B80(void *a0) { - D_801888EC[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80188840[]; - extern u8 D_801888B0[]; - extern u8 D_801888E0[]; - extern u8 D_801AA6F0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_801888E0, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80188840[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801AA6F0; - RotMatrixYXZ(rot, D_801AA6F0); - func_80048D9C(D_801AA6F0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801888B0); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_801888F4[])(void); - -void func_80169F00(void *a0) { - D_801888F4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801888A4[]; -extern char D_80188864[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801888A4, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188864); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_8018892C[])(void); - -void func_8016A020(void *a0) { - D_8018892C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_801888FC; - extern u8 D_80188910[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_801888FC); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80188910; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80188938[])(void); - -void func_8016A700(void *a0) { - D_80188938[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80188980[])(void); - -void func_8016AB30(void *a0) { - D_80188980[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c b/src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c new file mode 100644 index 000000000..18427004f --- /dev/null +++ b/src/ov_SC06_008/ov_SC06_008_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80187D4C; +extern u8 D_80187CBC; +extern u8 D_80187C98; +extern u8 D_80187C74; +extern u8 D_80187D28; +extern u8 D_80187D04; +extern u8 D_80187CE0; +extern u8 D_80187C50; +extern void func_80145934(void); +extern u8 D_80187DDC; +extern u8 D_80187DB8; +extern u8 D_80187D94; +extern u8 D_80187D70; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801871D4[]; +extern unsigned char D_80187204[]; +extern unsigned char D_80187254[]; +extern unsigned char D_80187284[]; +extern unsigned char D_801872B4[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80187304[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801873CC[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80187454[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_8018745C; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A8E48; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A8E4C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_8018748C; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80187534[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80187558[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80187548; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_8018756C[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80187578[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80187588[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801875A0[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80187590; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801875B4[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801875D0[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801875C0; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801875E4[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801875F8[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_8018760C; +extern void (*D_80187634[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80187614; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80187680[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80187684[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80187AE8[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80187AF8[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A8E80; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80187B20[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80187B00; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80187B10; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80187B60[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80187B68[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80187B34; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80187B74[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80187B44; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A8E88; +extern s32 D_801A8E94; +extern s32 D_801A8E98; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80187BB0[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80187B84[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A8E90; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80187E00[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80187C20[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80187EA4[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80187FF8[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80187E14; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80188000[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80187E24; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80187E44; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80188008[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80188030[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80187EB0[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_8018803C[])(void); + +void func_8015C714(void *a0) { + D_8018803C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80187EB0[])(void*); + extern int D_80187E54; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80187EB0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80187EB0)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187E54); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80187EB0[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80187EB0[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80187EB0[])(void*); + extern int D_80187E54; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80187EB0)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80187E54); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80187EB0)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_8018804C[])(void); + D_8018804C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80187EB0[])(struct Ent_8015CD20 *); + extern u8 D_80187E64; + extern u8 D_80188054; + extern u8 D_80188064; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80187EB0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80187E64); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188054); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80188064); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80187EB0[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80188084[])(void); + D_80188084[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80188074; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80188074 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80187EB0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801880E0; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801880E0, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801871C4[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801871C4; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801880E8[])(void); + D_801880E8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801880F4[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801880F4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801880F4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801880F4[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80187EB0[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801880F4[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80187E74[]; + extern u8 D_80187E84[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187E74); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187E84); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801880F4[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801880F4[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801880F4[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80188128[])(void); + D_80188128[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187EB0[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188130[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80188148[])(void); + D_80188148[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187EB0[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80188130[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80188130[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80188168[])(void); + D_80188168[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80187EB0[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187EB0)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80188178; +extern u16 D_8018817A; +extern u16 D_8018817C; +extern s32 D_80188180; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80188178 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_8018817A + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_8018817C + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80188180, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80188188; + +void func_8015E588(void) { + func_8013C9C4(&D_80188188); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80187EB0[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187EB0)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_8018819C[])(void); + D_8018819C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80187EB0[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80187EB0[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801881A4[])(void); + D_801881A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80187E94; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187E94); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80187EB0[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801881AC[])(void); + D_801881AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80187EB0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80187EB0[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801881B4[])(void); + D_801881B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80187EB0[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801881BC; + extern s32 D_801881CC; + extern s32 D_801881DC; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801881BC); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801881CC); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80187EB0[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801881DC); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801881EC[])(void); + D_801881EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80187EB0[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80187EB0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80187EB0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187EB0[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801881F8[])(void); + D_801881F8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80187EB0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187EB0[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80187EB0[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187EB0[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_8018820C[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_8018820C[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80187EB0[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80187EB0)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80187EB0[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187EB0[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80188288[])(void); + D_80188288[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80187EB0[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80187EB0)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80188298[])(void); + D_80188298[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80187EB0[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80187EB0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80187EB0[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80187EB0[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80187EB0[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80187EB0[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80187EB0[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801882A0[])(void); + D_801882A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80187EB0[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80187EB0)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80187EB0[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80187EB0)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801882AC[])(void); + D_801882AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187EB0 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80187EB0[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80187EB0[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80187EB0[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801882BC[])(void); + +void func_80160EA4(void *a0) { + D_801882BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80187EB0[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80187EB0[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801882EC[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801882EC[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80188350; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80188350); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A8EA0[]; + extern u8 D_8018831C[]; + extern u8 D_8018833C[]; + extern u8 D_801A8EAC[]; + extern u8 D_801A8ED4[]; + extern u8 D_801A8EEC[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A8EA0[0] = p; + func_80024054(&D_8018831C, &D_801A8EAC); + func_8001CE28(p, &D_801A8EAC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A8EA0[1] = p; + func_80024054(&D_8018833C, &D_801A8ED4); + func_8001CE28(p, &D_801A8ED4); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A8EA0[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A8EEC, 0x84); + func_8001CE68(p, &D_801A8EEC); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A8EEC, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A8EA0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A8EA0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80188350; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80188350; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80188350; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80188350; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A8EA0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A8EA0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80188374[])(void); + +void func_80162330(void *a0) { + D_80188374[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A8EF8[i] via `extern int D_801A8EF8[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80188380[]; + extern s32 D_80188398; + extern u8 D_801A8F04[]; + extern u8 D_801A8F2C[]; + extern u8 D_801A8F48[]; + extern int D_801A8EF8[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A8EF8[0] = (s32)item; + func_80024054(D_80188380, D_801A8F04); + func_8001CE28(item, D_801A8F04); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A8EF8[1] = (s32)item; + func_80024054(((u8 *)&D_80188398), D_801A8F2C); + func_8001CE28(item, D_801A8F2C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A8EF8[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A8F48, 0x84); + func_8001CE68(item, D_801A8F48); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A8F48, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A8EF8[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A8EF8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_801627E8); + + +extern void (*D_801883BC[])(void); + +void func_80162834(void *a0) { + D_801883BC[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_801883AC; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_801883AC, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801A8770[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801A8770, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801A8770[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801A8770, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801883C4[])(void); + +void func_80163A58(void *a0) { + D_801883C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801A8778; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801A8778; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80188418[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80188418[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801883E0; +extern s16 D_80188414; +extern s16 D_80188412; +extern s16 D_80188410; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801883E0; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80188414 = 0x80; + D_80188412 = 0x80; + D_80188410 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80188414 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80188414` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80188414 - 8; + D_80188414 = nv; + D_80188412 = nv; + D_80188410 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80188424[])(void); + +void func_80164BA0(void *a0) { + D_80188424[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A8F58; +extern u8 D_801A8F59; +extern u8 D_801A8F5A; +extern u8 D_801A8F5B; +extern u8 D_801A8F5C; +extern u8 D_801A8F5D; +extern u8 D_801A8F5E; +extern u8 D_801A8F5F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A8F58; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A8F59 = 0xf0; + *(u8 *)base = 0xf0; + D_801A8F5A = 0xc0; + D_801A8F5E = 0; + D_801A8F5D = 0; + D_801A8F5C = 0; + D_801A8F5F = 0; + D_801A8F5B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A8F58; +extern u8 D_801A8F59; +extern u8 D_801A8F5A; + +s32 func_80164E40(void) { + u8 *p = &D_801A8F58; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A8F59 != 0) { + D_801A8F59 -= 0x10; + } + if (D_801A8F5A != 0) { + D_801A8F5A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80188434[])(void); + +void func_80164EA4(void *a0) { + D_80188434[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A8FA4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A8FA4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A8F98[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A8F98[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A8F98[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A8F98; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A8F98; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80188448[]; + extern u32 D_80188468, D_8018846C, D_80188470, D_80188474; + extern u32 D_80188468, D_8018846C, D_80188470, D_80188474; + extern u32 D_80188468, D_8018846C, D_80188470, D_80188474; + extern u32 D_80188468, D_8018846C, D_80188470, D_80188474; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80188448[0x00], p); + ApplyMatrixSV(mat, &D_80188448[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80188448[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80188448[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80188470; + *(u32 *)(prim + 0x24) = D_80188468; + *(u32 *)(prim + 0x28) = D_80188474; + *(u32 *)(prim + 0x2c) = D_8018846C; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80188478[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80188478[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80188478[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80188478[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801884F4[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801884F4[a1 & 0x7F]; +} + + + +extern s32 D_80188514[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80188514[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80188590[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80188590[a1 & 0x7F]; +} + + + +extern u8 D_801885B0[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801885B0[a1 & 0x7F]; +} + + + +extern u8 D_801885D0[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801885D0[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801885F0[])(void); + D_801885F0[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_8018866C[])(void); + +void func_80165AC8(void) { + D_8018866C[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801886E8[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801886E8[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801A8780; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801A8780, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801886F4[])(void); + +void func_80166018(void *a0) { + D_801886F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801886FC[])(void); + +void func_801663FC(void *a0) { + D_801886FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801887C4[])(void); + +void func_80166618(void *a0) { + D_801887C4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801887D4[])(void); + +void func_80166654(void *a0) { + D_801887D4[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A9018[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A9018[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A9018). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A9018[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A9018)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A9018[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A9018[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80188718[]; + extern u8 D_80188704[]; + extern u8 D_8018872C[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80188718; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80188704; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_8018872C; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80167714); + + +extern void (*D_801887E4[])(void); + +void func_801678B4(void *a0) { + D_801887E4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801887F0[])(void); + +void func_80167A9C(void *a0) { + D_801887F0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_801888FC; + extern u8 D_80188910[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_801888FC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188910; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80188750[]; +extern u8 D_80188764[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80188750; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80188764; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80188808[])(void); + +void func_80168744(void *a0) { + D_80188808[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801887F8 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801887F8[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801887F8; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80188810[])(void); + +void func_801689D8(void *a0) { + D_80188810[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80188818[])(void); + +void func_80168AA8(void *a0) { + D_80188818[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80188820[])(void); + +void func_80168D58(void *a0) { + D_80188820[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80188828[])(void); + +void func_8016901C(void *a0) { + D_80188828[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_008/nonmatchings/ov_SC06_008_jr_8015C32C", func_80169228); + + +extern void (*D_80188830[])(void); + +void func_801693CC(void *a0) { + D_80188830[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80188838[])(void); + +void func_80169830(void *a0) { + D_80188838[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_801888EC[])(void); + +void func_80169B80(void *a0) { + D_801888EC[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80188840[]; + extern u8 D_801888B0[]; + extern u8 D_801888E0[]; + extern u8 D_801AA6F0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_801888E0, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80188840[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801AA6F0; + RotMatrixYXZ(rot, D_801AA6F0); + func_80048D9C(D_801AA6F0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801888B0); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_801888F4[])(void); + +void func_80169F00(void *a0) { + D_801888F4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801888A4[]; +extern char D_80188864[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801888A4, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80188864); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_8018892C[])(void); + +void func_8016A020(void *a0) { + D_8018892C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_801888FC; + extern u8 D_80188910[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_801888FC); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80188910; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80188938[])(void); + +void func_8016A700(void *a0) { + D_80188938[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80188980[])(void); + +void func_8016AB30(void *a0) { + D_80188980[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_010/ov_SC06_010_jr_8015AE2C.c b/src/ov_SC06_010/ov_SC06_010_jr_8015AE2C.c index 5b819ef84..e59de7c84 100644 --- a/src/ov_SC06_010/ov_SC06_010_jr_8015AE2C.c +++ b/src/ov_SC06_010/ov_SC06_010_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80189218[])(void); - -void func_8015C714(void *a0) { - D_80189218[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_8018908C[])(void*); - extern int D_80189030; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_8018908C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_8018908C)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189030); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_8018908C[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_8018908C[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_8018908C[])(void*); - extern int D_80189030; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_8018908C)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189030); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_8018908C)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80189228[])(void); - D_80189228[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_8018908C[])(struct Ent_8015CD20 *); - extern u8 D_80189040; - extern u8 D_80189230; - extern u8 D_80189240; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_8018908C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189040); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189230); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189240); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_8018908C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80189260[])(void); - D_80189260[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80189250; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80189250 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_8018908C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801892BC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801892BC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801883A0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801883A0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801892C4[])(void); - D_801892C4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801892D0[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801892D0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801892D0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801892D0[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_8018908C[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801892D0[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80189050[]; - extern u8 D_80189060[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189050); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189060); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801892D0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801892D0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801892D0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80189304[])(void); - D_80189304[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018908C[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018930C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80189324[])(void); - D_80189324[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_8018908C[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018930C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80189344[])(void); - D_80189344[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_8018908C[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018908C)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80189354; -extern u16 D_80189356; -extern u16 D_80189358; -extern s32 D_8018935C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80189354 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80189356 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80189358 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018935C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80189364; - -void func_8015E588(void) { - func_8013C9C4(&D_80189364); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_8018908C[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_8018908C)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80189378[])(void); - D_80189378[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_8018908C[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_8018908C[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80189380[])(void); - D_80189380[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80189070; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80189070); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_8018908C[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80189388[])(void); - D_80189388[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_8018908C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_8018908C[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80189390[])(void); - D_80189390[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_8018908C[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80189398; - extern s32 D_801893A8; - extern s32 D_801893B8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_8018908C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189398); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801893A8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_8018908C[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801893B8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801893C8[])(void); - D_801893C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_8018908C[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_8018908C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_8018908C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_8018908C[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801893D4[])(void); - D_801893D4[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_8018908C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_8018908C[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_8018908C[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018908C[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801893E8[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801893E8[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_8018908C[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_8018908C)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_8018908C[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_8018908C[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80189464[])(void); - D_80189464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_8018908C[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_8018908C)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80189474[])(void); - D_80189474[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_8018908C[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_8018908C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_8018908C[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_8018908C[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_8018908C[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_8018908C[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_8018908C[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_8018947C[])(void); - D_8018947C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_8018908C[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_8018908C)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_8018908C[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_8018908C)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80189488[])(void); - D_80189488[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018908C + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_8018908C[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_8018908C[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_8018908C[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80189498[])(void); - -void func_80160EA4(void *a0) { - D_80189498[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_8018908C[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_8018908C[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801894C8[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801894C8[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_8018952C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_8018952C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801B0ED8[]; - extern u8 D_801894F8[]; - extern u8 D_80189518[]; - extern u8 D_801B0EE4[]; - extern u8 D_801B0F0C[]; - extern u8 D_801B0F24[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801B0ED8[0] = p; - func_80024054(&D_801894F8, &D_801B0EE4); - func_8001CE28(p, &D_801B0EE4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801B0ED8[1] = p; - func_80024054(&D_80189518, &D_801B0F0C); - func_8001CE28(p, &D_801B0F0C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801B0ED8[2] = p; - func_800242D0((s16)func_801620C4(), &D_801B0F24, 0x84); - func_8001CE68(p, &D_801B0F24); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801B0F24, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B0ED8[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801B0ED8; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_8018952C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_8018952C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_8018952C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_8018952C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801B0ED8[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801B0ED8; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80189550[])(void); - -void func_80162330(void *a0) { - D_80189550[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801B0F30[i] via `extern int D_801B0F30[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_8018955C[]; - extern s32 D_80189574; - extern u8 D_801B0F3C[]; - extern u8 D_801B0F64[]; - extern u8 D_801B0F80[]; - extern int D_801B0F30[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801B0F30[0] = (s32)item; - func_80024054(D_8018955C, D_801B0F3C); - func_8001CE28(item, D_801B0F3C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801B0F30[1] = (s32)item; - func_80024054(((u8 *)&D_80189574), D_801B0F64); - func_8001CE28(item, D_801B0F64); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801B0F30[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801B0F80, 0x84); - func_8001CE68(item, D_801B0F80); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801B0F80, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801B0F30[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801B0F30; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_801627E8); - - -extern void (*D_80189598[])(void); - -void func_80162834(void *a0) { - D_80189598[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80189588; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80189588, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801B07C4[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801B07C4, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801B07C4[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801B07C4, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_801895A0[])(void); - -void func_80163A58(void *a0) { - D_801895A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801B07CC; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801B07CC; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801895F4[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801895F4[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_801895BC; -extern s16 D_801895F0; -extern s16 D_801895EE; -extern s16 D_801895EC; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_801895BC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801895F0 = 0x80; - D_801895EE = 0x80; - D_801895EC = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801895F0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801895F0` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801895F0 - 8; - D_801895F0 = nv; - D_801895EE = nv; - D_801895EC = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80189600[])(void); - -void func_80164BA0(void *a0) { - D_80189600[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801B0F90; -extern u8 D_801B0F91; -extern u8 D_801B0F92; -extern u8 D_801B0F93; -extern u8 D_801B0F94; -extern u8 D_801B0F95; -extern u8 D_801B0F96; -extern u8 D_801B0F97; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801B0F90; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801B0F91 = 0xf0; - *(u8 *)base = 0xf0; - D_801B0F92 = 0xc0; - D_801B0F96 = 0; - D_801B0F95 = 0; - D_801B0F94 = 0; - D_801B0F97 = 0; - D_801B0F93 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801B0F90; -extern u8 D_801B0F91; -extern u8 D_801B0F92; - -s32 func_80164E40(void) { - u8 *p = &D_801B0F90; - if (*p != 0) { - *p -= 0x10; - } - if (D_801B0F91 != 0) { - D_801B0F91 -= 0x10; - } - if (D_801B0F92 != 0) { - D_801B0F92 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80189610[])(void); - -void func_80164EA4(void *a0) { - D_80189610[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801B0FDC[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801B0FDC[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801B0FD0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801B0FD0[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801B0FD0[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801B0FD0; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801B0FD0; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80189624[]; - extern u32 D_80189644, D_80189648, D_8018964C, D_80189650; - extern u32 D_80189644, D_80189648, D_8018964C, D_80189650; - extern u32 D_80189644, D_80189648, D_8018964C, D_80189650; - extern u32 D_80189644, D_80189648, D_8018964C, D_80189650; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80189624[0x00], p); - ApplyMatrixSV(mat, &D_80189624[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80189624[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80189624[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_8018964C; - *(u32 *)(prim + 0x24) = D_80189644; - *(u32 *)(prim + 0x28) = D_80189650; - *(u32 *)(prim + 0x2c) = D_80189648; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80189654[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80189654[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80189654[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80189654[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801896D0[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801896D0[a1 & 0x7F]; -} - - - -extern s32 D_801896F0[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801896F0[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_8018976C[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_8018976C[a1 & 0x7F]; -} - - - -extern u8 D_8018978C[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_8018978C[a1 & 0x7F]; -} - - - -extern u8 D_801897AC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_801897AC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801897CC[])(void); - D_801897CC[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80189848[])(void); - -void func_80165AC8(void) { - D_80189848[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_801898C4[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_801898C4[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801B07D4; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801B07D4, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_801898D0[])(void); - -void func_80166018(void *a0) { - D_801898D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_801898D8[])(void); - -void func_801663FC(void *a0) { - D_801898D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_801899A0[])(void); - -void func_80166618(void *a0) { - D_801899A0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_801899B0[])(void); - -void func_80166654(void *a0) { - D_801899B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801B1050[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801B1050[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B1050). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801B1050[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801B1050)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801B1050[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801B1050[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_801898F4[]; - extern u8 D_801898E0[]; - extern u8 D_80189908[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_801898F4; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_801898E0; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80189908; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80167714); - - -extern void (*D_801899C0[])(void); - -void func_801678B4(void *a0) { - D_801899C0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_801899CC[])(void); - -void func_80167A9C(void *a0) { - D_801899CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80189AD8; - extern u8 D_80189AEC[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80189AD8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80189AEC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018992C[]; -extern u8 D_80189940[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018992C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80189940; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_801899E4[])(void); - -void func_80168744(void *a0) { - D_801899E4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_801899D4 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_801899D4[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_801899D4; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_801899EC[])(void); - -void func_801689D8(void *a0) { - D_801899EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_801899F4[])(void); - -void func_80168AA8(void *a0) { - D_801899F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_801899FC[])(void); - -void func_80168D58(void *a0) { - D_801899FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80189A04[])(void); - -void func_8016901C(void *a0) { - D_80189A04[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015AE2C", func_80169228); - - -extern void (*D_80189A0C[])(void); - -void func_801693CC(void *a0) { - D_80189A0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80189A14[])(void); - -void func_80169830(void *a0) { - D_80189A14[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80189AC8[])(void); - -void func_80169B80(void *a0) { - D_80189AC8[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80189A1C[]; - extern u8 D_80189A8C[]; - extern u8 D_80189ABC[]; - extern u8 D_801B2B38[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80189ABC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80189A1C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801B2B38; - RotMatrixYXZ(rot, D_801B2B38); - func_80048D9C(D_801B2B38, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80189A8C); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80189AD0[])(void); - -void func_80169F00(void *a0) { - D_80189AD0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80189A80[]; -extern char D_80189A40[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80189A80, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80189A40); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80189B08[])(void); - -void func_8016A020(void *a0) { - D_80189B08[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80189AD8; - extern u8 D_80189AEC[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80189AD8); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80189AEC; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80189B14[])(void); - -void func_8016A700(void *a0) { - D_80189B14[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80189B5C[])(void); - -void func_8016AB30(void *a0) { - D_80189B5C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c b/src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c new file mode 100644 index 000000000..6cf55d553 --- /dev/null +++ b/src/ov_SC06_010/ov_SC06_010_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80188F28; +extern u8 D_80188E98; +extern u8 D_80188E74; +extern u8 D_80188E50; +extern u8 D_80188F04; +extern u8 D_80188EE0; +extern u8 D_80188EBC; +extern u8 D_80188E2C; +extern void func_80145934(void); +extern u8 D_80188FB8; +extern u8 D_80188F94; +extern u8 D_80188F70; +extern u8 D_80188F4C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801883B0[]; +extern unsigned char D_801883E0[]; +extern unsigned char D_80188430[]; +extern unsigned char D_80188460[]; +extern unsigned char D_80188490[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801884E0[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_801885A8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80188630[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80188638; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801B0E80; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801B0E84; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80188668; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80188710[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80188734[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80188724; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80188748[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80188754[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80188764[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_8018877C[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_8018876C; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80188790[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_801887AC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_8018879C; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_801887C0[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801887D4[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801887E8; +extern void (*D_80188810[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801887F0; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_8018885C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80188860[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80188CC4[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80188CD4[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801B0EB8; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80188CFC[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80188CDC; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80188CEC; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80188D3C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80188D44[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80188D10; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80188D50[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80188D20; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801B0EC0; +extern s32 D_801B0ECC; +extern s32 D_801B0ED0; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80188D8C[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80188D60[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801B0EC8; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80188FDC[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80188DFC[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80189080[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801891D4[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80188FF0; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801891DC[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80189000; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80189020; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801891E4[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018920C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_8018908C[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80189218[])(void); + +void func_8015C714(void *a0) { + D_80189218[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_8018908C[])(void*); + extern int D_80189030; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_8018908C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_8018908C)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189030); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_8018908C[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_8018908C[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_8018908C[])(void*); + extern int D_80189030; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_8018908C)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80189030); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_8018908C)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80189228[])(void); + D_80189228[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_8018908C[])(struct Ent_8015CD20 *); + extern u8 D_80189040; + extern u8 D_80189230; + extern u8 D_80189240; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_8018908C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189040); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189230); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80189240); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_8018908C[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80189260[])(void); + D_80189260[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80189250; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80189250 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_8018908C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801892BC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801892BC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801883A0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801883A0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801892C4[])(void); + D_801892C4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801892D0[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801892D0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801892D0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801892D0[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_8018908C[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801892D0[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80189050[]; + extern u8 D_80189060[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189050); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80189060); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801892D0[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801892D0[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801892D0[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80189304[])(void); + D_80189304[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018908C[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018930C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80189324[])(void); + D_80189324[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_8018908C[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018930C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018930C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80189344[])(void); + D_80189344[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_8018908C[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018908C)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80189354; +extern u16 D_80189356; +extern u16 D_80189358; +extern s32 D_8018935C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80189354 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80189356 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80189358 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018935C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80189364; + +void func_8015E588(void) { + func_8013C9C4(&D_80189364); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_8018908C[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_8018908C)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80189378[])(void); + D_80189378[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_8018908C[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_8018908C[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80189380[])(void); + D_80189380[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80189070; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80189070); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_8018908C[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80189388[])(void); + D_80189388[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_8018908C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_8018908C[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80189390[])(void); + D_80189390[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_8018908C[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80189398; + extern s32 D_801893A8; + extern s32 D_801893B8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80189398); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801893A8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_8018908C[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801893B8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801893C8[])(void); + D_801893C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_8018908C[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_8018908C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_8018908C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_8018908C[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801893D4[])(void); + D_801893D4[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_8018908C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_8018908C[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_8018908C[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018908C[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801893E8[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801893E8[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_8018908C[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_8018908C)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_8018908C[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_8018908C[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80189464[])(void); + D_80189464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_8018908C[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_8018908C)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80189474[])(void); + D_80189474[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_8018908C[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_8018908C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_8018908C[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_8018908C[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_8018908C[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_8018908C[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_8018908C[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_8018947C[])(void); + D_8018947C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_8018908C[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_8018908C)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_8018908C[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_8018908C)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80189488[])(void); + D_80189488[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_8018908C + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_8018908C[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_8018908C[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_8018908C[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80189498[])(void); + +void func_80160EA4(void *a0) { + D_80189498[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_8018908C[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_8018908C[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801894C8[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801894C8[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_8018952C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_8018952C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801B0ED8[]; + extern u8 D_801894F8[]; + extern u8 D_80189518[]; + extern u8 D_801B0EE4[]; + extern u8 D_801B0F0C[]; + extern u8 D_801B0F24[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801B0ED8[0] = p; + func_80024054(&D_801894F8, &D_801B0EE4); + func_8001CE28(p, &D_801B0EE4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801B0ED8[1] = p; + func_80024054(&D_80189518, &D_801B0F0C); + func_8001CE28(p, &D_801B0F0C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801B0ED8[2] = p; + func_800242D0((s16)func_801620C4(), &D_801B0F24, 0x84); + func_8001CE68(p, &D_801B0F24); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801B0F24, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B0ED8[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801B0ED8; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_8018952C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_8018952C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_8018952C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_8018952C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801B0ED8[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801B0ED8; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80189550[])(void); + +void func_80162330(void *a0) { + D_80189550[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801B0F30[i] via `extern int D_801B0F30[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_8018955C[]; + extern s32 D_80189574; + extern u8 D_801B0F3C[]; + extern u8 D_801B0F64[]; + extern u8 D_801B0F80[]; + extern int D_801B0F30[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801B0F30[0] = (s32)item; + func_80024054(D_8018955C, D_801B0F3C); + func_8001CE28(item, D_801B0F3C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801B0F30[1] = (s32)item; + func_80024054(((u8 *)&D_80189574), D_801B0F64); + func_8001CE28(item, D_801B0F64); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801B0F30[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801B0F80, 0x84); + func_8001CE68(item, D_801B0F80); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801B0F80, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801B0F30[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801B0F30; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_801627E8); + + +extern void (*D_80189598[])(void); + +void func_80162834(void *a0) { + D_80189598[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80189588; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80189588, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801B07C4[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801B07C4, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801B07C4[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801B07C4, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_801895A0[])(void); + +void func_80163A58(void *a0) { + D_801895A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801B07CC; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801B07CC; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801895F4[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801895F4[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_801895BC; +extern s16 D_801895F0; +extern s16 D_801895EE; +extern s16 D_801895EC; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_801895BC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801895F0 = 0x80; + D_801895EE = 0x80; + D_801895EC = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801895F0 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801895F0` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801895F0 - 8; + D_801895F0 = nv; + D_801895EE = nv; + D_801895EC = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80189600[])(void); + +void func_80164BA0(void *a0) { + D_80189600[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801B0F90; +extern u8 D_801B0F91; +extern u8 D_801B0F92; +extern u8 D_801B0F93; +extern u8 D_801B0F94; +extern u8 D_801B0F95; +extern u8 D_801B0F96; +extern u8 D_801B0F97; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801B0F90; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801B0F91 = 0xf0; + *(u8 *)base = 0xf0; + D_801B0F92 = 0xc0; + D_801B0F96 = 0; + D_801B0F95 = 0; + D_801B0F94 = 0; + D_801B0F97 = 0; + D_801B0F93 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801B0F90; +extern u8 D_801B0F91; +extern u8 D_801B0F92; + +s32 func_80164E40(void) { + u8 *p = &D_801B0F90; + if (*p != 0) { + *p -= 0x10; + } + if (D_801B0F91 != 0) { + D_801B0F91 -= 0x10; + } + if (D_801B0F92 != 0) { + D_801B0F92 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80189610[])(void); + +void func_80164EA4(void *a0) { + D_80189610[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801B0FDC[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801B0FDC[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801B0FD0[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801B0FD0[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801B0FD0[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801B0FD0; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801B0FD0; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80189624[]; + extern u32 D_80189644, D_80189648, D_8018964C, D_80189650; + extern u32 D_80189644, D_80189648, D_8018964C, D_80189650; + extern u32 D_80189644, D_80189648, D_8018964C, D_80189650; + extern u32 D_80189644, D_80189648, D_8018964C, D_80189650; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80189624[0x00], p); + ApplyMatrixSV(mat, &D_80189624[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80189624[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80189624[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_8018964C; + *(u32 *)(prim + 0x24) = D_80189644; + *(u32 *)(prim + 0x28) = D_80189650; + *(u32 *)(prim + 0x2c) = D_80189648; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80189654[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80189654[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80189654[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80189654[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801896D0[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801896D0[a1 & 0x7F]; +} + + + +extern s32 D_801896F0[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801896F0[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_8018976C[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_8018976C[a1 & 0x7F]; +} + + + +extern u8 D_8018978C[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_8018978C[a1 & 0x7F]; +} + + + +extern u8 D_801897AC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_801897AC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801897CC[])(void); + D_801897CC[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80189848[])(void); + +void func_80165AC8(void) { + D_80189848[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_801898C4[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_801898C4[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801B07D4; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801B07D4, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_801898D0[])(void); + +void func_80166018(void *a0) { + D_801898D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_801898D8[])(void); + +void func_801663FC(void *a0) { + D_801898D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_801899A0[])(void); + +void func_80166618(void *a0) { + D_801899A0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_801899B0[])(void); + +void func_80166654(void *a0) { + D_801899B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801B1050[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801B1050[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801B1050). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801B1050[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801B1050)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801B1050[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801B1050[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_801898F4[]; + extern u8 D_801898E0[]; + extern u8 D_80189908[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_801898F4; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_801898E0; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80189908; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80167714); + + +extern void (*D_801899C0[])(void); + +void func_801678B4(void *a0) { + D_801899C0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_801899CC[])(void); + +void func_80167A9C(void *a0) { + D_801899CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80189AD8; + extern u8 D_80189AEC[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80189AD8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80189AEC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018992C[]; +extern u8 D_80189940[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018992C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80189940; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_801899E4[])(void); + +void func_80168744(void *a0) { + D_801899E4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_801899D4 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_801899D4[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_801899D4; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_801899EC[])(void); + +void func_801689D8(void *a0) { + D_801899EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_801899F4[])(void); + +void func_80168AA8(void *a0) { + D_801899F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_801899FC[])(void); + +void func_80168D58(void *a0) { + D_801899FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80189A04[])(void); + +void func_8016901C(void *a0) { + D_80189A04[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_010/nonmatchings/ov_SC06_010_jr_8015C32C", func_80169228); + + +extern void (*D_80189A0C[])(void); + +void func_801693CC(void *a0) { + D_80189A0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80189A14[])(void); + +void func_80169830(void *a0) { + D_80189A14[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80189AC8[])(void); + +void func_80169B80(void *a0) { + D_80189AC8[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80189A1C[]; + extern u8 D_80189A8C[]; + extern u8 D_80189ABC[]; + extern u8 D_801B2B38[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80189ABC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80189A1C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801B2B38; + RotMatrixYXZ(rot, D_801B2B38); + func_80048D9C(D_801B2B38, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80189A8C); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80189AD0[])(void); + +void func_80169F00(void *a0) { + D_80189AD0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80189A80[]; +extern char D_80189A40[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80189A80, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80189A40); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80189B08[])(void); + +void func_8016A020(void *a0) { + D_80189B08[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80189AD8; + extern u8 D_80189AEC[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80189AD8); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80189AEC; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80189B14[])(void); + +void func_8016A700(void *a0) { + D_80189B14[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80189B5C[])(void); + +void func_8016AB30(void *a0) { + D_80189B5C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_011/ov_SC06_011_jr_8015AE2C.c b/src/ov_SC06_011/ov_SC06_011_jr_8015AE2C.c index 9ed04e2d9..c2d849627 100644 --- a/src/ov_SC06_011/ov_SC06_011_jr_8015AE2C.c +++ b/src/ov_SC06_011/ov_SC06_011_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80182C78[])(void); - -void func_8015C714(void *a0) { - D_80182C78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80182AEC[])(void*); - extern int D_80182A90; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80182AEC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80182AEC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182A90); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80182AEC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80182AEC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80182AEC[])(void*); - extern int D_80182A90; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80182AEC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182A90); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80182AEC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80182C88[])(void); - D_80182C88[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80182AEC[])(struct Ent_8015CD20 *); - extern u8 D_80182AA0; - extern u8 D_80182C90; - extern u8 D_80182CA0; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80182AEC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182AA0); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182C90); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182CA0); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80182AEC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80182CC0[])(void); - D_80182CC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80182CB0; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80182CB0 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80182AEC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80182D1C; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80182D1C, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80181E00[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80181E00; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80182D24[])(void); - D_80182D24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80182D30[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80182D30[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80182D30[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80182D30[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80182AEC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80182D30[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80182AB0[]; - extern u8 D_80182AC0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182AB0); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182AC0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80182D30[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80182D30[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80182D30[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80182D64[])(void); - D_80182D64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182AEC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182D6C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80182D84[])(void); - D_80182D84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80182AEC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_80182D6C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80182DA4[])(void); - D_80182DA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80182AEC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182AEC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80182DB4; -extern u16 D_80182DB6; -extern u16 D_80182DB8; -extern s32 D_80182DBC; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80182DB4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80182DB6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80182DB8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182DBC, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80182DC4; - -void func_8015E588(void) { - func_8013C9C4(&D_80182DC4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80182AEC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80182AEC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80182DD8[])(void); - D_80182DD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80182AEC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80182AEC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80182DE0[])(void); - D_80182DE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80182AD0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182AD0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80182AEC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80182DE8[])(void); - D_80182DE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80182AEC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80182AEC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80182DF0[])(void); - D_80182DF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80182AEC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80182DF8; - extern s32 D_80182E08; - extern s32 D_80182E18; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80182AEC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182DF8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E08); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80182AEC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E18); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80182E28[])(void); - D_80182E28[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80182AEC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80182AEC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80182AEC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80182AEC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80182E34[])(void); - D_80182E34[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80182AEC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80182AEC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80182AEC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182AEC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80182E48[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80182E48[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80182AEC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80182AEC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80182AEC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80182AEC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80182EC4[])(void); - D_80182EC4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80182AEC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80182AEC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80182ED4[])(void); - D_80182ED4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80182AEC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80182AEC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80182AEC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80182AEC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80182AEC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80182AEC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80182AEC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80182EDC[])(void); - D_80182EDC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80182AEC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80182AEC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80182AEC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80182AEC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80182EE8[])(void); - D_80182EE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182AEC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80182AEC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80182AEC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80182AEC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80182EF8[])(void); - -void func_80160EA4(void *a0) { - D_80182EF8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80182AEC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80182AEC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80182F28[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80182F28[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80182F8C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80182F8C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801AAA88[]; - extern u8 D_80182F58[]; - extern u8 D_80182F78[]; - extern u8 D_801AAA94[]; - extern u8 D_801AAABC[]; - extern u8 D_801AAAD4[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801AAA88[0] = p; - func_80024054(&D_80182F58, &D_801AAA94); - func_8001CE28(p, &D_801AAA94); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801AAA88[1] = p; - func_80024054(&D_80182F78, &D_801AAABC); - func_8001CE28(p, &D_801AAABC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801AAA88[2] = p; - func_800242D0((s16)func_801620C4(), &D_801AAAD4, 0x84); - func_8001CE68(p, &D_801AAAD4); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801AAAD4, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801AAA88[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801AAA88; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80182F8C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80182F8C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80182F8C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80182F8C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801AAA88[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801AAA88; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80182FB0[])(void); - -void func_80162330(void *a0) { - D_80182FB0[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801AAAE0[i] via `extern int D_801AAAE0[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80182FBC[]; - extern s32 D_80182FD4; - extern u8 D_801AAAEC[]; - extern u8 D_801AAB14[]; - extern u8 D_801AAB30[]; - extern int D_801AAAE0[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801AAAE0[0] = (s32)item; - func_80024054(D_80182FBC, D_801AAAEC); - func_8001CE28(item, D_801AAAEC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801AAAE0[1] = (s32)item; - func_80024054(((u8 *)&D_80182FD4), D_801AAB14); - func_8001CE28(item, D_801AAB14); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801AAAE0[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801AAB30, 0x84); - func_8001CE68(item, D_801AAB30); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801AAB30, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801AAAE0[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801AAAE0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_801627E8); - - -extern void (*D_80182FF8[])(void); - -void func_80162834(void *a0) { - D_80182FF8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80182FE8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80182FE8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801AA324[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801AA324, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801AA324[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801AA324, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80183000[])(void); - -void func_80163A58(void *a0) { - D_80183000[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_801AA32C; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_801AA32C; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80183054[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80183054[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_8018301C; -extern s16 D_80183050; -extern s16 D_8018304E; -extern s16 D_8018304C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_8018301C; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80183050 = 0x80; - D_8018304E = 0x80; - D_8018304C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80183050 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80183050` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80183050 - 8; - D_80183050 = nv; - D_8018304E = nv; - D_8018304C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80183060[])(void); - -void func_80164BA0(void *a0) { - D_80183060[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801AAB40; -extern u8 D_801AAB41; -extern u8 D_801AAB42; -extern u8 D_801AAB43; -extern u8 D_801AAB44; -extern u8 D_801AAB45; -extern u8 D_801AAB46; -extern u8 D_801AAB47; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801AAB40; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801AAB41 = 0xf0; - *(u8 *)base = 0xf0; - D_801AAB42 = 0xc0; - D_801AAB46 = 0; - D_801AAB45 = 0; - D_801AAB44 = 0; - D_801AAB47 = 0; - D_801AAB43 = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801AAB40; -extern u8 D_801AAB41; -extern u8 D_801AAB42; - -s32 func_80164E40(void) { - u8 *p = &D_801AAB40; - if (*p != 0) { - *p -= 0x10; - } - if (D_801AAB41 != 0) { - D_801AAB41 -= 0x10; - } - if (D_801AAB42 != 0) { - D_801AAB42 -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80183070[])(void); - -void func_80164EA4(void *a0) { - D_80183070[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801AAB8C[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801AAB8C[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801AAB80[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801AAB80[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801AAB80[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801AAB80; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801AAB80; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80183084[]; - extern u32 D_801830A4, D_801830A8, D_801830AC, D_801830B0; - extern u32 D_801830A4, D_801830A8, D_801830AC, D_801830B0; - extern u32 D_801830A4, D_801830A8, D_801830AC, D_801830B0; - extern u32 D_801830A4, D_801830A8, D_801830AC, D_801830B0; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80183084[0x00], p); - ApplyMatrixSV(mat, &D_80183084[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80183084[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80183084[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801830AC; - *(u32 *)(prim + 0x24) = D_801830A4; - *(u32 *)(prim + 0x28) = D_801830B0; - *(u32 *)(prim + 0x2c) = D_801830A8; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801830B4[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801830B4[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801830B4[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801830B4[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80183130[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80183130[a1 & 0x7F]; -} - - - -extern s32 D_80183150[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80183150[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_801831CC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_801831CC[a1 & 0x7F]; -} - - - -extern u8 D_801831EC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_801831EC[a1 & 0x7F]; -} - - - -extern u8 D_8018320C[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_8018320C[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_8018322C[])(void); - D_8018322C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801832A8[])(void); - -void func_80165AC8(void) { - D_801832A8[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80183324[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80183324[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_801AA334; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_801AA334, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80183330[])(void); - -void func_80166018(void *a0) { - D_80183330[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80183338[])(void); - -void func_801663FC(void *a0) { - D_80183338[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80183400[])(void); - -void func_80166618(void *a0) { - D_80183400[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80183410[])(void); - -void func_80166654(void *a0) { - D_80183410[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801AAC00[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801AAC00[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801AAC00). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801AAC00[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801AAC00)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801AAC00[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801AAC00[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80183354[]; - extern u8 D_80183340[]; - extern u8 D_80183368[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80183354; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80183340; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80183368; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80167714); - - -extern void (*D_80183420[])(void); - -void func_801678B4(void *a0) { - D_80183420[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_8018342C[])(void); - -void func_80167A9C(void *a0) { - D_8018342C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80183538; - extern u8 D_8018354C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80183538); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018354C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_8018338C[]; -extern u8 D_801833A0[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_8018338C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801833A0; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80183444[])(void); - -void func_80168744(void *a0) { - D_80183444[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80183434 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80183434[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80183434; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_8018344C[])(void); - -void func_801689D8(void *a0) { - D_8018344C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80183454[])(void); - -void func_80168AA8(void *a0) { - D_80183454[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_8018345C[])(void); - -void func_80168D58(void *a0) { - D_8018345C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80183464[])(void); - -void func_8016901C(void *a0) { - D_80183464[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015AE2C", func_80169228); - - -extern void (*D_8018346C[])(void); - -void func_801693CC(void *a0) { - D_8018346C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80183474[])(void); - -void func_80169830(void *a0) { - D_80183474[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80183528[])(void); - -void func_80169B80(void *a0) { - D_80183528[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_8018347C[]; - extern u8 D_801834EC[]; - extern u8 D_8018351C[]; - extern u8 D_801ABC10[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_8018351C, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_8018347C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801ABC10; - RotMatrixYXZ(rot, D_801ABC10); - func_80048D9C(D_801ABC10, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_801834EC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80183530[])(void); - -void func_80169F00(void *a0) { - D_80183530[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_801834E0[]; -extern char D_801834A0[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_801834E0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801834A0); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80183568[])(void); - -void func_8016A020(void *a0) { - D_80183568[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80183538; - extern u8 D_8018354C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80183538); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018354C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80183574[])(void); - -void func_8016A700(void *a0) { - D_80183574[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_801835BC[])(void); - -void func_8016AB30(void *a0) { - D_801835BC[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c b/src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c new file mode 100644 index 000000000..a6a49dfb4 --- /dev/null +++ b/src/ov_SC06_011/ov_SC06_011_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80182988; +extern u8 D_801828F8; +extern u8 D_801828D4; +extern u8 D_801828B0; +extern u8 D_80182964; +extern u8 D_80182940; +extern u8 D_8018291C; +extern u8 D_8018288C; +extern void func_80145934(void); +extern u8 D_80182A18; +extern u8 D_801829F4; +extern u8 D_801829D0; +extern u8 D_801829AC; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80181E10[]; +extern unsigned char D_80181E40[]; +extern unsigned char D_80181E90[]; +extern unsigned char D_80181EC0[]; +extern unsigned char D_80181EF0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80181F40[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80182008[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80182090[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80182098; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801AAA30; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801AAA34; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_801820C8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80182170[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80182194[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80182184; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801821A8[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801821B4[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801821C4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_801821DC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_801821CC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_801821F0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_8018220C[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_801821FC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80182220[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80182234[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80182248; +extern void (*D_80182270[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80182250; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801822BC[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801822C0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80182724[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80182734[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801AAA68; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018275C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018273C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018274C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018279C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801827A4[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80182770; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801827B0[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80182780; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801AAA70; +extern s32 D_801AAA7C; +extern s32 D_801AAA80; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801827EC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801827C0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801AAA78; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80182A3C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018285C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80182AE0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80182C34[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80182A50; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80182C3C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80182A60; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80182A80; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80182C44[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_80182C6C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80182AEC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80182C78[])(void); + +void func_8015C714(void *a0) { + D_80182C78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80182AEC[])(void*); + extern int D_80182A90; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80182AEC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80182AEC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182A90); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80182AEC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80182AEC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80182AEC[])(void*); + extern int D_80182A90; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80182AEC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182A90); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80182AEC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80182C88[])(void); + D_80182C88[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80182AEC[])(struct Ent_8015CD20 *); + extern u8 D_80182AA0; + extern u8 D_80182C90; + extern u8 D_80182CA0; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80182AEC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182AA0); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182C90); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182CA0); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80182AEC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80182CC0[])(void); + D_80182CC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80182CB0; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80182CB0 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80182AEC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80182D1C; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80182D1C, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80181E00[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80181E00; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80182D24[])(void); + D_80182D24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80182D30[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80182D30[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80182D30[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80182D30[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80182AEC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80182D30[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80182AB0[]; + extern u8 D_80182AC0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182AB0); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182AC0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80182D30[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80182D30[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80182D30[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80182D64[])(void); + D_80182D64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182AEC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182D6C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80182D84[])(void); + D_80182D84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80182AEC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_80182D6C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_80182D6C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80182DA4[])(void); + D_80182DA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80182AEC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182AEC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80182DB4; +extern u16 D_80182DB6; +extern u16 D_80182DB8; +extern s32 D_80182DBC; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80182DB4 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80182DB6 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80182DB8 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80182DBC, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80182DC4; + +void func_8015E588(void) { + func_8013C9C4(&D_80182DC4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80182AEC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80182AEC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80182DD8[])(void); + D_80182DD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80182AEC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80182AEC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80182DE0[])(void); + D_80182DE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80182AD0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80182AD0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80182AEC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80182DE8[])(void); + D_80182DE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80182AEC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80182AEC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80182DF0[])(void); + D_80182DF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80182AEC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80182DF8; + extern s32 D_80182E08; + extern s32 D_80182E18; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182DF8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E08); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80182AEC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80182E18); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80182E28[])(void); + D_80182E28[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80182AEC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80182AEC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80182AEC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80182AEC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80182E34[])(void); + D_80182E34[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80182AEC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80182AEC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80182AEC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182AEC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80182E48[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80182E48[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80182AEC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80182AEC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80182AEC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80182AEC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80182EC4[])(void); + D_80182EC4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80182AEC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80182AEC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80182ED4[])(void); + D_80182ED4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80182AEC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80182AEC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80182AEC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80182AEC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80182AEC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80182AEC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80182AEC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80182EDC[])(void); + D_80182EDC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80182AEC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80182AEC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80182AEC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80182AEC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80182EE8[])(void); + D_80182EE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80182AEC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80182AEC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80182AEC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80182AEC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80182EF8[])(void); + +void func_80160EA4(void *a0) { + D_80182EF8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80182AEC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80182AEC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80182F28[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80182F28[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80182F8C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80182F8C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801AAA88[]; + extern u8 D_80182F58[]; + extern u8 D_80182F78[]; + extern u8 D_801AAA94[]; + extern u8 D_801AAABC[]; + extern u8 D_801AAAD4[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801AAA88[0] = p; + func_80024054(&D_80182F58, &D_801AAA94); + func_8001CE28(p, &D_801AAA94); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801AAA88[1] = p; + func_80024054(&D_80182F78, &D_801AAABC); + func_8001CE28(p, &D_801AAABC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801AAA88[2] = p; + func_800242D0((s16)func_801620C4(), &D_801AAAD4, 0x84); + func_8001CE68(p, &D_801AAAD4); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801AAAD4, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801AAA88[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801AAA88; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80182F8C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80182F8C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80182F8C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80182F8C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801AAA88[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801AAA88; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80182FB0[])(void); + +void func_80162330(void *a0) { + D_80182FB0[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801AAAE0[i] via `extern int D_801AAAE0[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80182FBC[]; + extern s32 D_80182FD4; + extern u8 D_801AAAEC[]; + extern u8 D_801AAB14[]; + extern u8 D_801AAB30[]; + extern int D_801AAAE0[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801AAAE0[0] = (s32)item; + func_80024054(D_80182FBC, D_801AAAEC); + func_8001CE28(item, D_801AAAEC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801AAAE0[1] = (s32)item; + func_80024054(((u8 *)&D_80182FD4), D_801AAB14); + func_8001CE28(item, D_801AAB14); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801AAAE0[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801AAB30, 0x84); + func_8001CE68(item, D_801AAB30); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801AAB30, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801AAAE0[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801AAAE0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_801627E8); + + +extern void (*D_80182FF8[])(void); + +void func_80162834(void *a0) { + D_80182FF8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80182FE8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80182FE8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801AA324[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801AA324, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801AA324[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801AA324, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80183000[])(void); + +void func_80163A58(void *a0) { + D_80183000[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_801AA32C; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_801AA32C; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80183054[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80183054[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_8018301C; +extern s16 D_80183050; +extern s16 D_8018304E; +extern s16 D_8018304C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_8018301C; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80183050 = 0x80; + D_8018304E = 0x80; + D_8018304C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80183050 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80183050` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80183050 - 8; + D_80183050 = nv; + D_8018304E = nv; + D_8018304C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80183060[])(void); + +void func_80164BA0(void *a0) { + D_80183060[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801AAB40; +extern u8 D_801AAB41; +extern u8 D_801AAB42; +extern u8 D_801AAB43; +extern u8 D_801AAB44; +extern u8 D_801AAB45; +extern u8 D_801AAB46; +extern u8 D_801AAB47; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801AAB40; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801AAB41 = 0xf0; + *(u8 *)base = 0xf0; + D_801AAB42 = 0xc0; + D_801AAB46 = 0; + D_801AAB45 = 0; + D_801AAB44 = 0; + D_801AAB47 = 0; + D_801AAB43 = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801AAB40; +extern u8 D_801AAB41; +extern u8 D_801AAB42; + +s32 func_80164E40(void) { + u8 *p = &D_801AAB40; + if (*p != 0) { + *p -= 0x10; + } + if (D_801AAB41 != 0) { + D_801AAB41 -= 0x10; + } + if (D_801AAB42 != 0) { + D_801AAB42 -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80183070[])(void); + +void func_80164EA4(void *a0) { + D_80183070[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801AAB8C[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801AAB8C[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801AAB80[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801AAB80[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801AAB80[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801AAB80; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801AAB80; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80183084[]; + extern u32 D_801830A4, D_801830A8, D_801830AC, D_801830B0; + extern u32 D_801830A4, D_801830A8, D_801830AC, D_801830B0; + extern u32 D_801830A4, D_801830A8, D_801830AC, D_801830B0; + extern u32 D_801830A4, D_801830A8, D_801830AC, D_801830B0; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80183084[0x00], p); + ApplyMatrixSV(mat, &D_80183084[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80183084[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80183084[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801830AC; + *(u32 *)(prim + 0x24) = D_801830A4; + *(u32 *)(prim + 0x28) = D_801830B0; + *(u32 *)(prim + 0x2c) = D_801830A8; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801830B4[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801830B4[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801830B4[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801830B4[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80183130[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80183130[a1 & 0x7F]; +} + + + +extern s32 D_80183150[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80183150[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_801831CC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_801831CC[a1 & 0x7F]; +} + + + +extern u8 D_801831EC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_801831EC[a1 & 0x7F]; +} + + + +extern u8 D_8018320C[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_8018320C[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_8018322C[])(void); + D_8018322C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801832A8[])(void); + +void func_80165AC8(void) { + D_801832A8[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80183324[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80183324[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_801AA334; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_801AA334, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80183330[])(void); + +void func_80166018(void *a0) { + D_80183330[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80183338[])(void); + +void func_801663FC(void *a0) { + D_80183338[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80183400[])(void); + +void func_80166618(void *a0) { + D_80183400[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80183410[])(void); + +void func_80166654(void *a0) { + D_80183410[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801AAC00[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801AAC00[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801AAC00). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801AAC00[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801AAC00)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801AAC00[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801AAC00[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80183354[]; + extern u8 D_80183340[]; + extern u8 D_80183368[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80183354; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80183340; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80183368; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80167714); + + +extern void (*D_80183420[])(void); + +void func_801678B4(void *a0) { + D_80183420[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_8018342C[])(void); + +void func_80167A9C(void *a0) { + D_8018342C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80183538; + extern u8 D_8018354C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80183538); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018354C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_8018338C[]; +extern u8 D_801833A0[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_8018338C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801833A0; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80183444[])(void); + +void func_80168744(void *a0) { + D_80183444[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80183434 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80183434[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80183434; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_8018344C[])(void); + +void func_801689D8(void *a0) { + D_8018344C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80183454[])(void); + +void func_80168AA8(void *a0) { + D_80183454[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_8018345C[])(void); + +void func_80168D58(void *a0) { + D_8018345C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80183464[])(void); + +void func_8016901C(void *a0) { + D_80183464[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_011/nonmatchings/ov_SC06_011_jr_8015C32C", func_80169228); + + +extern void (*D_8018346C[])(void); + +void func_801693CC(void *a0) { + D_8018346C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80183474[])(void); + +void func_80169830(void *a0) { + D_80183474[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80183528[])(void); + +void func_80169B80(void *a0) { + D_80183528[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_8018347C[]; + extern u8 D_801834EC[]; + extern u8 D_8018351C[]; + extern u8 D_801ABC10[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_8018351C, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_8018347C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801ABC10; + RotMatrixYXZ(rot, D_801ABC10); + func_80048D9C(D_801ABC10, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_801834EC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80183530[])(void); + +void func_80169F00(void *a0) { + D_80183530[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_801834E0[]; +extern char D_801834A0[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_801834E0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_801834A0); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80183568[])(void); + +void func_8016A020(void *a0) { + D_80183568[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80183538; + extern u8 D_8018354C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80183538); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018354C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80183574[])(void); + +void func_8016A700(void *a0) { + D_80183574[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_801835BC[])(void); + +void func_8016AB30(void *a0) { + D_801835BC[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_013/ov_SC06_013_jr_8015AE2C.c b/src/ov_SC06_013/ov_SC06_013_jr_8015AE2C.c index c14fb120e..46d8b5eab 100644 --- a/src/ov_SC06_013/ov_SC06_013_jr_8015AE2C.c +++ b/src/ov_SC06_013/ov_SC06_013_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801813F4[])(void); - -void func_8015C714(void *a0) { - D_801813F4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181268[])(void*); - extern int D_8018120C; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181268)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181268)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018120C); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181268[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181268[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181268[])(void*); - extern int D_8018120C; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181268)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018120C); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181268)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80181404[])(void); - D_80181404[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181268[])(struct Ent_8015CD20 *); - extern u8 D_8018121C; - extern u8 D_8018140C; - extern u8 D_8018141C; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181268[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018121C); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018140C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018141C); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181268[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_8018143C[])(void); - D_8018143C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_8018142C; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_8018142C | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181268[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181498; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181498, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_8018057C[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_8018057C; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_801814A0[])(void); - D_801814A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_801814AC[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_801814AC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_801814AC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_801814AC[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181268[])(void *); -extern u8 D_80078E78[]; -extern u8 D_801814AC[]; - -void func_8015D738(void *arg0) { - - extern u8 D_8018122C[]; - extern u8 D_8018123C[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018122C); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018123C); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_801814AC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_801814AC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_801814AC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801814E0[])(void); - D_801814E0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181268[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801814E8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80181500[])(void); - D_80181500[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181268[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801814E8[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80181520[])(void); - D_80181520[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181268[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181268)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80181530; -extern u16 D_80181532; -extern u16 D_80181534; -extern s32 D_80181538; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80181530 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80181532 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80181534 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181538, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_80181540; - -void func_8015E588(void) { - func_8013C9C4(&D_80181540); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181268[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181268)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181554[])(void); - D_80181554[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181268[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181268[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_8018155C[])(void); - D_8018155C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_8018124C; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018124C); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181268[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181564[])(void); - D_80181564[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181268[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181268[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_8018156C[])(void); - D_8018156C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181268[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181574; - extern s32 D_80181584; - extern s32 D_80181594; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181268[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181574); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181584); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181268[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181594); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_801815A4[])(void); - D_801815A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181268[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181268[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181268[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181268[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_801815B0[])(void); - D_801815B0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181268[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181268[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181268[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181268[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_801815C4[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_801815C4[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181268[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181268)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181268[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181268[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_80181640[])(void); - D_80181640[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181268[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181268)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_80181650[])(void); - D_80181650[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181268[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181268[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181268[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181268[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181268[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181268[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181268[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181658[])(void); - D_80181658[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181268[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181268)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181268[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181268)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181664[])(void); - D_80181664[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181268 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181268[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181268[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181268[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181674[])(void); - -void func_80160EA4(void *a0) { - D_80181674[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181268[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181268[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_801816A4[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_801816A4[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80181708; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80181708); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80199940[]; - extern u8 D_801816D4[]; - extern u8 D_801816F4[]; - extern u8 D_8019994C[]; - extern u8 D_80199974[]; - extern u8 D_8019998C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80199940[0] = p; - func_80024054(&D_801816D4, &D_8019994C); - func_8001CE28(p, &D_8019994C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80199940[1] = p; - func_80024054(&D_801816F4, &D_80199974); - func_8001CE28(p, &D_80199974); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80199940[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019998C, 0x84); - func_8001CE68(p, &D_8019998C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019998C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80199940[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80199940; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80181708; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80181708; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80181708; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80181708; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80199940[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80199940; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_8018172C[])(void); - -void func_80162330(void *a0) { - D_8018172C[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80199998[i] via `extern int D_80199998[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80181738[]; - extern s32 D_80181750; - extern u8 D_801999A4[]; - extern u8 D_801999CC[]; - extern u8 D_801999E8[]; - extern int D_80199998[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80199998[0] = (s32)item; - func_80024054(D_80181738, D_801999A4); - func_8001CE28(item, D_801999A4); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80199998[1] = (s32)item; - func_80024054(((u8 *)&D_80181750), D_801999CC); - func_8001CE28(item, D_801999CC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80199998[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801999E8, 0x84); - func_8001CE68(item, D_801999E8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801999E8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80199998[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80199998; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181774[])(void); - -void func_80162834(void *a0) { - D_80181774[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181764; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181764, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_801991F8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_801991F8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_801991F8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_801991F8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_8018177C[])(void); - -void func_80163A58(void *a0) { - D_8018177C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80199200; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80199200; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_801817D0[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_801817D0[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181798; -extern s16 D_801817CC; -extern s16 D_801817CA; -extern s16 D_801817C8; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181798; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_801817CC = 0x80; - D_801817CA = 0x80; - D_801817C8 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_801817CC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801817CC` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_801817CC - 8; - D_801817CC = nv; - D_801817CA = nv; - D_801817C8 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_801817DC[])(void); - -void func_80164BA0(void *a0) { - D_801817DC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801999F8; -extern u8 D_801999F9; -extern u8 D_801999FA; -extern u8 D_801999FB; -extern u8 D_801999FC; -extern u8 D_801999FD; -extern u8 D_801999FE; -extern u8 D_801999FF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801999F8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801999F9 = 0xf0; - *(u8 *)base = 0xf0; - D_801999FA = 0xc0; - D_801999FE = 0; - D_801999FD = 0; - D_801999FC = 0; - D_801999FF = 0; - D_801999FB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801999F8; -extern u8 D_801999F9; -extern u8 D_801999FA; - -s32 func_80164E40(void) { - u8 *p = &D_801999F8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801999F9 != 0) { - D_801999F9 -= 0x10; - } - if (D_801999FA != 0) { - D_801999FA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801817EC[])(void); - -void func_80164EA4(void *a0) { - D_801817EC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80199A44[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80199A44[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80199A38[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80199A38[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80199A38[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80199A38; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80199A38; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80181800[]; - extern u32 D_80181820, D_80181824, D_80181828, D_8018182C; - extern u32 D_80181820, D_80181824, D_80181828, D_8018182C; - extern u32 D_80181820, D_80181824, D_80181828, D_8018182C; - extern u32 D_80181820, D_80181824, D_80181828, D_8018182C; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80181800[0x00], p); - ApplyMatrixSV(mat, &D_80181800[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80181800[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80181800[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80181828; - *(u32 *)(prim + 0x24) = D_80181820; - *(u32 *)(prim + 0x28) = D_8018182C; - *(u32 *)(prim + 0x2c) = D_80181824; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80181830[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80181830[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80181830[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80181830[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_801818AC[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_801818AC[a1 & 0x7F]; -} - - - -extern s32 D_801818CC[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_801818CC[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181948[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181948[a1 & 0x7F]; -} - - - -extern u8 D_80181968[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80181968[a1 & 0x7F]; -} - - - -extern u8 D_80181988[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181988[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_801819A8[])(void); - D_801819A8[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80181A24[])(void); - -void func_80165AC8(void) { - D_80181A24[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80181AA0[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80181AA0[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80199208; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80199208, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80181AAC[])(void); - -void func_80166018(void *a0) { - D_80181AAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181AB4[])(void); - -void func_801663FC(void *a0) { - D_80181AB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80181B7C[])(void); - -void func_80166618(void *a0) { - D_80181B7C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181B8C[])(void); - -void func_80166654(void *a0) { - D_80181B8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80199AB8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80199AB8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80199AB8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80199AB8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80199AB8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80199AB8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80199AB8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80181AD0[]; - extern u8 D_80181ABC[]; - extern u8 D_80181AE4[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80181AD0; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80181ABC; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80181AE4; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80167714); - - -extern void (*D_80181B9C[])(void); - -void func_801678B4(void *a0) { - D_80181B9C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181BA8[])(void); - -void func_80167A9C(void *a0) { - D_80181BA8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181CB4; - extern u8 D_80181CC8[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181CB4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181CC8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80181B08[]; -extern u8 D_80181B1C[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80181B08; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80181B1C; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181BC0[])(void); - -void func_80168744(void *a0) { - D_80181BC0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181BB0 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181BB0[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181BB0; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181BC8[])(void); - -void func_801689D8(void *a0) { - D_80181BC8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181BD0[])(void); - -void func_80168AA8(void *a0) { - D_80181BD0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181BD8[])(void); - -void func_80168D58(void *a0) { - D_80181BD8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181BE0[])(void); - -void func_8016901C(void *a0) { - D_80181BE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015AE2C", func_80169228); - - -extern void (*D_80181BE8[])(void); - -void func_801693CC(void *a0) { - D_80181BE8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181BF0[])(void); - -void func_80169830(void *a0) { - D_80181BF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181CA4[])(void); - -void func_80169B80(void *a0) { - D_80181CA4[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181BF8[]; - extern u8 D_80181C68[]; - extern u8 D_80181C98[]; - extern u8 D_8019AAC0[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181C98, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181BF8[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_8019AAC0; - RotMatrixYXZ(rot, D_8019AAC0); - func_80048D9C(D_8019AAC0, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181C68); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181CAC[])(void); - -void func_80169F00(void *a0) { - D_80181CAC[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80181C5C[]; -extern char D_80181C1C[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80181C5C, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181C1C); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181CE4[])(void); - -void func_8016A020(void *a0) { - D_80181CE4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181CB4; - extern u8 D_80181CC8[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181CB4); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181CC8; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181CF0[])(void); - -void func_8016A700(void *a0) { - D_80181CF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80181D38[])(void); - -void func_8016AB30(void *a0) { - D_80181D38[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c b/src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c new file mode 100644 index 000000000..49239db44 --- /dev/null +++ b/src/ov_SC06_013/ov_SC06_013_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80181104; +extern u8 D_80181074; +extern u8 D_80181050; +extern u8 D_8018102C; +extern u8 D_801810E0; +extern u8 D_801810BC; +extern u8 D_80181098; +extern u8 D_80181008; +extern void func_80145934(void); +extern u8 D_80181194; +extern u8 D_80181170; +extern u8 D_8018114C; +extern u8 D_80181128; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_8018058C[]; +extern unsigned char D_801805BC[]; +extern unsigned char D_8018060C[]; +extern unsigned char D_8018063C[]; +extern unsigned char D_8018066C[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_801806BC[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80180784[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_8018080C[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80180814; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801998E8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801998EC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180844; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801808EC[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80180910[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80180900; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80180924[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80180930[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80180940[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80180958[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180948; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_8018096C[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80180988[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80180978; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_8018099C[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_801809B0[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_801809C4; +extern void (*D_801809EC[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_801809CC; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80180A38[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80180A3C[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180EA0[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180EB0[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_80199920; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180ED8[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180EB8; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180EC8; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180F18[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180F20[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180EEC; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80180F2C[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180EFC; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_80199928; +extern s32 D_80199934; +extern s32 D_80199938; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180F68[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80180F3C[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80199930; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_801811B8[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180FD8[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_8018125C[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_801813B0[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_801811CC; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_801813B8[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801811DC; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801811FC; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_801813C0[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801813E8[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181268[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181268[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181268[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181268[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181268[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181268[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181268[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181268[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801813F4[])(void); + +void func_8015C714(void *a0) { + D_801813F4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181268[])(void*); + extern int D_8018120C; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181268)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181268)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018120C); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181268[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181268[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181268[])(void*); + extern int D_8018120C; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181268)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_8018120C); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181268)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80181404[])(void); + D_80181404[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181268[])(struct Ent_8015CD20 *); + extern u8 D_8018121C; + extern u8 D_8018140C; + extern u8 D_8018141C; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181268[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018121C); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018140C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_8018141C); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181268[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_8018143C[])(void); + D_8018143C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_8018142C; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_8018142C | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181268[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181498; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181498, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_8018057C[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_8018057C; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_801814A0[])(void); + D_801814A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_801814AC[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_801814AC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_801814AC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_801814AC[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181268[])(void *); +extern u8 D_80078E78[]; +extern u8 D_801814AC[]; + +void func_8015D738(void *arg0) { + + extern u8 D_8018122C[]; + extern u8 D_8018123C[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018122C); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_8018123C); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_801814AC[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_801814AC[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_801814AC[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801814E0[])(void); + D_801814E0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181268[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801814E8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80181500[])(void); + D_80181500[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181268[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801814E8[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801814E8[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80181520[])(void); + D_80181520[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181268[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181268)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80181530; +extern u16 D_80181532; +extern u16 D_80181534; +extern s32 D_80181538; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80181530 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80181532 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80181534 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80181538, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_80181540; + +void func_8015E588(void) { + func_8013C9C4(&D_80181540); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181268[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181268)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181554[])(void); + D_80181554[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181268[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181268[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_8018155C[])(void); + D_8018155C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_8018124C; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_8018124C); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181268[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181564[])(void); + D_80181564[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181268[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181268[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_8018156C[])(void); + D_8018156C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181268[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181574; + extern s32 D_80181584; + extern s32 D_80181594; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181268[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181574); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181584); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181268[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181594); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_801815A4[])(void); + D_801815A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181268[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181268[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181268[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181268[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_801815B0[])(void); + D_801815B0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181268[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181268[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181268[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181268[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_801815C4[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_801815C4[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181268[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181268)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181268[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181268[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_80181640[])(void); + D_80181640[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181268[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181268)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_80181650[])(void); + D_80181650[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181268[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181268[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181268[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181268[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181268[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181268[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181268[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181658[])(void); + D_80181658[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181268[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181268)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181268[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181268)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181664[])(void); + D_80181664[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181268 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181268[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181268[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181268[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181674[])(void); + +void func_80160EA4(void *a0) { + D_80181674[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181268[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181268[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_801816A4[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_801816A4[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80181708; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80181708); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80199940[]; + extern u8 D_801816D4[]; + extern u8 D_801816F4[]; + extern u8 D_8019994C[]; + extern u8 D_80199974[]; + extern u8 D_8019998C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80199940[0] = p; + func_80024054(&D_801816D4, &D_8019994C); + func_8001CE28(p, &D_8019994C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80199940[1] = p; + func_80024054(&D_801816F4, &D_80199974); + func_8001CE28(p, &D_80199974); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80199940[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019998C, 0x84); + func_8001CE68(p, &D_8019998C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019998C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80199940[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80199940; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80181708; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80181708; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80181708; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80181708; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80199940[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80199940; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_8018172C[])(void); + +void func_80162330(void *a0) { + D_8018172C[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80199998[i] via `extern int D_80199998[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80181738[]; + extern s32 D_80181750; + extern u8 D_801999A4[]; + extern u8 D_801999CC[]; + extern u8 D_801999E8[]; + extern int D_80199998[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80199998[0] = (s32)item; + func_80024054(D_80181738, D_801999A4); + func_8001CE28(item, D_801999A4); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80199998[1] = (s32)item; + func_80024054(((u8 *)&D_80181750), D_801999CC); + func_8001CE28(item, D_801999CC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80199998[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801999E8, 0x84); + func_8001CE68(item, D_801999E8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801999E8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80199998[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80199998; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_801627E8); + + +extern void (*D_80181774[])(void); + +void func_80162834(void *a0) { + D_80181774[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181764; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181764, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_801991F8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_801991F8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_801991F8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_801991F8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_8018177C[])(void); + +void func_80163A58(void *a0) { + D_8018177C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80199200; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80199200; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_801817D0[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_801817D0[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181798; +extern s16 D_801817CC; +extern s16 D_801817CA; +extern s16 D_801817C8; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181798; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_801817CC = 0x80; + D_801817CA = 0x80; + D_801817C8 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_801817CC read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_801817CC` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_801817CC - 8; + D_801817CC = nv; + D_801817CA = nv; + D_801817C8 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_801817DC[])(void); + +void func_80164BA0(void *a0) { + D_801817DC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801999F8; +extern u8 D_801999F9; +extern u8 D_801999FA; +extern u8 D_801999FB; +extern u8 D_801999FC; +extern u8 D_801999FD; +extern u8 D_801999FE; +extern u8 D_801999FF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801999F8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801999F9 = 0xf0; + *(u8 *)base = 0xf0; + D_801999FA = 0xc0; + D_801999FE = 0; + D_801999FD = 0; + D_801999FC = 0; + D_801999FF = 0; + D_801999FB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801999F8; +extern u8 D_801999F9; +extern u8 D_801999FA; + +s32 func_80164E40(void) { + u8 *p = &D_801999F8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801999F9 != 0) { + D_801999F9 -= 0x10; + } + if (D_801999FA != 0) { + D_801999FA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801817EC[])(void); + +void func_80164EA4(void *a0) { + D_801817EC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80199A44[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80199A44[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80199A38[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80199A38[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80199A38[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80199A38; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80199A38; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80181800[]; + extern u32 D_80181820, D_80181824, D_80181828, D_8018182C; + extern u32 D_80181820, D_80181824, D_80181828, D_8018182C; + extern u32 D_80181820, D_80181824, D_80181828, D_8018182C; + extern u32 D_80181820, D_80181824, D_80181828, D_8018182C; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80181800[0x00], p); + ApplyMatrixSV(mat, &D_80181800[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80181800[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80181800[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80181828; + *(u32 *)(prim + 0x24) = D_80181820; + *(u32 *)(prim + 0x28) = D_8018182C; + *(u32 *)(prim + 0x2c) = D_80181824; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80181830[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80181830[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80181830[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80181830[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_801818AC[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_801818AC[a1 & 0x7F]; +} + + + +extern s32 D_801818CC[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_801818CC[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181948[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181948[a1 & 0x7F]; +} + + + +extern u8 D_80181968[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80181968[a1 & 0x7F]; +} + + + +extern u8 D_80181988[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181988[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_801819A8[])(void); + D_801819A8[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80181A24[])(void); + +void func_80165AC8(void) { + D_80181A24[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80181AA0[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80181AA0[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80199208; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80199208, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80181AAC[])(void); + +void func_80166018(void *a0) { + D_80181AAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181AB4[])(void); + +void func_801663FC(void *a0) { + D_80181AB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80181B7C[])(void); + +void func_80166618(void *a0) { + D_80181B7C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181B8C[])(void); + +void func_80166654(void *a0) { + D_80181B8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80199AB8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80199AB8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80199AB8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80199AB8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80199AB8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80199AB8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80199AB8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80181AD0[]; + extern u8 D_80181ABC[]; + extern u8 D_80181AE4[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80181AD0; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80181ABC; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80181AE4; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80167714); + + +extern void (*D_80181B9C[])(void); + +void func_801678B4(void *a0) { + D_80181B9C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181BA8[])(void); + +void func_80167A9C(void *a0) { + D_80181BA8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181CB4; + extern u8 D_80181CC8[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181CB4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181CC8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80181B08[]; +extern u8 D_80181B1C[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80181B08; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80181B1C; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181BC0[])(void); + +void func_80168744(void *a0) { + D_80181BC0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181BB0 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181BB0[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181BB0; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181BC8[])(void); + +void func_801689D8(void *a0) { + D_80181BC8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181BD0[])(void); + +void func_80168AA8(void *a0) { + D_80181BD0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181BD8[])(void); + +void func_80168D58(void *a0) { + D_80181BD8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181BE0[])(void); + +void func_8016901C(void *a0) { + D_80181BE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_013/nonmatchings/ov_SC06_013_jr_8015C32C", func_80169228); + + +extern void (*D_80181BE8[])(void); + +void func_801693CC(void *a0) { + D_80181BE8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181BF0[])(void); + +void func_80169830(void *a0) { + D_80181BF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181CA4[])(void); + +void func_80169B80(void *a0) { + D_80181CA4[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181BF8[]; + extern u8 D_80181C68[]; + extern u8 D_80181C98[]; + extern u8 D_8019AAC0[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181C98, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181BF8[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_8019AAC0; + RotMatrixYXZ(rot, D_8019AAC0); + func_80048D9C(D_8019AAC0, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181C68); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181CAC[])(void); + +void func_80169F00(void *a0) { + D_80181CAC[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80181C5C[]; +extern char D_80181C1C[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80181C5C, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181C1C); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181CE4[])(void); + +void func_8016A020(void *a0) { + D_80181CE4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181CB4; + extern u8 D_80181CC8[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181CB4); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181CC8; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181CF0[])(void); + +void func_8016A700(void *a0) { + D_80181CF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80181D38[])(void); + +void func_8016AB30(void *a0) { + D_80181D38[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_014/ov_SC06_014_jr_8015AE2C.c b/src/ov_SC06_014/ov_SC06_014_jr_8015AE2C.c index 9d0a4eafb..d8adafe4b 100644 --- a/src/ov_SC06_014/ov_SC06_014_jr_8015AE2C.c +++ b/src/ov_SC06_014/ov_SC06_014_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_80182758[])(void); - -void func_8015C714(void *a0) { - D_80182758[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_801825CC[])(void*); - extern int D_80182570; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_801825CC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_801825CC)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182570); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_801825CC[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_801825CC[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_801825CC[])(void*); - extern int D_80182570; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_801825CC)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182570); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_801825CC)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_80182768[])(void); - D_80182768[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_801825CC[])(struct Ent_8015CD20 *); - extern u8 D_80182580; - extern u8 D_80182770; - extern u8 D_80182780; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_801825CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182580); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182770); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182780); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_801825CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801827A0[])(void); - D_801827A0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_80182790; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_80182790 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_801825CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_801827FC; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_801827FC, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_801818E0[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_801818E0; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_80182804[])(void); - D_80182804[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80182810[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80182810[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80182810[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80182810[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_801825CC[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80182810[]; - -void func_8015D738(void *arg0) { - - extern u8 D_80182590[]; - extern u8 D_801825A0[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182590); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801825A0); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80182810[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80182810[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80182810[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_80182844[])(void); - D_80182844[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801825CC[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018284C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_80182864[])(void); - D_80182864[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_801825CC[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_8018284C[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_80182884[])(void); - D_80182884[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_801825CC[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801825CC)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_80182894; -extern u16 D_80182896; -extern u16 D_80182898; -extern s32 D_8018289C; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_80182894 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_80182896 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80182898 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018289C, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801828A4; - -void func_8015E588(void) { - func_8013C9C4(&D_801828A4); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_801825CC[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_801825CC)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_801828B8[])(void); - D_801828B8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_801825CC[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_801825CC[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_801828C0[])(void); - D_801828C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_801825B0; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_801825B0); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_801825CC[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_801828C8[])(void); - D_801828C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_801825CC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_801825CC[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_801828D0[])(void); - D_801828D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_801825CC[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_801828D8; - extern s32 D_801828E8; - extern s32 D_801828F8; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_801825CC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828D8); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828E8); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_801825CC[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828F8); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80182908[])(void); - D_80182908[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_801825CC[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_801825CC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_801825CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_801825CC[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_80182914[])(void); - D_80182914[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_801825CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_801825CC[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_801825CC[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801825CC[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80182928[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80182928[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_801825CC[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_801825CC)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_801825CC[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_801825CC[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801829A4[])(void); - D_801829A4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_801825CC[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_801825CC)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_801829B4[])(void); - D_801829B4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_801825CC[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_801825CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_801825CC[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_801825CC[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_801825CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_801825CC[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_801825CC[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_801829BC[])(void); - D_801829BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_801825CC[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_801825CC)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_801825CC[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_801825CC)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_801829C8[])(void); - D_801829C8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801825CC + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_801825CC[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_801825CC[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_801825CC[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_801829D8[])(void); - -void func_80160EA4(void *a0) { - D_801829D8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_801825CC[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_801825CC[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80182A08[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80182A08[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_80182A6C; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_80182A6C); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_801A0330[]; - extern u8 D_80182A38[]; - extern u8 D_80182A58[]; - extern u8 D_801A033C[]; - extern u8 D_801A0364[]; - extern u8 D_801A037C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_801A0330[0] = p; - func_80024054(&D_80182A38, &D_801A033C); - func_8001CE28(p, &D_801A033C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_801A0330[1] = p; - func_80024054(&D_80182A58, &D_801A0364); - func_8001CE28(p, &D_801A0364); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_801A0330[2] = p; - func_800242D0((s16)func_801620C4(), &D_801A037C, 0x84); - func_8001CE68(p, &D_801A037C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_801A037C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A0330[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_801A0330; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_80182A6C; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_80182A6C; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_80182A6C; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_80182A6C; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_801A0330[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_801A0330; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_80182A90[])(void); - -void func_80162330(void *a0) { - D_80182A90[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_801A0388[i] via `extern int D_801A0388[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80182A9C[]; - extern s32 D_80182AB4; - extern u8 D_801A0394[]; - extern u8 D_801A03BC[]; - extern u8 D_801A03D8[]; - extern int D_801A0388[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_801A0388[0] = (s32)item; - func_80024054(D_80182A9C, D_801A0394); - func_8001CE28(item, D_801A0394); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_801A0388[1] = (s32)item; - func_80024054(((u8 *)&D_80182AB4), D_801A03BC); - func_8001CE28(item, D_801A03BC); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_801A0388[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801A03D8, 0x84); - func_8001CE68(item, D_801A03D8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801A03D8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_801A0388[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_801A0388; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_801627E8); - - -extern void (*D_80182AD8[])(void); - -void func_80162834(void *a0) { - D_80182AD8[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80182AC8; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80182AC8, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019FBE8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019FBE8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019FBE8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019FBE8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80182AE0[])(void); - -void func_80163A58(void *a0) { - D_80182AE0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019FBF0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019FBF0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80182B34[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80182B34[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80182AFC; -extern s16 D_80182B30; -extern s16 D_80182B2E; -extern s16 D_80182B2C; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80182AFC; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80182B30 = 0x80; - D_80182B2E = 0x80; - D_80182B2C = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80182B30 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182B30` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80182B30 - 8; - D_80182B30 = nv; - D_80182B2E = nv; - D_80182B2C = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80182B40[])(void); - -void func_80164BA0(void *a0) { - D_80182B40[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801A03E8; -extern u8 D_801A03E9; -extern u8 D_801A03EA; -extern u8 D_801A03EB; -extern u8 D_801A03EC; -extern u8 D_801A03ED; -extern u8 D_801A03EE; -extern u8 D_801A03EF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801A03E8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801A03E9 = 0xf0; - *(u8 *)base = 0xf0; - D_801A03EA = 0xc0; - D_801A03EE = 0; - D_801A03ED = 0; - D_801A03EC = 0; - D_801A03EF = 0; - D_801A03EB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801A03E8; -extern u8 D_801A03E9; -extern u8 D_801A03EA; - -s32 func_80164E40(void) { - u8 *p = &D_801A03E8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801A03E9 != 0) { - D_801A03E9 -= 0x10; - } - if (D_801A03EA != 0) { - D_801A03EA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80182B50[])(void); - -void func_80164EA4(void *a0) { - D_80182B50[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_801A0434[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_801A0434[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_801A0428[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_801A0428[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_801A0428[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_801A0428; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_801A0428; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80182B64[]; - extern u32 D_80182B84, D_80182B88, D_80182B8C, D_80182B90; - extern u32 D_80182B84, D_80182B88, D_80182B8C, D_80182B90; - extern u32 D_80182B84, D_80182B88, D_80182B8C, D_80182B90; - extern u32 D_80182B84, D_80182B88, D_80182B8C, D_80182B90; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80182B64[0x00], p); - ApplyMatrixSV(mat, &D_80182B64[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80182B64[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80182B64[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80182B8C; - *(u32 *)(prim + 0x24) = D_80182B84; - *(u32 *)(prim + 0x28) = D_80182B90; - *(u32 *)(prim + 0x2c) = D_80182B88; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80182B94[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80182B94[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80182B94[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80182B94[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80182C10[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80182C10[a1 & 0x7F]; -} - - - -extern s32 D_80182C30[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80182C30[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80182CAC[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80182CAC[a1 & 0x7F]; -} - - - -extern u8 D_80182CCC[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80182CCC[a1 & 0x7F]; -} - - - -extern u8 D_80182CEC[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80182CEC[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80182D0C[])(void); - D_80182D0C[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80182D88[])(void); - -void func_80165AC8(void) { - D_80182D88[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80182E04[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80182E04[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019FBF8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019FBF8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80182E10[])(void); - -void func_80166018(void *a0) { - D_80182E10[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80182E18[])(void); - -void func_801663FC(void *a0) { - D_80182E18[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80182EE0[])(void); - -void func_80166618(void *a0) { - D_80182EE0[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80182EF0[])(void); - -void func_80166654(void *a0) { - D_80182EF0[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_801A04A8[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_801A04A8[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A04A8). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_801A04A8[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_801A04A8)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_801A04A8[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_801A04A8[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80182E34[]; - extern u8 D_80182E20[]; - extern u8 D_80182E48[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80182E34; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80182E20; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80182E48; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80167714); - - -extern void (*D_80182F00[])(void); - -void func_801678B4(void *a0) { - D_80182F00[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80182F0C[])(void); - -void func_80167A9C(void *a0) { - D_80182F0C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80183018; - extern u8 D_8018302C[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80183018); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018302C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80182E6C[]; -extern u8 D_80182E80[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80182E6C; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80182E80; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80182F24[])(void); - -void func_80168744(void *a0) { - D_80182F24[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80182F14 differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80182F14[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80182F14; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80182F2C[])(void); - -void func_801689D8(void *a0) { - D_80182F2C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80182F34[])(void); - -void func_80168AA8(void *a0) { - D_80182F34[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80182F3C[])(void); - -void func_80168D58(void *a0) { - D_80182F3C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80182F44[])(void); - -void func_8016901C(void *a0) { - D_80182F44[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015AE2C", func_80169228); - - -extern void (*D_80182F4C[])(void); - -void func_801693CC(void *a0) { - D_80182F4C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80182F54[])(void); - -void func_80169830(void *a0) { - D_80182F54[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80183008[])(void); - -void func_80169B80(void *a0) { - D_80183008[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80182F5C[]; - extern u8 D_80182FCC[]; - extern u8 D_80182FFC[]; - extern u8 D_801A14D8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80182FFC, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80182F5C[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A14D8; - RotMatrixYXZ(rot, D_801A14D8); - func_80048D9C(D_801A14D8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80182FCC); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80183010[])(void); - -void func_80169F00(void *a0) { - D_80183010[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80182FC0[]; -extern char D_80182F80[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80182FC0, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182F80); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80183048[])(void); - -void func_8016A020(void *a0) { - D_80183048[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80183018; - extern u8 D_8018302C[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80183018); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_8018302C; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80183054[])(void); - -void func_8016A700(void *a0) { - D_80183054[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_8018309C[])(void); - -void func_8016AB30(void *a0) { - D_8018309C[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c b/src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c new file mode 100644 index 000000000..41a04176f --- /dev/null +++ b/src/ov_SC06_014/ov_SC06_014_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80182468; +extern u8 D_801823D8; +extern u8 D_801823B4; +extern u8 D_80182390; +extern u8 D_80182444; +extern u8 D_80182420; +extern u8 D_801823FC; +extern u8 D_8018236C; +extern void func_80145934(void); +extern u8 D_801824F8; +extern u8 D_801824D4; +extern u8 D_801824B0; +extern u8 D_8018248C; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_801818F0[]; +extern unsigned char D_80181920[]; +extern unsigned char D_80181970[]; +extern unsigned char D_801819A0[]; +extern unsigned char D_801819D0[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80181A20[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80181AE8[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80181B70[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80181B78; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801A02D8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801A02DC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80181BA8; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80181C50[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80181C74[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80181C64; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80181C88[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80181C94[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80181CA4[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80181CBC[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80181CAC; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80181CD0[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80181CEC[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80181CDC; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80181D00[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80181D14[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80181D28; +extern void (*D_80181D50[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80181D30; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80181D9C[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80181DA0[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80182204[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80182214[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801A0310; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_8018223C[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_8018221C; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_8018222C; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_8018227C[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80182284[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80182250; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80182290[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80182260; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801A0318; +extern s32 D_801A0324; +extern s32 D_801A0328; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_801822CC[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_801822A0[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_801A0320; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_8018251C[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_8018233C[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_801825C0[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_80182714[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80182530; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_8018271C[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80182540; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_80182560; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_80182724[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_8018274C[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_801825CC[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_80182758[])(void); + +void func_8015C714(void *a0) { + D_80182758[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_801825CC[])(void*); + extern int D_80182570; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_801825CC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_801825CC)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182570); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_801825CC[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_801825CC[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_801825CC[])(void*); + extern int D_80182570; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_801825CC)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_80182570); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_801825CC)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_80182768[])(void); + D_80182768[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_801825CC[])(struct Ent_8015CD20 *); + extern u8 D_80182580; + extern u8 D_80182770; + extern u8 D_80182780; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_801825CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182580); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182770); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_80182780); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_801825CC[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801827A0[])(void); + D_801827A0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_80182790; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_80182790 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_801825CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_801827FC; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_801827FC, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_801818E0[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_801818E0; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_80182804[])(void); + D_80182804[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80182810[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80182810[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80182810[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80182810[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_801825CC[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80182810[]; + +void func_8015D738(void *arg0) { + + extern u8 D_80182590[]; + extern u8 D_801825A0[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80182590); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801825A0); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80182810[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80182810[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80182810[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_80182844[])(void); + D_80182844[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801825CC[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018284C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_80182864[])(void); + D_80182864[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_801825CC[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_8018284C[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_8018284C[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_80182884[])(void); + D_80182884[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_801825CC[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801825CC)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_80182894; +extern u16 D_80182896; +extern u16 D_80182898; +extern s32 D_8018289C; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_80182894 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_80182896 + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80182898 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_8018289C, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801828A4; + +void func_8015E588(void) { + func_8013C9C4(&D_801828A4); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_801825CC[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_801825CC)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_801828B8[])(void); + D_801828B8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_801825CC[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_801825CC[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_801828C0[])(void); + D_801828C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_801825B0; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_801825B0); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_801825CC[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_801828C8[])(void); + D_801828C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_801825CC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_801825CC[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_801828D0[])(void); + D_801828D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_801825CC[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_801828D8; + extern s32 D_801828E8; + extern s32 D_801828F8; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828D8); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828E8); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_801825CC[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_801828F8); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80182908[])(void); + D_80182908[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_801825CC[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_801825CC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_801825CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_801825CC[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_80182914[])(void); + D_80182914[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_801825CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_801825CC[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_801825CC[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801825CC[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80182928[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80182928[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_801825CC[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_801825CC)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_801825CC[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_801825CC[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801829A4[])(void); + D_801829A4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_801825CC[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_801825CC)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_801829B4[])(void); + D_801829B4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_801825CC[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_801825CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_801825CC[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_801825CC[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_801825CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_801825CC[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_801825CC[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_801829BC[])(void); + D_801829BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_801825CC[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_801825CC)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_801825CC[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_801825CC)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_801829C8[])(void); + D_801829C8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_801825CC + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_801825CC[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_801825CC[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_801825CC[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_801829D8[])(void); + +void func_80160EA4(void *a0) { + D_801829D8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_801825CC[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_801825CC[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80182A08[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80182A08[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_80182A6C; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_80182A6C); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_801A0330[]; + extern u8 D_80182A38[]; + extern u8 D_80182A58[]; + extern u8 D_801A033C[]; + extern u8 D_801A0364[]; + extern u8 D_801A037C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_801A0330[0] = p; + func_80024054(&D_80182A38, &D_801A033C); + func_8001CE28(p, &D_801A033C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_801A0330[1] = p; + func_80024054(&D_80182A58, &D_801A0364); + func_8001CE28(p, &D_801A0364); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_801A0330[2] = p; + func_800242D0((s16)func_801620C4(), &D_801A037C, 0x84); + func_8001CE68(p, &D_801A037C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_801A037C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A0330[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_801A0330; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_80182A6C; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_80182A6C; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_80182A6C; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_80182A6C; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_801A0330[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_801A0330; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_80182A90[])(void); + +void func_80162330(void *a0) { + D_80182A90[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_801A0388[i] via `extern int D_801A0388[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80182A9C[]; + extern s32 D_80182AB4; + extern u8 D_801A0394[]; + extern u8 D_801A03BC[]; + extern u8 D_801A03D8[]; + extern int D_801A0388[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_801A0388[0] = (s32)item; + func_80024054(D_80182A9C, D_801A0394); + func_8001CE28(item, D_801A0394); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_801A0388[1] = (s32)item; + func_80024054(((u8 *)&D_80182AB4), D_801A03BC); + func_8001CE28(item, D_801A03BC); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_801A0388[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801A03D8, 0x84); + func_8001CE68(item, D_801A03D8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801A03D8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_801A0388[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_801A0388; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_801627E8); + + +extern void (*D_80182AD8[])(void); + +void func_80162834(void *a0) { + D_80182AD8[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80182AC8; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80182AC8, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019FBE8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019FBE8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019FBE8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019FBE8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80182AE0[])(void); + +void func_80163A58(void *a0) { + D_80182AE0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019FBF0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019FBF0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80182B34[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80182B34[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80182AFC; +extern s16 D_80182B30; +extern s16 D_80182B2E; +extern s16 D_80182B2C; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80182AFC; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80182B30 = 0x80; + D_80182B2E = 0x80; + D_80182B2C = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80182B30 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80182B30` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80182B30 - 8; + D_80182B30 = nv; + D_80182B2E = nv; + D_80182B2C = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80182B40[])(void); + +void func_80164BA0(void *a0) { + D_80182B40[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801A03E8; +extern u8 D_801A03E9; +extern u8 D_801A03EA; +extern u8 D_801A03EB; +extern u8 D_801A03EC; +extern u8 D_801A03ED; +extern u8 D_801A03EE; +extern u8 D_801A03EF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801A03E8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801A03E9 = 0xf0; + *(u8 *)base = 0xf0; + D_801A03EA = 0xc0; + D_801A03EE = 0; + D_801A03ED = 0; + D_801A03EC = 0; + D_801A03EF = 0; + D_801A03EB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801A03E8; +extern u8 D_801A03E9; +extern u8 D_801A03EA; + +s32 func_80164E40(void) { + u8 *p = &D_801A03E8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801A03E9 != 0) { + D_801A03E9 -= 0x10; + } + if (D_801A03EA != 0) { + D_801A03EA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80182B50[])(void); + +void func_80164EA4(void *a0) { + D_80182B50[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_801A0434[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_801A0434[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_801A0428[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_801A0428[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_801A0428[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_801A0428; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_801A0428; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80182B64[]; + extern u32 D_80182B84, D_80182B88, D_80182B8C, D_80182B90; + extern u32 D_80182B84, D_80182B88, D_80182B8C, D_80182B90; + extern u32 D_80182B84, D_80182B88, D_80182B8C, D_80182B90; + extern u32 D_80182B84, D_80182B88, D_80182B8C, D_80182B90; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80182B64[0x00], p); + ApplyMatrixSV(mat, &D_80182B64[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80182B64[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80182B64[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80182B8C; + *(u32 *)(prim + 0x24) = D_80182B84; + *(u32 *)(prim + 0x28) = D_80182B90; + *(u32 *)(prim + 0x2c) = D_80182B88; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80182B94[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80182B94[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80182B94[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80182B94[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80182C10[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80182C10[a1 & 0x7F]; +} + + + +extern s32 D_80182C30[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80182C30[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80182CAC[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80182CAC[a1 & 0x7F]; +} + + + +extern u8 D_80182CCC[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80182CCC[a1 & 0x7F]; +} + + + +extern u8 D_80182CEC[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80182CEC[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80182D0C[])(void); + D_80182D0C[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80182D88[])(void); + +void func_80165AC8(void) { + D_80182D88[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80182E04[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80182E04[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019FBF8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019FBF8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80182E10[])(void); + +void func_80166018(void *a0) { + D_80182E10[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80182E18[])(void); + +void func_801663FC(void *a0) { + D_80182E18[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80182EE0[])(void); + +void func_80166618(void *a0) { + D_80182EE0[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80182EF0[])(void); + +void func_80166654(void *a0) { + D_80182EF0[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_801A04A8[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_801A04A8[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_801A04A8). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_801A04A8[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_801A04A8)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_801A04A8[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_801A04A8[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80182E34[]; + extern u8 D_80182E20[]; + extern u8 D_80182E48[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80182E34; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80182E20; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80182E48; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80167714); + + +extern void (*D_80182F00[])(void); + +void func_801678B4(void *a0) { + D_80182F00[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80182F0C[])(void); + +void func_80167A9C(void *a0) { + D_80182F0C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80183018; + extern u8 D_8018302C[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80183018); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018302C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80182E6C[]; +extern u8 D_80182E80[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80182E6C; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80182E80; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80182F24[])(void); + +void func_80168744(void *a0) { + D_80182F24[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80182F14 differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80182F14[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80182F14; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80182F2C[])(void); + +void func_801689D8(void *a0) { + D_80182F2C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80182F34[])(void); + +void func_80168AA8(void *a0) { + D_80182F34[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80182F3C[])(void); + +void func_80168D58(void *a0) { + D_80182F3C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80182F44[])(void); + +void func_8016901C(void *a0) { + D_80182F44[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_014/nonmatchings/ov_SC06_014_jr_8015C32C", func_80169228); + + +extern void (*D_80182F4C[])(void); + +void func_801693CC(void *a0) { + D_80182F4C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80182F54[])(void); + +void func_80169830(void *a0) { + D_80182F54[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80183008[])(void); + +void func_80169B80(void *a0) { + D_80183008[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80182F5C[]; + extern u8 D_80182FCC[]; + extern u8 D_80182FFC[]; + extern u8 D_801A14D8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80182FFC, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80182F5C[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A14D8; + RotMatrixYXZ(rot, D_801A14D8); + func_80048D9C(D_801A14D8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80182FCC); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80183010[])(void); + +void func_80169F00(void *a0) { + D_80183010[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80182FC0[]; +extern char D_80182F80[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80182FC0, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80182F80); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80183048[])(void); + +void func_8016A020(void *a0) { + D_80183048[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80183018; + extern u8 D_8018302C[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80183018); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_8018302C; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80183054[])(void); + +void func_8016A700(void *a0) { + D_80183054[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_8018309C[])(void); + +void func_8016AB30(void *a0) { + D_8018309C[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_015/ov_SC06_015_jr_8015AE2C.c b/src/ov_SC06_015/ov_SC06_015_jr_8015AE2C.c index 3dca7c990..f60e18d15 100644 --- a/src/ov_SC06_015/ov_SC06_015_jr_8015AE2C.c +++ b/src/ov_SC06_015/ov_SC06_015_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801812B0[])(void); - -void func_8015C714(void *a0) { - D_801812B0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80181124[])(void*); - extern int D_801810C8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80181124)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80181124)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801810C8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80181124[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80181124[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80181124[])(void*); - extern int D_801810C8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80181124)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801810C8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80181124)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801812C0[])(void); - D_801812C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80181124[])(struct Ent_8015CD20 *); - extern u8 D_801810D8; - extern u8 D_801812C8; - extern u8 D_801812D8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80181124[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801810D8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801812C8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801812D8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80181124[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_801812F8[])(void); - D_801812F8[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801812E8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801812E8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80181124[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80181354; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80181354, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80180438[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80180438; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018135C[])(void); - D_8018135C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80181368[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80181368[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80181368[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80181368[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80181124[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80181368[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801810E8[]; - extern u8 D_801810F8[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801810E8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801810F8); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80181368[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181368[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181368[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_8018139C[])(void); - D_8018139C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181124[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801813A4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801813BC[])(void); - D_801813BC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80181124[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801813A4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801813DC[])(void); - D_801813DC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80181124[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181124)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801813EC; -extern u16 D_801813EE; -extern u16 D_801813F0; -extern s32 D_801813F4; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801813EC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801813EE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_801813F0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801813F4, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_801813FC; - -void func_8015E588(void) { - func_8013C9C4(&D_801813FC); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80181124[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80181124)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80181410[])(void); - D_80181410[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80181124[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80181124[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80181418[])(void); - D_80181418[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80181108; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181108); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80181124[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80181420[])(void); - D_80181420[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80181124[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80181124[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80181428[])(void); - D_80181428[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80181124[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80181430; - extern s32 D_80181440; - extern s32 D_80181450; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80181124[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181430); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181440); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80181124[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181450); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80181460[])(void); - D_80181460[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80181124[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80181124[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80181124[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80181124[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018146C[])(void); - D_8018146C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80181124[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80181124[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80181124[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181124[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80181480[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80181480[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80181124[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80181124)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80181124[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80181124[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_801814FC[])(void); - D_801814FC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80181124[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80181124)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018150C[])(void); - D_8018150C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80181124[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80181124[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80181124[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80181124[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80181124[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80181124[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80181124[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80181514[])(void); - D_80181514[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80181124[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80181124)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80181124[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80181124)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80181520[])(void); - D_80181520[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181124 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80181124[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80181124[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80181124[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80181530[])(void); - -void func_80160EA4(void *a0) { - D_80181530[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80181124[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80181124[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80181560[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80181560[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801815C4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801815C4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_80193710[]; - extern u8 D_80181590[]; - extern u8 D_801815B0[]; - extern u8 D_8019371C[]; - extern u8 D_80193744[]; - extern u8 D_8019375C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_80193710[0] = p; - func_80024054(&D_80181590, &D_8019371C); - func_8001CE28(p, &D_8019371C); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_80193710[1] = p; - func_80024054(&D_801815B0, &D_80193744); - func_8001CE28(p, &D_80193744); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_80193710[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019375C, 0x84); - func_8001CE68(p, &D_8019375C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019375C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80193710[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_80193710; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801815C4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801815C4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801815C4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801815C4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_80193710[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_80193710; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801815E8[])(void); - -void func_80162330(void *a0) { - D_801815E8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_80193768[i] via `extern int D_80193768[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_801815F4[]; - extern s32 D_8018160C; - extern u8 D_80193774[]; - extern u8 D_8019379C[]; - extern u8 D_801937B8[]; - extern int D_80193768[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_80193768[0] = (s32)item; - func_80024054(D_801815F4, D_80193774); - func_8001CE28(item, D_80193774); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_80193768[1] = (s32)item; - func_80024054(((u8 *)&D_8018160C), D_8019379C); - func_8001CE28(item, D_8019379C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_80193768[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_801937B8, 0x84); - func_8001CE68(item, D_801937B8); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_801937B8, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_80193768[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_80193768; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_801627E8); - - -extern void (*D_80181630[])(void); - -void func_80162834(void *a0) { - D_80181630[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80181620; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80181620, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_80192FC8[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_80192FC8, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_80192FC8[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_80192FC8, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80181638[])(void); - -void func_80163A58(void *a0) { - D_80181638[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_80192FD0; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_80192FD0; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_8018168C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_8018168C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80181654; -extern s16 D_80181688; -extern s16 D_80181686; -extern s16 D_80181684; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80181654; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80181688 = 0x80; - D_80181686 = 0x80; - D_80181684 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80181688 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181688` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80181688 - 8; - D_80181688 = nv; - D_80181686 = nv; - D_80181684 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80181698[])(void); - -void func_80164BA0(void *a0) { - D_80181698[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_801937C8; -extern u8 D_801937C9; -extern u8 D_801937CA; -extern u8 D_801937CB; -extern u8 D_801937CC; -extern u8 D_801937CD; -extern u8 D_801937CE; -extern u8 D_801937CF; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_801937C8; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_801937C9 = 0xf0; - *(u8 *)base = 0xf0; - D_801937CA = 0xc0; - D_801937CE = 0; - D_801937CD = 0; - D_801937CC = 0; - D_801937CF = 0; - D_801937CB = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_801937C8; -extern u8 D_801937C9; -extern u8 D_801937CA; - -s32 func_80164E40(void) { - u8 *p = &D_801937C8; - if (*p != 0) { - *p -= 0x10; - } - if (D_801937C9 != 0) { - D_801937C9 -= 0x10; - } - if (D_801937CA != 0) { - D_801937CA -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_801816A8[])(void); - -void func_80164EA4(void *a0) { - D_801816A8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_80193814[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_80193814[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_80193808[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_80193808[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_80193808[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_80193808; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_80193808; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_801816BC[]; - extern u32 D_801816DC, D_801816E0, D_801816E4, D_801816E8; - extern u32 D_801816DC, D_801816E0, D_801816E4, D_801816E8; - extern u32 D_801816DC, D_801816E0, D_801816E4, D_801816E8; - extern u32 D_801816DC, D_801816E0, D_801816E4, D_801816E8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_801816BC[0x00], p); - ApplyMatrixSV(mat, &D_801816BC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_801816BC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_801816BC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_801816E4; - *(u32 *)(prim + 0x24) = D_801816DC; - *(u32 *)(prim + 0x28) = D_801816E8; - *(u32 *)(prim + 0x2c) = D_801816E0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_801816EC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_801816EC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_801816EC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_801816EC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80181768[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80181768[a1 & 0x7F]; -} - - - -extern s32 D_80181788[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80181788[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80181804[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80181804[a1 & 0x7F]; -} - - - -extern u8 D_80181824[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80181824[a1 & 0x7F]; -} - - - -extern u8 D_80181844[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80181844[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80181864[])(void); - D_80181864[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_801818E0[])(void); - -void func_80165AC8(void) { - D_801818E0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_8018195C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_8018195C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_80192FD8; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_80192FD8, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80181968[])(void); - -void func_80166018(void *a0) { - D_80181968[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80181970[])(void); - -void func_801663FC(void *a0) { - D_80181970[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80181A38[])(void); - -void func_80166618(void *a0) { - D_80181A38[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80181A48[])(void); - -void func_80166654(void *a0) { - D_80181A48[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_80193888[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_80193888[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80193888). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_80193888[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_80193888)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_80193888[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_80193888[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_8018198C[]; - extern u8 D_80181978[]; - extern u8 D_801819A0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_8018198C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80181978; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_801819A0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80167714); - - -extern void (*D_80181A58[])(void); - -void func_801678B4(void *a0) { - D_80181A58[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80181A64[])(void); - -void func_80167A9C(void *a0) { - D_80181A64[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80181B70; - extern u8 D_80181B84[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80181B70); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181B84; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_801819C4[]; -extern u8 D_801819D8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_801819C4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_801819D8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80181A7C[])(void); - -void func_80168744(void *a0) { - D_80181A7C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80181A6C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80181A6C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80181A6C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80181A84[])(void); - -void func_801689D8(void *a0) { - D_80181A84[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80181A8C[])(void); - -void func_80168AA8(void *a0) { - D_80181A8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80181A94[])(void); - -void func_80168D58(void *a0) { - D_80181A94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80181A9C[])(void); - -void func_8016901C(void *a0) { - D_80181A9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015AE2C", func_80169228); - - -extern void (*D_80181AA4[])(void); - -void func_801693CC(void *a0) { - D_80181AA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80181AAC[])(void); - -void func_80169830(void *a0) { - D_80181AAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80181B60[])(void); - -void func_80169B80(void *a0) { - D_80181B60[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80181AB4[]; - extern u8 D_80181B24[]; - extern u8 D_80181B54[]; - extern u8 D_801948B8[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80181B54, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80181AB4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801948B8; - RotMatrixYXZ(rot, D_801948B8); - func_80048D9C(D_801948B8, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80181B24); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80181B68[])(void); - -void func_80169F00(void *a0) { - D_80181B68[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80181B18[]; -extern char D_80181AD8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80181B18, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181AD8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80181BA0[])(void); - -void func_8016A020(void *a0) { - D_80181BA0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80181B70; - extern u8 D_80181B84[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80181B70); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80181B84; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80181BAC[])(void); - -void func_8016A700(void *a0) { - D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80181BF4[])(void); - -void func_8016AB30(void *a0) { - D_80181BF4[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c b/src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c new file mode 100644 index 000000000..1a8099b74 --- /dev/null +++ b/src/ov_SC06_015/ov_SC06_015_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_80180FC0; +extern u8 D_80180F30; +extern u8 D_80180F0C; +extern u8 D_80180EE8; +extern u8 D_80180F9C; +extern u8 D_80180F78; +extern u8 D_80180F54; +extern u8 D_80180EC4; +extern void func_80145934(void); +extern u8 D_80181050; +extern u8 D_8018102C; +extern u8 D_80181008; +extern u8 D_80180FE4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80180448[]; +extern unsigned char D_80180478[]; +extern unsigned char D_801804C8[]; +extern unsigned char D_801804F8[]; +extern unsigned char D_80180528[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80180578[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80180640[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_801806C8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_801806D0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_801936B8; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_801936BC; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80180700; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_801807A8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_801807CC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_801807BC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_801807E0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_801807EC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_801807FC[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80180814[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80180804; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80180828[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80180844[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80180834; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80180858[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_8018086C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80180880; +extern void (*D_801808A8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80180888; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_801808F4[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_801808F8[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_80180D5C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_80180D6C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_801936F0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_80180D94[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80180D74; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80180D84; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_80180DD4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_80180DDC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_80180DA8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_80180DE8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_80180DB8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_801936F8; +extern s32 D_80193704; +extern s32 D_80193708; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80180E24[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80180DF8[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_80193700; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80181074[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_80180E94[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80181118[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018126C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80181088; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80181274[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_80181098; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801810B8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018127C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801812A4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80181124[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80181124[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80181124[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80181124[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80181124[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80181124[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80181124[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80181124[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801812B0[])(void); + +void func_8015C714(void *a0) { + D_801812B0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80181124[])(void*); + extern int D_801810C8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80181124)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80181124)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801810C8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80181124[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80181124[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80181124[])(void*); + extern int D_801810C8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80181124)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801810C8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80181124)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801812C0[])(void); + D_801812C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80181124[])(struct Ent_8015CD20 *); + extern u8 D_801810D8; + extern u8 D_801812C8; + extern u8 D_801812D8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80181124[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801810D8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801812C8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801812D8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80181124[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_801812F8[])(void); + D_801812F8[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801812E8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801812E8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80181124[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80181354; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80181354, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80180438[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80180438; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018135C[])(void); + D_8018135C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80181368[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80181368[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80181368[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80181368[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80181124[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80181368[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801810E8[]; + extern u8 D_801810F8[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801810E8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801810F8); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80181368[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80181368[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80181368[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_8018139C[])(void); + D_8018139C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181124[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801813A4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801813BC[])(void); + D_801813BC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80181124[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801813A4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801813A4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801813DC[])(void); + D_801813DC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80181124[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181124)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801813EC; +extern u16 D_801813EE; +extern u16 D_801813F0; +extern s32 D_801813F4; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801813EC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801813EE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_801813F0 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_801813F4, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_801813FC; + +void func_8015E588(void) { + func_8013C9C4(&D_801813FC); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80181124[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80181124)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80181410[])(void); + D_80181410[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80181124[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80181124[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80181418[])(void); + D_80181418[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80181108; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80181108); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80181124[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80181420[])(void); + D_80181420[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80181124[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80181124[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80181428[])(void); + D_80181428[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80181124[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80181430; + extern s32 D_80181440; + extern s32 D_80181450; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80181124[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181430); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181440); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80181124[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80181450); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80181460[])(void); + D_80181460[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80181124[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80181124[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80181124[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80181124[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018146C[])(void); + D_8018146C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80181124[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80181124[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80181124[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181124[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80181480[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80181480[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80181124[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80181124)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80181124[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80181124[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_801814FC[])(void); + D_801814FC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80181124[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80181124)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018150C[])(void); + D_8018150C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80181124[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80181124[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80181124[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80181124[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80181124[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80181124[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80181124[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80181514[])(void); + D_80181514[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80181124[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80181124)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80181124[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80181124)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80181520[])(void); + D_80181520[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80181124 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80181124[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80181124[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80181124[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80181530[])(void); + +void func_80160EA4(void *a0) { + D_80181530[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80181124[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80181124[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80181560[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80181560[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801815C4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801815C4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_80193710[]; + extern u8 D_80181590[]; + extern u8 D_801815B0[]; + extern u8 D_8019371C[]; + extern u8 D_80193744[]; + extern u8 D_8019375C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_80193710[0] = p; + func_80024054(&D_80181590, &D_8019371C); + func_8001CE28(p, &D_8019371C); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_80193710[1] = p; + func_80024054(&D_801815B0, &D_80193744); + func_8001CE28(p, &D_80193744); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_80193710[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019375C, 0x84); + func_8001CE68(p, &D_8019375C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019375C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80193710[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_80193710; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801815C4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801815C4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801815C4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801815C4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_80193710[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_80193710; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801815E8[])(void); + +void func_80162330(void *a0) { + D_801815E8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_80193768[i] via `extern int D_80193768[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_801815F4[]; + extern s32 D_8018160C; + extern u8 D_80193774[]; + extern u8 D_8019379C[]; + extern u8 D_801937B8[]; + extern int D_80193768[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_80193768[0] = (s32)item; + func_80024054(D_801815F4, D_80193774); + func_8001CE28(item, D_80193774); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_80193768[1] = (s32)item; + func_80024054(((u8 *)&D_8018160C), D_8019379C); + func_8001CE28(item, D_8019379C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_80193768[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_801937B8, 0x84); + func_8001CE68(item, D_801937B8); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_801937B8, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_80193768[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_80193768; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_801627E8); + + +extern void (*D_80181630[])(void); + +void func_80162834(void *a0) { + D_80181630[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80181620; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80181620, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_80192FC8[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_80192FC8, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_80192FC8[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_80192FC8, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80181638[])(void); + +void func_80163A58(void *a0) { + D_80181638[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_80192FD0; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_80192FD0; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_8018168C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_8018168C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80181654; +extern s16 D_80181688; +extern s16 D_80181686; +extern s16 D_80181684; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80181654; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80181688 = 0x80; + D_80181686 = 0x80; + D_80181684 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80181688 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80181688` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80181688 - 8; + D_80181688 = nv; + D_80181686 = nv; + D_80181684 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80181698[])(void); + +void func_80164BA0(void *a0) { + D_80181698[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_801937C8; +extern u8 D_801937C9; +extern u8 D_801937CA; +extern u8 D_801937CB; +extern u8 D_801937CC; +extern u8 D_801937CD; +extern u8 D_801937CE; +extern u8 D_801937CF; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_801937C8; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_801937C9 = 0xf0; + *(u8 *)base = 0xf0; + D_801937CA = 0xc0; + D_801937CE = 0; + D_801937CD = 0; + D_801937CC = 0; + D_801937CF = 0; + D_801937CB = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_801937C8; +extern u8 D_801937C9; +extern u8 D_801937CA; + +s32 func_80164E40(void) { + u8 *p = &D_801937C8; + if (*p != 0) { + *p -= 0x10; + } + if (D_801937C9 != 0) { + D_801937C9 -= 0x10; + } + if (D_801937CA != 0) { + D_801937CA -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_801816A8[])(void); + +void func_80164EA4(void *a0) { + D_801816A8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_80193814[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_80193814[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_80193808[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_80193808[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_80193808[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_80193808; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_80193808; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_801816BC[]; + extern u32 D_801816DC, D_801816E0, D_801816E4, D_801816E8; + extern u32 D_801816DC, D_801816E0, D_801816E4, D_801816E8; + extern u32 D_801816DC, D_801816E0, D_801816E4, D_801816E8; + extern u32 D_801816DC, D_801816E0, D_801816E4, D_801816E8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_801816BC[0x00], p); + ApplyMatrixSV(mat, &D_801816BC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_801816BC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_801816BC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_801816E4; + *(u32 *)(prim + 0x24) = D_801816DC; + *(u32 *)(prim + 0x28) = D_801816E8; + *(u32 *)(prim + 0x2c) = D_801816E0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_801816EC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_801816EC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_801816EC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_801816EC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80181768[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80181768[a1 & 0x7F]; +} + + + +extern s32 D_80181788[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80181788[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80181804[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80181804[a1 & 0x7F]; +} + + + +extern u8 D_80181824[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80181824[a1 & 0x7F]; +} + + + +extern u8 D_80181844[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80181844[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80181864[])(void); + D_80181864[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_801818E0[])(void); + +void func_80165AC8(void) { + D_801818E0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_8018195C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_8018195C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_80192FD8; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_80192FD8, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80181968[])(void); + +void func_80166018(void *a0) { + D_80181968[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80181970[])(void); + +void func_801663FC(void *a0) { + D_80181970[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80181A38[])(void); + +void func_80166618(void *a0) { + D_80181A38[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80181A48[])(void); + +void func_80166654(void *a0) { + D_80181A48[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_80193888[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_80193888[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_80193888). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_80193888[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_80193888)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_80193888[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_80193888[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_8018198C[]; + extern u8 D_80181978[]; + extern u8 D_801819A0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_8018198C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80181978; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_801819A0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80167714); + + +extern void (*D_80181A58[])(void); + +void func_801678B4(void *a0) { + D_80181A58[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80181A64[])(void); + +void func_80167A9C(void *a0) { + D_80181A64[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80181B70; + extern u8 D_80181B84[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80181B70); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181B84; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_801819C4[]; +extern u8 D_801819D8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_801819C4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_801819D8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80181A7C[])(void); + +void func_80168744(void *a0) { + D_80181A7C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80181A6C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80181A6C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80181A6C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80181A84[])(void); + +void func_801689D8(void *a0) { + D_80181A84[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80181A8C[])(void); + +void func_80168AA8(void *a0) { + D_80181A8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80181A94[])(void); + +void func_80168D58(void *a0) { + D_80181A94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80181A9C[])(void); + +void func_8016901C(void *a0) { + D_80181A9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_015/nonmatchings/ov_SC06_015_jr_8015C32C", func_80169228); + + +extern void (*D_80181AA4[])(void); + +void func_801693CC(void *a0) { + D_80181AA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80181AAC[])(void); + +void func_80169830(void *a0) { + D_80181AAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80181B60[])(void); + +void func_80169B80(void *a0) { + D_80181B60[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80181AB4[]; + extern u8 D_80181B24[]; + extern u8 D_80181B54[]; + extern u8 D_801948B8[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80181B54, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80181AB4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801948B8; + RotMatrixYXZ(rot, D_801948B8); + func_80048D9C(D_801948B8, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80181B24); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80181B68[])(void); + +void func_80169F00(void *a0) { + D_80181B68[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80181B18[]; +extern char D_80181AD8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80181B18, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80181AD8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80181BA0[])(void); + +void func_8016A020(void *a0) { + D_80181BA0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80181B70; + extern u8 D_80181B84[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80181B70); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80181B84; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80181BAC[])(void); + +void func_8016A700(void *a0) { + D_80181BAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80181BF4[])(void); + +void func_8016AB30(void *a0) { + D_80181BF4[*(u16 *)((s32)a0 + 0x2)](); +} + diff --git a/src/ov_SC06_016/ov_SC06_016_jr_8015AE2C.c b/src/ov_SC06_016/ov_SC06_016_jr_8015AE2C.c index 1d5582566..6e8bd9a46 100644 --- a/src/ov_SC06_016/ov_SC06_016_jr_8015AE2C.c +++ b/src/ov_SC06_016/ov_SC06_016_jr_8015AE2C.c @@ -1621,4590 +1621,3 @@ s32 func_8015C128(s32 param_1) { ((void(*)(int))func_8015BE94)(((int)param_1)); } } - - - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_8015C32C); - -DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ - -DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ - -DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ - - -extern void (*D_801876C0[])(void); - -void func_8015C714(void *a0) { - D_801876C0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ - -DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80149704(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); -extern void func_8014C010(s32 a0, s32 a1); - - -void func_8015C7E4(u16 *param_1) -{ - - extern void (*D_80187534[])(void*); - extern int D_801874D8; - s32 iVar1; - u32 uVar2; - - iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); - if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { - iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); - if (iVar1 != 0) { - ((void (**)(u16*))D_80187534)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - } else { - uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); - if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { - ((void (**)(u16*))D_80187534)[*param_1](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - } else { - iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); - if (iVar1 == 0) { - iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); - if (iVar1 != 0) { - ((void (*)(u16 *))func_80148AAC)(param_1); - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801874D8); - ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *))func_80146CA0)(param_1); - } - if ((param_1[0x5c] & 0x2000) != 0) { - ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); - ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); - } - } - } - } - } - return; -} - - - - -// @class: struct -// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH - -extern s32 func_80149FB0(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161240(void *a0); -extern s32 func_80146E98(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80161C24(s32, s32); - - -void func_8015C944(int param_1) { - - extern void (*D_80187534[])(); - func_80149FB0(param_1); - func_80147AD4(param_1, 0, 0, 0); - ((void (*)(int))func_801473EC)(param_1); - ((void (*)(int))func_8014D738)(param_1); - if (*(int *)(param_1 + 0x170) == 0) { - (*D_80187534[*(unsigned short *)param_1])(param_1); - ((void (*)(int, int))func_80147078)(param_1, 0); - ((void (*)(int))func_80159B70)(param_1); - } else { - if (((int (*)(int))func_80161240)(param_1) == 0) { - if (func_80146E98(param_1) != 0) { - ((void (*)(int))func_80146CA0)(param_1); - } - if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { - func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); - } - } - } -} - - - -// @class: schedule -// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) - - -extern s32 func_80149FB0(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_801496D4(void *a0); -extern u16 func_801487F4(s32 *a0); -extern s32 func_801488A8(u8 *a0); -extern void func_80148AAC(u8 *a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_80146E90(s32 *a0, s32 a1); -extern void func_80146C98(s32 *a0, s16 a1); -extern void func_80161240(void *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80149704(void); - - -void func_8015CA28(u16 *param_1) { - - extern void (*D_80187534[])(void*); - extern int D_801874D8; - ((void (*)(void))func_80149FB0)(); - if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; - if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; - if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { - ((void (**)(u16*))D_80187534)[*param_1](param_1); - ((void (*)(u16 *))func_80149704)(param_1); - return; - } - if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { - if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { - ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); - ((void (*)(u16 *))func_801473EC)(param_1); - } - if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { - ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801874D8); - ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); - ((void (*)(u16 *, int))func_80146C98)(param_1, 2); - } - if (*(int *)(param_1 + 0xb8) != 0) - goto do161240; - } - ((void (**)(u16*))D_80187534)[*param_1](param_1); - ((void (*)(u16 *, int))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; -do161240: - ((void (*)(u16 *))func_80161240)(param_1); -} - - -DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ - -DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ - -DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ - -DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ - -DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ - -DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ - -DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ - -DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ - -DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ - -DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ - -DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ - - - -void func_8015CC74(s32 *a0) { - - extern void (*D_801876D0[])(void); - D_801876D0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ - -DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ - -#define NULL 0 - -struct Sub_8015CD20 { - u8 pad0[0x12]; - u16 unk12; /* +0x12 */ -}; - -struct Ent_8015CD20 { - u16 unk0; /* +0x00 */ - u8 pad2[0x1E]; - struct Sub_8015CD20 *unk20; /* +0x20 */ - u8 pad24[0x94]; - s16 unkB8; /* +0xB8 */ - u8 pad1BA[0x102]; - s8 unk1BC; /* +0x1BC */ - u8 pad1BD[0x77]; - s32 unk234; /* +0x234 */ -}; - - - -s32 func_8015CD20(s32 arg0) { - extern void (*D_80187534[])(struct Ent_8015CD20 *); - extern u8 D_801874E8; - extern u8 D_801876D8; - extern u8 D_801876E8; - - s32 temp_v0; - s32 var_v0; - struct Sub_8015CD20 *sp; - - ((void(*)())func_80149FB0)(); - if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { - D_80187534[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; - ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801874E8); - } else { - ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); - } - return; - } - temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; - if (temp_v0 == 0) { - if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801876D8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0xAA; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { - ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801876E8); - ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); - ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; - } - if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 + 0x71; - goto block_13; - } - if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { - sp = ((struct Ent_8015CD20 *)arg0)->unk20; - var_v0 = sp->unk12 - 0x71; -block_13: - sp->unk12 = var_v0 & 0xFFF; - } - } else { - ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; - } - ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); - if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { - D_80187534[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); - ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); - ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); - } else { - ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); - } -} - - - -DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ - -DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ - -DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ - - - -void func_8015CFC0(s32 *a0) { - - extern void (*D_80187708[])(void); - D_80187708[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) - - -void func_8015D01C(int param_1) { - extern s32 func_801725F4(u8 *a0); - extern int D_800D550C; - extern int D_801876F8; - - int iVar4; - register unsigned short uVar1 __asm__("$19"); - register unsigned short uVar5 __asm__("$17"); - short sVar2; - short sVar3; - - ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); - uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); - uVar5 = (uVar1 + 0x800) & 0xfff; - sVar2 = func_80012A60(iVar4, (short)uVar1); - sVar3 = func_80012A60(iVar4, uVar5); - if (sVar2 < sVar3) { - *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; - } else { - *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; - } - *(int *)(param_1 + 0x38) = (int)&D_801876F8 | 0x40000000; - ((void (*)(int))func_801725F4)(param_1); - ((void (*)(int))func_80146CA0)(param_1); -} - - - - - -// @class: struct -// @stuck: none — MATCH (pending gate) - -extern s32 func_80149FB0(s32 a0); -extern void func_8014FA04(s32 a0); -extern void func_8014E6A0(void); -extern void (*D_80187534[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_801725F4(u8 *a0); -extern void func_80146CA0(void *a0); - -void func_8015D104(void *arg0) { - ((void (*)(void))func_80149FB0)(); - ((void (*)(void *))func_8014FA04)(arg0); - if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - ((void (*)(void *))func_801725F4)(arg0); - *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; - *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); - func_80146CA0(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_8015D1B8); - - -// @class: regalloc-order -// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches -extern void func_80013F3C(s32 a0); -extern void func_80012558(s32 a0, s32 a1); -extern void func_800126C4(s32 a0, s32 a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern void *memcpy(void *dst, const void *src, u32 n); - -extern s32 D_80187764; - -void func_8015D380(s32 a0) { - s16 out[4]; - s32 buf[8]; - register s32 s1 __asm__("$17") = a0; - register s32 *s0 __asm__("$16") = buf; - ((void (*)(void *))func_80013F3C)((void *)s0); - ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); - ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); - ApplyMatrixSV((void *)s0, (void *)&D_80187764, (void *)out); - memcpy((void *)(s1 + 0x138), (void *)out, 8); -} - - - - -// @class: plumbing -// @stuck: none — MATCH - -extern unsigned char D_80186848[]; - -extern void func_801553C0(s32 a0); -extern void func_80154A74(s32 a0, s32 a1); - -void func_8015D414(int param_1) -{ - *(unsigned char *)(param_1 + 0x1bd) = 8; - *(unsigned char **)(param_1 + 0x38) = D_80186848; - *(short *)(param_1 + 0x138) = 0; - *(short *)(param_1 + 0x13a) = 0; - *(short *)(param_1 + 0x13c) = 0; - *(short *)(param_1 + 0x13e) = 0; - *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; - *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; - ((void (*)(void))func_801553C0)(); - func_80154A74(param_1, 0x11); -} - - -DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ - -DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ - - - -s32 func_8015D4E8(s16 *a0) { - - extern void (*D_8018776C[])(void); - D_8018776C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ - -DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ - -DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ - - -// @class: loose-typing -// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) - -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern void func_80154A74(int, int); -extern s32 func_80161208(); -extern void func_80154150(int, int); -extern void func_80146CA0(void *a0); -extern void func_80149374(int, int); - -extern unsigned char D_80187778[]; - -void func_8015D5E8(int param_1) -{ - int iVar1; - int iVar2; - - if (((int (*)(void))func_80161B18)() != 0) - return; - if (((int (*)(int))func_80161B84)(param_1) != 0) - return; - if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) - func_80154A74(param_1, 0x17); - if (((int (*)(int))func_80161208)(param_1) != 0) - return; - if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { - *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; - func_80154150(param_1, 0x1a); - ((void (*)(int))func_80146CA0)(param_1); - } else { - iVar1 = *(int *)(param_1 + 0x178); - if (iVar1 != 0) { - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 6) = - (short)((signed char)D_80187778[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 10) = - (short)((signed char)D_80187778[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); - iVar2 = *(int *)(param_1 + 0x234); - *(int *)(param_1 + 0x234) = iVar2 + 1; - *(short *)(iVar1 + 0xe) = - (short)((signed char)D_80187778[iVar2] + - *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); - func_80149374(param_1, iVar1 + 4); - } - } -} - - - -extern int func_80148AFC(void*); -extern s32 func_80161B18(void *); -extern s32 func_80161B84(void *); -extern u16 func_80148800(s32*); -extern u8 func_8014BEF8(void); -extern s32 func_80165624(s32); -extern s32 func_801488A8(u8*); -extern void func_8014D738(void); -extern s32 func_80161208(); -extern void func_80154A74(s32, s32); -extern void func_8015DAC4(s32*); -extern void func_8015DE24(s32*); -extern void func_8015DA5C(s32); -extern void func_8015F948(s32*); -extern void func_800CAF14(void *); -extern void func_80154150(s32, s32); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80149374(s32, s32); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *); -extern void func_8015C714(void *); -extern void func_801483E8(void); - -extern void (*D_80187534[])(void *); -extern u8 D_80078E78[]; -extern u8 D_80187778[]; - -void func_8015D738(void *arg0) { - - extern u8 D_801874F8[]; - extern u8 D_80187508[]; - u8 *p = D_80078E78; - s32 s1; - ((void (*)(void))func_80148AFC)(); - if (func_80161B18(arg0) != 0) return; - if (func_80161B84(arg0) != 0) return; - s1 = *(s32 *)((char *)arg0 + 0x178); - if (s1 != 0) { - if (*(u16 *)s1 == 0x360) goto block_808; - } - __asm__ __volatile__(""); - if (s1 != 0) { - if (*(u16 *)s1 != 0) goto block_7F4; - } - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -block_7F4: - if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { - block_808: - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DAC4)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - ((void (*)(void *))func_8015DE24)(arg0); - return; - } - if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { - if (((s32 (*)(void *))func_80165624)(arg0) != 0) { - ((void (*)(void *))func_8015DA5C)(arg0); - ((void (*)(void *))func_8015F948)(arg0); - return; - } - ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); - func_800CAF14(arg0); - return; - } - if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801874F8); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); - ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187508); - } - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - s1 = *(s32 *)((char *)arg0 + 0x178); - *(s16 *)(s1 + 6) = (s16)((s8)D_80187778[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); - *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187778[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); - *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187778[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); - ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); - *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (func_80161208(arg0) != 0) return; - ((void (*)(void *))func_801483E8)(arg0); -} - - -DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ - -DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ - -DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ - - - -void func_8015DAF8(s32 *a0) { - - extern void (*D_801877AC[])(void); - D_801877AC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ - -DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187534[])(void *); -extern int func_8015DD74(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015DCB8(s32 a0); - -void func_8015DBD4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015DD74)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015DCB8)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801877B4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015DCB8(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ - -DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ - -DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ - - - -void func_8015DE58(s32 *a0) { - - extern void (*D_801877CC[])(void); - D_801877CC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ - -DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) - -extern void (*D_80187534[])(void *); -extern int func_8015E0D4(int); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); -extern void func_8015E018(s32 a0); - -void func_8015DF34(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { - ((void (*)(void))func_8015E0D4)(); - } - if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { - ((void (*)(void *))func_8015E018)(arg0); - } - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (proxy gate) - -extern s8 D_801877B4[]; -extern void func_80149374(s32 a0, s32 a1); - -void func_8015E018(s32 param_1) { - s32 iVar1; - s32 iVar2; - - iVar2 = *(s32 *)(param_1 + 0x178); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 6) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 10) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); - - iVar1 = *(s32 *)(param_1 + 0x234); - *(s32 *)(param_1 + 0x234) = iVar1 + 1; - *(s16 *)(iVar2 + 0xe) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); - - func_80149374(param_1, iVar2 + 4); -} - - -DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ - -DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ - -DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ - - - -s32 func_8015E1B8(s32 a0) { - - extern void (*D_801877EC[])(void); - D_801877EC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ - -DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ - -DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store - - -extern void func_8015E40C(s32 a0); -extern s32 func_80161B18(void *a0); -extern s32 func_80161B84(void *a0); -extern s32 func_80161208(); -extern void func_8015E5B0(u8*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -extern void (*D_80187534[])(void*); - -void func_8015E344(u16 *param_1) -{ - ((s32 (*)(void))func_8015E40C)(); - if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && - ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *))func_8015E5B0)(param_1); - *(s32 *)((char *)param_1 + 0x234) = 1; - } - if ((param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187534)[param_1[0]](param_1); - ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); - ((s32 (*)(u16 *))func_80159BE4)(param_1); - } - } -} - - -DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check - - -extern u16 D_801877FC; -extern u16 D_801877FE; -extern u16 D_80187800; -extern s32 D_80187804; - -extern void func_80149350(s32 arg0); -extern void func_80013E94(void *a0, void *a1); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); - -void func_8015E4B0(s32 param_1) -{ - u16 *psVar1; - s16 v[3]; - s32 local_10; - - psVar1 = *(u16 **)(param_1 + 0x18c); - if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { - v[0] = D_801877FC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); - v[1] = D_801877FE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; - v[2] = D_80187800 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); - ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); - ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187804, &local_10); - ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); - } - return; -} - - - - -extern void func_8013C9C4(void *a0); -extern s32 D_8018780C; - -void func_8015E588(void) { - func_8013C9C4(&D_8018780C); -} - - -DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) - - -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159BE4(s32 arg0); - -/* function-pointer dispatch table */ -extern void (*D_80187534[])(void*); - -void func_8015E698(u16 *param_1) -{ - if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { - ((void (**)(u16*))D_80187534)[param_1[0]](param_1); - ((void (*)(u16 *, s32))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159BE4)(param_1); - } -} - - -DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ - -DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ - -DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ - -DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ - - - -void func_8015E8E8(s32 *a0) { - - extern void (*D_80187820[])(void); - D_80187820[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ - -DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ - -DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ - - -extern u16 func_801487F4(s32*); -extern void func_80147078(s32*, s16); -extern void func_80159B70(void *a0); -extern s32 func_80149D10(s32); -extern void func_80175150(void *a0); -extern void func_8016EE40(s32 a0, s32 a1); -extern s32 func_80149744(struct S_80149744*); -extern void func_80149788(void); -extern s32 func_80161B84(void *a0); -extern s32 func_8014A4B4(void *a0); -extern void func_8014A4FC(void); -extern s32 func_80149AA8(s32*); -extern void func_80149AD4(s32*); -extern s32 func_80149B54(s32*); -extern void func_80149BAC(s32*); -extern s32 func_800CF8B4(void); -extern s32 func_801491C4(s32); -extern s32 func_80148E54(void *a0); -extern void func_8001382C(s32 a0, void *a1, void *a2); -extern void func_80146DB8(s32*, s32*); -extern void func_80147A84(s32); -extern void func_801473EC(s32*); -extern void func_80154150(s32, s32); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ -extern void func_801483E8(void); - -extern void (*D_80187534[])(void *); - -void func_8015EA3C(void *arg0) { - - extern s16 D_801152A0; - s32 invec[4]; - s32 outbuf[4]; - s32 temp; - s32 r; - - if (!(((s32 (*)(void))func_801487F4)() & 8)) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; - } - r = ((s32 (*)(void *))func_80149D10)(arg0); - if (r == 1) goto Lcase1; - if (r < 2) goto Ldefault; - if (r == 2) goto Lcase2; - goto Ldefault; -Lcase1: - D_80187534[*(u16 *)arg0](arg0); - func_80175150(arg0); - return; -Lcase2: - func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); - return; -Ldefault: - if (((s32 (*)(void *))func_80149744)(arg0) != 0) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149788)(arg0); - return; - } - if (func_80161B84(arg0) != 0) { - return; - } - if (func_8014A4B4(arg0) != 0) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *))func_8014A4FC)(arg0); - return; - } - if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149AD4)(arg0); - return; - } - if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *))func_80149BAC)(arg0); - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; - } - temp = func_80148E54(arg0); - if ((s16)temp >= 0) { - s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); - invec[0] = 0; - invec[1] = 0; - invec[2] = 0xFFFC0000; - func_8001382C((s16)d, invec, outbuf); - ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); - ((void (*)(void *))func_80147A84)(arg0); - ((void (*)(void *))func_801473EC)(arg0); - ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); - } else { - ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); - } - if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 9); - func_8015C714(arg0); - return; - } - if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ - ((void (*)(void *))func_801483E8)(arg0); - } -} - - -DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ - -DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ - -DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ - - - -s32 func_8015EE08(s32 a0) { - - extern void (*D_80187828[])(void); - D_80187828[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ - - -// @class: plumbing -// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) - -extern void func_8014CBF8(void *a0); -extern void func_801474EC(s32 *a0); -extern void func_80154274(s32 *a0, s32 a1); -extern void func_80146DB8(s32 *a0, s32 *a1); -extern void func_801477E8(s32 *a0, s32 a1); -extern void func_80146CA0(void *a0); - -extern int D_800D4C48; -extern int D_80187518; - -void func_8015EE7C(s32 param_1) -{ - ((int (*)(void))func_8014CBF8)(); - ((int (*)(int))func_801474EC)(param_1); - ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); - ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187518); - ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); - ((int (*)(int))func_80146CA0)(param_1); -} - - - -extern void (*D_80187534[])(void *); - -extern void func_80148038(s32 a0, s32 a1); -extern void func_80147460(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80161418(void *a0); -extern s32 func_801725A4(u8 *a0); - -void func_8015EEE0(void *arg0) -{ - ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); - ((void (*)(void *))func_80147460)(arg0); - ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); - ((void (*)(void *))func_801473EC)(arg0); - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s32))func_80147078)(arg0, 0); - func_80159B70(arg0); - } else { - if (((s32 (*)(void *))func_80161418)(arg0) == 0) { - ((void (*)(void *))func_801725A4)(arg0); - } - } -} - - -DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ - -DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ - -DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ - - - -void func_8015F00C(s32 *a0) { - - extern void (*D_80187830[])(void); - D_80187830[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ - -DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ - -extern s32 D_80062BE8; -extern void (*D_80187534[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8014AB5C(void); -extern void func_80159B70(void *a0); -extern void func_80019064(void *a0); -extern void func_80147324(s32 a0); -extern s32 func_80161208(void); -extern int func_80155FF8(int arg, int a1); - -void func_8015F118(void *a0) { - u16 flag; - - *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; - flag = *(u16 *)((u8 *)a0 + 0xB8); - if (flag == 0x8000) { - (*D_80187534[*(u16 *)a0])(a0); - ((void (*)(void *, s32))func_80147078)(a0, 0); - func_80159B70(a0); - } else { - if (flag & 0x4000) { - ((void (*)(s32))func_8014AB5C)(0x19); - ((void (*)(s32))func_8014AB5C)(0x1D); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); - func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); - func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); - func_80019064(&D_80062BE8); - func_80147324(0x9DA); - } - if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { - func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); - } - } -} - - -DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ - -DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ - -DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ - - - -void func_8015F324(s32 *a0) { - - extern void (*D_80187838[])(void); - D_80187838[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ - -DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ - - -extern void (*D_80187534[])(void *); - -extern s32 func_80149884(void); -extern s32 func_801496D4(void*); -extern void func_80149724(void); -extern void func_801477E8(s32*, s32); -extern u16 func_80148800(s32*); -extern s32 func_80148980(u8*); -extern void func_8014F1F4(void); -extern void func_8014FCFC(void); -extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); -extern void func_80147A84(s32 a0); -extern void func_801473EC(s32*); -extern void func_80146DB8(s32*, s32*); -extern void func_80146E90(s32*, s32); -extern void func_8014ED28(s32 a0); -extern void func_8014FA04(s32 a0); -extern s32 func_801725B8(u8*); -extern void func_80147324(s32 a0); -extern void func_80019064(void*); -extern void func_801484B0(s32, s32); -extern void func_80148534(s32, s32); - -void func_8015F448(s32 arg0) { - - extern u8 D_80062BD0; - extern s32 D_80187840; - extern s32 D_80187850; - extern s32 D_80187860; - s32 sp20[2]; - s32 sp28[2]; - - if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || - (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { - D_80187534[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0); - return; - } - - if (*(u8 *)(arg0 + 0x245) == 0) { - if (*(u8 *)(arg0 + 0x244) == 0) { - if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { - *(u8 *)(arg0 + 0x244) = 1; - *(u8 *)(arg0 + 0x245) = 1; - } - } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { - *(u8 *)(arg0 + 0x244) = 0; - *(u8 *)(arg0 + 0x245) = 1; - } - } - - if (*(u16 *)(arg0 + 0xB8) & 0x3000) { - if (*(u16 *)(arg0 + 0xB8) & 0x2000) { - ((void (*)(void *, void *))func_801484B0)(sp20, sp28); - func_80147324(0x56D); - } else { - ((void (*)(void *, void *))func_80148534)(sp20, sp28); - func_80147324(0x56E); - } - ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 0, 0); - ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), - (s16)(*(u16 *)(arg0 + 0xA) - 0x14), - *(s16 *)(arg0 + 0xE), 1, 0); - } - - if (*(u16 *)(arg0 + 0xB8) & 0x8000) { - if (*(u8 *)(arg0 + 0x245) != 0) { - *(u8 *)(arg0 + 0x245) = 0; - *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); - if (((s32 (*)(s32))func_80148980)(arg0) != 0) { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187840); - } else { - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187850); - } - } - } else { - *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); - *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); - *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); - func_80147A84(arg0); - ((void (*)(s32))func_801473EC)(arg0); - if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); - } - } - - if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { - D_80187534[*(u16 *)arg0]((void *)arg0); - *(u8 *)(arg0 + 0x1BE) = 0xA; - ((void (*)(s32))func_80149724)(arg0); - ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); - ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187860); - ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); - return; - } - - func_8014ED28(arg0); - func_8014FA04(arg0); - ((void (*)(s32))func_801725B8)(arg0); -} - - -DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ - -DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ - -DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ - - - -s32 func_8015F7D4(s32 a0) { - - extern void (*D_80187870[])(void); - D_80187870[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ - -DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ - - -extern void (*D_80187534[])(void *); -extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); -extern void func_80147078(s32 *, s16); -extern void func_80159B70(void *); -extern s32 func_80161208(void); - -void func_8015F89C(void *arg0) { - u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); - if (!(flags & 0x4000)) { - if (flags & 0x8000) { - D_80187534[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - return; - } - } else { - func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); - } - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ - - -extern void (*D_80187534[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(void); - -void func_8015F9A4(void *arg0) { - if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { - D_80187534[*(u16 *)arg0](arg0); - func_80147078(arg0, 0); - func_80159B70(arg0); - } else { - ((s32 (*)(void *))func_80161208)(arg0); - } -} - - -DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ - -DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ - -DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ - - - -void func_8015FAAC(s32 *a0) { - - extern void (*D_8018787C[])(void); - D_8018787C[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern s32 func_801612B8(void *a0, s32 a1); -extern void func_8016007C(s32 a0); -extern void (*D_80187534[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern s32 func_8015BE94(); -extern void func_8015C0C4(s32 a0); -extern void func_8015FBE0(s32 *a0); - -void func_8015FAE8(void *arg0) { - s32 v; - - v = func_801612B8(arg0, 0); - if (v == 0 || v == 0x8000) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 3); - ((void (*)(void *))func_8015BE94)(arg0); - } else if ((v & 0x4000) != 0) { - ((void (*)(void *))func_8016007C)(arg0); - *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; - D_80187534[*(u16 *)arg0](arg0); - ((void (*)(void *, s16))func_80147078)(arg0, 4); - ((void (*)(void *))func_8015C0C4)(arg0); - } else { - ((void (*)(void *))func_8015FBE0)(arg0); - } -} - - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_8015FBE0); - -extern void func_801599A4(void *a0); - -// @class: struct -// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) - -extern s32 D_800AE6B0; -extern void (*D_80187534[])(void *); - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_8015FCC8(void *param_1) { - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187534[*(u16 *)param_1](param_1); - ((void (*)(void *, s32))func_80147078)(param_1, 0); - func_80159B70(param_1); - } else { - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); - ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); - func_80146CA0(param_1); - } -} - - - -// @class: plumbing -// @stuck: none — MATCH expected; simple 3-call sequence with global table index - -extern unsigned int D_80187890[]; - -extern void func_80147324(s32 arg0); -extern s32 func_8013767C(s32 a0); -extern void func_80146CA0(void *a0); - -void func_8015FD74(int param_1) -{ - ((int (*)(int))func_80147324)(0x18); - *(int *)(param_1 + 0x198) = func_8013767C(D_80187890[*(unsigned char *)(param_1 + 0x1a0)]); - ((int (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) - - -extern void (*D_80187534[])(void*); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern void func_80154A74(s32 a0, s32 a1); -extern s32 func_80161208(); - -void func_8015FE70(u16 *param_1) -{ - if ((param_1[0x5c] & 0x8000) != 0) { - if (param_1[0x5d] == 0) { - ((void (**)())D_80187534)[param_1[0]](); - ((void (*)(u16 *, s16))func_80147078)(param_1, 0); - ((void (*)(u16 *))func_80159B70)(param_1); - return; - } - param_1[0x5c] = param_1[0x5d]; - } - if ((param_1[0x5c] & 0x4000) != 0) { - ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); - } - ((void (*)(u16 *))func_80161208)(param_1); -} - - - -extern s32 D_800AE6B0; -extern void (*D_80187534[])(void *); -extern u8 D_80078EC1; -extern u8 D_80078EC2; -extern u16 D_801270C0; - -extern void func_8016007C(s32 a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern u8 func_801656E8(s32 a0, s32 a1); -extern void func_80150820(s32 a0, s32 a1); -extern void func_8014BFF4(s32 a0, s32 a1); -extern void func_80165670(s32 a0, s32 a1); -extern void func_80165840(void); -extern void func_801658DC(void); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_8016004C(s32 a0); - -void func_8015FF20(void *param_1) { - s32 v2; - u8 cur; - - if ((D_800AE6B0 & 0x80FFFFFF) != 0) { - ((void (*)(void))func_8016007C)(); - D_80187534[*(u16 *)param_1](param_1); - ((void (*)(void *, s16))func_80147078)(param_1, 0); - func_80159B70(param_1); - return; - } - - v2 = *(s32 *)((s32)param_1 + 0x184); - if (v2 < 0) { - func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); - } else { - if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { - *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; - *(u8 *)((s32)param_1 + 0x197) = 0; - *(u8 *)((s32)param_1 + 0xBE) = 0; - *(u8 *)((s32)param_1 + 0xBF) = 0; - func_8014BFF4((s32)param_1, 1); - } - - cur = *(u8 *)((s32)param_1 + 0x1A0); - D_80078EC1 = cur; - D_80078EC2 = cur; - func_80165670((s32)param_1, cur); - ((void (*)(void *))func_80165840)(param_1); - ((void (*)(void *))func_801658DC)(param_1); - func_80154A74((s32)param_1, 0x11); - D_801270C0 = 1; - } - - ((void (*)(void *))func_8016004C)(param_1); -} - - -DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ - -DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ - -DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ - -DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ - - - -void func_80160138(s32 *a0) { - - extern void (*D_8018790C[])(void); - D_8018790C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ - -DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ - -DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ - -DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ - - -extern void (*D_80187534[])(void*); -extern void func_80154A74(s32 a0, s32 a1); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_801602A4(s32 *a0) { - if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { - ((void (**)())D_80187534)[*(u16 *)a0](); - func_80154A74((s32)a0, 0x11); - ((void (*)(s32, s32))func_80147078)((s32)a0, 0); - func_80159B70(a0); - } else { - ((s32 (*)(s32 *))func_80161208)(a0); - } -} - - -DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ - -DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ - -DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ - - - -void func_8016039C(s32 *a0) { - - extern void (*D_8018791C[])(void); - D_8018791C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ - -DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ - - - - - - - -/* data */ -extern u8 D_80078EC0; -extern u8 D_80078EBF; -extern void (*D_80187534[])(void *); - -/* callees (engine_core.h canonical sigs) */ -extern void func_80149020(s32 *a0); -extern void func_80149034(s32 *a0); -extern u16 func_80148800(s32 *a0); -extern s32 func_80149B54(s32 *a0); -extern void func_80149BAC(s32 *a0); -extern s32 func_80149AA8(s32 *a0); -extern void func_80149AD4(s32 *a0); -extern s32 func_80146E98(s32 a0); -extern u16 func_801487F4(s32 *a0); -extern void func_8015E9B8(s32 *a0); -extern void func_80159B70(void *a0); -extern s32 func_800CF8B4(); -extern s32 func_801491C4(s32 a0); -extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); -extern void func_801473EC(s32 *a0); -extern void func_8014D738(void); -extern void func_8015C714(void *a0); -extern s32 func_80161208(); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_8015F00C(s32 *a0); - -void func_80160534(u8 *p) { - - extern s16 D_801152A0; - func_80149020((s32 *)p); - func_80149034((s32 *)p); - if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { - if (D_80078EBF == 0x80) { - D_80187534[*(u16 *)p](p); - func_80147078((s32 *)p, 0x13); - func_8015F00C((s32 *)p); - return; - } - if (func_80149B54((s32 *)p) != 0) { - D_80187534[*(u16 *)p](p); - func_80149BAC((s32 *)p); - return; - } - } - if (func_80149AA8((s32 *)p) != 0) { - D_80187534[*(u16 *)p](p); - func_80149AD4((s32 *)p); - return; - } - if (func_80146E98((s32)p) != 0) { - if ((func_801487F4((s32 *)p) & 8) != 0) { - D_80187534[*(u16 *)p](p); - func_80147078((s32 *)p, 0x11); - func_8015E9B8((s32 *)p); - } else { - D_80187534[*(u16 *)p](p); - func_80147078((s32 *)p, 0); - func_80159B70(p); - } - return; - } - if (func_800CF8B4() != 0) { - *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = - ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; - } - func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), - *(s32 *)(p + 0x23C)); - func_801473EC((s32 *)p); - if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { - D_80187534[*(u16 *)p](p); - func_80147078((s32 *)p, 9); - func_8015C714(p); - } else { - ((s32 (*)(void *))func_80161208)(p); - } -} - - -DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ - -DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ - -DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ - - - -void func_8016084C(s32 *a0) { - - extern void (*D_80187924[])(void); - D_80187924[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ - -DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) - -typedef void (*code)(unsigned short *); - -extern void (*D_80187534[])(void*); - -extern u16 func_801487F4(s32 *a0); -extern s32 func_80161208(); -extern void func_80160A74(s32 *a0); -extern void func_80154150(s32 a0, s32 a1); -extern void func_80146CA0(void *a0); - -void func_80160920(unsigned short *param_1) -{ - if ((((int (*)(void))func_801487F4)() & 8) == 0) { - ((code *)D_80187534)[*param_1](param_1); - ((void (*)(unsigned short *))func_80160A74)(param_1); - } else { - if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { - ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); - ((void (*)(unsigned short *))func_80146CA0)(param_1); - } - } - return; -} - - - - -// @class: struct -// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array - - -extern u16 func_801487F4(s32 *a0); -extern void func_80160A74(s32 *a0); -extern s32 func_80161208(); - -/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ -extern void (*D_80187534[])(void*); - -void func_801609B8(u16 *param_1) { - if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { - ((void (**)(u16*))D_80187534)[*param_1](param_1); - ((void (*)(u16 *))func_80160A74)(param_1); - } else { - ((void (*)(u16 *))func_80161208)(param_1); - } -} - - -DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ - -DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ - -DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ - -DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ - - - -s32 func_80160B34(s32 a0) { - - extern void (*D_80187930[])(void); - D_80187930[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ - -DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ - -DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ - -DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187534 + func_80147078/func_80159B70 tail, func_80161208 else) - -extern void (*D_80187534[])(void *); -extern u16 func_80148800(s32 *a0); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); -extern s32 func_80161208(); - -void func_80160D10(void *arg0) { - if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { - D_80187534[*(u16 *)arg0](arg0); - } else { - if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { - if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { - goto dd0; - } - } else { - s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; - *(s32 *)((u8 *)arg0 + 0x1AC) = t; - if (t >= 0) { - goto dd0; - } - } - D_80187534[*(u16 *)arg0](arg0); - } - ((void (*)(void *, s16))func_80147078)(arg0, 0); - func_80159B70(arg0); - return; -dd0: - ((s32 (*)(void *))func_80161208)(arg0); -} - - -DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ - -DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ - -DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ - - -extern void (*D_80187940[])(void); - -void func_80160EA4(void *a0) { - D_80187940[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ - -DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ - -DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ - -DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH - -extern void func_80149020(s32 *a0); -extern void (*D_80187534[])(void *); -extern void func_80147078(s32 *a0, s16 a1); -extern void func_80159B70(void *a0); - -void func_80161034(void *a0) -{ - func_80149020(a0); - D_80187534[*(u16 *)a0](a0); - func_80147078(a0, 0); - func_80159B70(a0); -} - - -DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ - -DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ - -DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ - -DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80161208); - -DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ - -DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ - -DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_8016130C); - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80161374); - -DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ - -DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ - -DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ - -DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ - -DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ - -DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ - -DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ - -DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_8016163C); - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80161774); - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80161888); - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_8016191C); - -DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ - -DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ - -DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ - -DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ - -DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ - -DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80161A90); - -DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ - -DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ - -DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80161C24); - - -// @class: struct -// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) - -extern u16 D_80187970[]; -extern void func_80147324(s32 arg0); - -void func_80161C98(int param_1, u32 param_2) -{ - if (param_2 < 8) { - func_80147324(D_80187970[param_2]); - } - return; -} - - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80161CD0); - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80161D20); - -DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ - - -// @class: other -// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) - -extern s32 D_800AE6B0; -extern s32 D_800AE6A8; -extern s32 func_80029178(s32 arg); -extern void func_80029124(s32, s32); -extern void func_800D1734(void *); -extern s32 D_801879D4; - -void func_80161D88(void) { - if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && - (func_80029178(0x141) & 0xFF) != 0) { - func_80029124(0x141, 0); - func_80029124(0x95, 1); - func_800D1734(&D_801879D4); - } -} - - -// @class: regalloc-order -// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 -// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); -// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: -// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the -// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into -// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces -// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs -// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). -#include "common.h" - - - - - - - -void func_80161E08(s32 param_1) { - extern void func_80024054(void *a0, void *a1); - extern void func_8001CE28(void *a0, void *a1); - extern void func_800242D0(s32 a0, void *a1, s32 a2); - extern void func_8001CE68(void *a0, void *a1); - extern int func_801620C4(void); - extern void func_801622C4(void); - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_80078EB0; - extern u16 D_800B5BD8; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern u16 D_800B5C10; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern u16 D_800B5C48; - extern s16 D_800B5C74; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern u8 * D_8019E4E0[]; - extern u8 D_801879A0[]; - extern u8 D_801879C0[]; - extern u8 D_8019E4EC[]; - extern u8 D_8019E514[]; - extern u8 D_8019E52C[]; - - u8 *base = &(*(u8 *)&D_800AF630); - u8 *p; - s32 a2; - - if (*((u16 *)param_1) != 0x1A && - currentLocationId != 0x3012 && - currentLocationId != 0x3054 && - currentLocationId != 0x3079 && - currentLocationId != 0x3096 && - ((a2 = func_800291DC(8)) & 0x8000) != 0) { - - if (D_800B5BD8 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); - D_8019E4E0[0] = p; - func_80024054(&D_801879A0, &D_8019E4EC); - func_8001CE28(p, &D_8019E4EC); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; - } - - if (D_800B5C10 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); - D_8019E4E0[1] = p; - func_80024054(&D_801879C0, &D_8019E514); - func_8001CE28(p, &D_8019E514); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; - } - - if (D_800B5C48 == 0) { - __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); - D_8019E4E0[2] = p; - func_800242D0((s16)func_801620C4(), &D_8019E52C, 0x84); - func_8001CE68(p, &D_8019E52C); - D_800B5C74 = 1; - D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; - } - - func_800242D0((s16)func_801620C4(), &D_8019E52C, 0x84); - if ((a2 & 0x7FFF) == (s32)D_80078EB0) { - func_801622C4(); - } - } -} - - - -DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ - -DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019E4E0[]; - -void func_8016216C(void) -{ - int *p; - int i; - - func_800291C8(8, 0); - i = 0; - p = D_8019E4E0; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern s32 func_800291DC(s32); -extern u8 D_80078E78[]; -extern u8 D_80078EB0; -extern u8 D_80078EB1; -extern s32 D_801879D4; - -s32 func_801621CC(s32 arg0) { - register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ - register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ - register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ - u32 a2; - s32 d; /* $a0: natural alloc; load via $v0 temp */ - s32 v, last, hi, lo; - char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ - - a2 = func_800291DC(8); - if ((a2 & 0x8000) == 0) { - return 0; - } - a2 &= 0x7FFF; - if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { - return (s32)&D_801879D4; - } - d = s1[0x39] - 1; - i = 0; - if (s0 <= 0) { - return 0; - } - hi = (a2 >> 8) & 0xFF; - last = s0 - 1; - lo = a2 & 0xFF; - do { - if ((s8)d < 0) { - d = 0x17; - } - v = (s8)d; - if (hi == v) { - if (i != last) { - return (s32)&D_801879D4; - } - i++; - if ((u32)s1[0x38] < (u32)lo) { - return (s32)&D_801879D4; - } - goto bot; - } - i++; - bot: - d--; - } while (i < s0); - return 0; -} - - - - -// @class: schedule -// @stuck: none — MATCH -extern void func_80029124(s32, s32); -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); -extern int D_8019E4E0[]; - -void func_801622C4(void) -{ - int *p; - int i; - - ((int (*)(int, int))func_80029124)(0x141, 1); - ((int (*)(int, int))func_800291C8)(8, 0); - i = 0; - p = &D_8019E4E0; - do { - ((int (*)(int, int))func_80016714)(*p, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - - -extern void (*D_801879F8[])(void); - -void func_80162330(void *a0) { - D_801879F8[*(u8 *)((s32)a0 + 0x15)](); -} - - -DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ - -DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ - -DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; -// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay -// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. -// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after -// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a -// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing -// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces -// into one `addiu $s1` — 3 ins short). (5) store D_8019E538[i] via `extern int D_8019E538[]` (folds -// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). - -#include "common.h" - - - - - - - - -s32 func_80162438(s32 _unused0) { - extern void func_80024054(void *, void *); - extern void func_8001CE28(void *, void *); - extern void func_8001CE68(void *, void *); - extern void func_800242D0(s32, void *, s32); - extern s32 func_801626B8(void); - extern void func_80162760(void); - extern u8 D_80187A04[]; - extern s32 D_80187A1C; - extern u8 D_8019E544[]; - extern u8 D_8019E56C[]; - extern u8 D_8019E588[]; - extern int D_8019E538[]; - extern u16 D_800B5BD8; - extern u16 D_800B5C10; - extern u16 D_800B5C48; - extern u16 D_800AF7BC; - extern u16 D_800AF7BE; - extern s16 D_800B5BE0; - extern s16 D_800B5BE2; - extern s16 D_800B5C04; - extern u8 D_800B5BFF; - extern s16 D_800B5C18; - extern s16 D_800B5C1A; - extern s16 D_800B5C3C; - extern u8 D_800B5C37; - extern s16 D_800B5C50; - extern s16 D_800B5C52; - extern s16 D_800B5C74; - - u32 uVar2; - register u8 *base __asm__("$18"); - register u8 *item __asm__("$17"); - - base = &(*(u8 *)&D_800AF630); - uVar2 = func_800291DC(0x12); - if ((uVar2 & 0x8000) != 0) { - if (D_800B5BD8 == 0) { - register u8 *t __asm__("$2") = base + 0x65A8; - item = t; - D_8019E538[0] = (s32)item; - func_80024054(D_80187A04, D_8019E544); - func_8001CE28(item, D_8019E544); - D_800B5C04 = 1; - D_800B5BFF = 1; - D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; - D_800B5BE2 = -D_800AF7BE / 2 + 0x28; - } - if (D_800B5C10 == 0) { - register u8 *t __asm__("$2") = base + 0x65E0; - item = t; - D_8019E538[1] = (s32)item; - func_80024054(((u8 *)&D_80187A1C), D_8019E56C); - func_8001CE28(item, D_8019E56C); - D_800B5C3C = 1; - D_800B5C37 = 1; - D_800B5C18 = -D_800AF7BC / 2 + 0xD0; - D_800B5C1A = -D_800AF7BE / 2 + 0x30; - } - if (D_800B5C48 == 0) { - register u8 *t __asm__("$2") = base + 0x6618; - item = t; - D_8019E538[2] = (s32)item; - func_800242D0((s16)func_801626B8(), D_8019E588, 0x84); - func_8001CE68(item, D_8019E588); - D_800B5C74 = 1; - D_800B5C50 = -D_800AF7BC / 2 + 0xD0; - D_800B5C52 = -D_800AF7BE / 2 + 0x10; - } - func_800242D0((s16)func_801626B8(), D_8019E588, 0x84); - if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { - func_80162760(); - } - } -} - - - -DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ - -DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ - - -// @class: schedule -// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. - -extern void func_800291C8(s32, s32); -extern void func_80016714(void *a0, s32 a1); - -extern int D_8019E538[]; - -void func_80162760(void) -{ - int *p; - int i; - - func_800291C8(0x12, 0); - i = 0; - p = D_8019E538; - do { - int v = *p; - ((void (*)(int, int))func_80016714)(v, 0x38); - p = p + 1; - i = i + 1; - } while (i < 3); -} - - -DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_801627E8); - - -extern void (*D_80187A40[])(void); - -void func_80162834(void *a0) { - D_80187A40[*(u8 *)((s32)a0 + 0x1)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) - -extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); -extern void func_80162968(s32 a0); -extern s32 func_80162ACC(u8 *a0); - -extern u8 D_800B5CB8; -extern s32 D_80187A30; -extern s32 D_800B5CBC; -extern u8 D_800B5CDF; -extern s32 D_800B5CEC; - -void func_80162870(s32 param_1) { - *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; - func_8001CB6C(&D_800B5CB8, (s32)&D_80187A30, 0x250, 0x1A0); - D_800B5CEC = param_1 + 0xC; - D_800B5CDF = 0x14; - D_800B5CBC |= 0x60000000; - func_80162968(param_1); - func_80162ACC((u8 *)param_1); -} - - -DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ - -DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ - -DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ - -DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ - -DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ - -DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ - -DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ - -DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80162CCC); - -DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ - -DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ - -DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ - -DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ - -DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ - -DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ - -DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ - -DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ - -DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ - -DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ - -DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ - -DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ - -DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ - -DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ - -DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ - -DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ - -DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ - -DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ - -DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (21 ins, relocation-masked) - - -s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { - extern int func_8016345C(int, unsigned short, int, unsigned short, void *); - extern unsigned char D_8019DC10[8]; - - unsigned char sp18[8]; - memcpy(sp18, D_8019DC10, 8); - return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); -} - - - -DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) - -extern char D_8019DC10[8]; - -extern void *memcpy(void *dst, const void *src, unsigned int n); -extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); - -void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) -{ - char buf[8]; - - memcpy(buf, D_8019DC10, 8); - ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); -} - - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80163534); - -DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ - -DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80163764); - -DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ - -DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ - -DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ - - -extern void (*D_80187A48[])(void); - -void func_80163A58(void *a0) { - D_80187A48[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ - -DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ - - -void func_80163EC8(s32 param_1) { - extern Blk8 D_8019DC18; - extern u16 D_800B99DA; - extern u8 func_801656D0(s32 a0, s32 a1); - extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); - extern void func_80015978(s32 a0, s32 *a1); - extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); - - Blk8 in; - u16 out[4]; - s16 buf[4]; - s32 psVar6; - s32 iVar8; - s32 iVar7; - register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ - u16 uVar4; - u8 uVar3; - - in = D_8019DC18; - psVar6 = *(s32 *)(param_1 + 0x4c); - iVar8 = *(s32 *)(param_1 + 0x20); - func_80162D88((s32 *)param_1); - - if (*(s32 *)(psVar6 + 0x184) == 0) { - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - } - if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { - goto LAB_matched; - } - *(s32 *)(psVar6 + 0x184) = 0; - uVar5 = *(s32 *)(psVar6 + 0x44); - *(s16 *)(psVar6 + 0x18a) = 0; - *(s16 *)(psVar6 + 0x188) = 0; - *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - return; - -LAB_matched: - *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; - if ((D_800B99DA & 3) == 0) { - if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { - *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); - } else { - *(s16 *)(psVar6 + 0x188) = 0; - } - if (*(s16 *)(psVar6 + 0x188) < 0) { - *(s16 *)(psVar6 + 0x188) = 0; - } - } - - *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; - uVar5 = func_80148800((s32 *)psVar6); - if ((uVar5 & 0x80) != 0) { - *(s16 *)(param_1 + 0x66) = 0; - uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); - *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; - *(s16 *)(iVar8 + 0x1a) = 0x4000; - *(s16 *)(iVar8 + 0x18) = 0x4000; - *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); - *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); - *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); - ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); - *(s16 *)(param_1 + 0x6) = out[0]; - *(s16 *)(param_1 + 0xa) = out[1]; - *(s16 *)(param_1 + 0xe) = out[2]; - } - - if (0x80 < *(s16 *)(psVar6 + 0x188)) { - *(s16 *)(psVar6 + 0x188) = 0x80; - } - if (*(s16 *)(psVar6 + 0x188) >= 0x80) { - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0xe); - func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - func_80146994(0x33, param_1, 0, iVar7); - } - } else { - if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { - goto LAB_end; - } - iVar7 = *(s32 *)(psVar6 + 0x184); - if (iVar7 != 0) { - func_80015978(iVar7 + 4, (s32 *)buf); - buf[3] = 0; - uVar4 = func_80156370(0x21); - func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); - if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { - func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); - } - } - } - - uVar5 = func_8014CA00(iVar7); - *(s32 *)(psVar6 + 0x184) = uVar5; - if (0x1e < (u32)uVar5) { - *(s32 *)(psVar6 + 0x184) = 0; - } - func_80146E90((s32 *)param_1, 0x20); - *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; - func_80147324(0x449); - func_80146CA0((void *)param_1); - func_80146CA0((void *)param_1); - -LAB_end: - uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); - *(s16 *)(iVar8 + 0x1a) = uVar4; - *(s16 *)(iVar8 + 0x18) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); - *(s16 *)(param_1 + 0x6) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); - *(s16 *)(param_1 + 0xa) = uVar4; - uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); - *(s16 *)(param_1 + 0xe) = uVar4; -} - - -DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ - -DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ - -DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ - -DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80164418); - -DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) - -extern void (*D_80187A9C[])(void); -extern void func_80162D28(s32 *a0); - -void func_80164744(s32 param_1) -{ - s32 iVar1; - - iVar1 = *(s32 *)(param_1 + 0x20); - D_80187A9C[*(u16 *)(param_1 + 2)](); - if (iVar1 != 0) { - ((void (*)(s32))func_80162D28)(param_1); - } -} - - - - -// @class: other -// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) - - -extern void func_8014659C(void); -extern void func_8001C810(s32 a0, s32 a1); -extern void func_80164A74(s32 *a0); -extern void func_80146CA0(void *a0); -extern void func_80164930(s32 a); - -extern u16 D_800DF2E0; -extern s32 D_80187A64; -extern s16 D_80187A98; -extern s16 D_80187A96; -extern s16 D_80187A94; - -void func_801647A4(int param_1) { - s32 iVar1; - - iVar1 = ((s32 (*)(void))func_8014659C)(); - *(s32 *)(param_1 + 0x20) = iVar1; - if (iVar1 != 0) { - ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); - *(s32 **)(iVar1 + 0x80) = &D_80187A64; - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; - D_80187A98 = 0x80; - D_80187A96 = 0x80; - D_80187A94 = 0x80; - *(u16 *)(iVar1 + 0x1a) = 0; - *(u16 *)(param_1 + 0x60) = 0; - *(u16 *)(param_1 + 0x62) = 0x200; - ((s32 (*)(s32))func_80164A74)(param_1); - ((void (*)(s32))func_80146CA0)(param_1); - } else { - func_80164930(param_1); - } -} - - -DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ - -// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. -// Fix: D_80187A98 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187A98` -// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types -// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — -// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. -typedef struct { - u16 f0; - u8 pad0[0x4e]; - int f50; - u8 pad1[0x14]; -} Ent_80164930_80164930; - - -void func_80164930(s32 param_1) { - int iVar3 = *(int *)(((int)param_1) + 0x20); - if (*(int *)(((int)param_1) + 0x50) == 0) { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; - short nv; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; - nv = D_80187A98 - 8; - D_80187A98 = nv; - D_80187A96 = nv; - D_80187A94 = nv; - if (nv < -0x80) { - int i, lim; - Ent_80164930_80164930 *p; - for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { - if (p->f0 == lim && p->f50 != 0) { - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); - } - p++; - } - ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); - } else { - ((void(*)(int))func_80164ACC)(((int)param_1)); - } - } else { - short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; - u16 uVar2; - *(short *)(iVar3 + 0x1c) = sVar1; - *(short *)(iVar3 + 0x18) = sVar1; - uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; - *(u16 *)(iVar3 + 0x1a) = uVar2; - if ((int)((unsigned)uVar2 << 0x10) < 0) { - *(short *)(iVar3 + 0x1a) = 0; - } - *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; - } -} - - - -DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ - -DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ - - -extern void (*D_80187AA8[])(void); - -void func_80164BA0(void *a0) { - D_80187AA8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void func_80146578(void); -extern void func_8001CD50(s32 a0, s32 a1); -extern void func_800233CC(void *, unsigned short); -extern void func_80164DD0(s32 a0); -extern void func_80146CA0(void *a0); -extern void func_80164DB0(void); - -extern u8 D_8019E598; -extern u8 D_8019E599; -extern u8 D_8019E59A; -extern u8 D_8019E59B; -extern u8 D_8019E59C; -extern u8 D_8019E59D; -extern u8 D_8019E59E; -extern u8 D_8019E59F; - -void func_80164BDC(s32 param_1) -{ - register s32 p1 __asm__("$17"); /* $s1 */ - register s32 iVar1 __asm__("$16"); /* $s0 */ - register s32 base __asm__("$18"); /* $s2 */ - - p1 = param_1; - iVar1 = ((s32 (*)(void))func_80146578)(); - base = (s32)&D_8019E598; - *(s32 *)(p1 + 0x20) = iVar1; - if (iVar1 != 0) { - func_8001CD50(iVar1, base); - ((void (*)(s32, s32))func_800233CC)(base, 0x60); - *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; - D_8019E599 = 0xf0; - *(u8 *)base = 0xf0; - D_8019E59A = 0xc0; - D_8019E59E = 0; - D_8019E59D = 0; - D_8019E59C = 0; - D_8019E59F = 0; - D_8019E59B = 0; - *(s16 *)(iVar1 + 0x1e) = 0xccc; - *(s16 *)(iVar1 + 0x10) = 0x400; - *(s16 *)(p1 + 0x60) = 0x700; - *(s16 *)(p1 + 0x62) = -0x60; - func_80164DD0(p1); - ((void (*)(s32))func_80146CA0)(p1); - } else { - ((void (*)(s32))func_80164DB0)(p1); - } -} - - -DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ - -DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ - -DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ - -DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ - - - - - -extern u8 D_8019E598; -extern u8 D_8019E599; -extern u8 D_8019E59A; - -s32 func_80164E40(void) { - u8 *p = &D_8019E598; - if (*p != 0) { - *p -= 0x10; - } - if (D_8019E599 != 0) { - D_8019E599 -= 0x10; - } - if (D_8019E59A != 0) { - D_8019E59A -= 0x10; - } - return *(s32 *)p == 0; -} - - - -extern void (*D_80187AB8[])(void); - -void func_80164EA4(void *a0) { - D_80187AB8[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: struct -// @stuck: none — MATCH - - /* stride 0x10 */ -extern DStruct D_8019E5E4[]; - -extern void func_80165124(void *a0); -extern void func_80146CA0(void *a0); - -void func_80164EE0(int param_1) -{ - int i; - - for (i = 7; i >= 0; i--) { - D_8019E5E4[i].f0 = 0; - } - *(short *)(param_1 + 0x2e) = 0x4000; - *(short *)(param_1 + 0x2c) = 0x4000; - *(short *)(param_1 + 0x60) = 0; - *(short *)(param_1 + 0x62) = 0; - ((void (*)(int))func_80165124)(param_1); - *(short *)(param_1 + 0x66) = 0; - ((void (*)(int))func_80146CA0)(param_1); -} - - -DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ - -DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ - -DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ - -DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ - -DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ - -// @class: struct -// @stuck: none — MATCH (30 ins) -// -// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, -// fill the first free one (field @0xC == 0). Two unaligned block copies from -// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute -// p = &D_8019E5D8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into -// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes -// combine_givs split the field offsets into a second pointer IV (+2 ins). - - -typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; -typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; -typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; - - -s32 func_80165140(s32 param_1) { - extern Slot_80165140 D_8019E5D8[8]; - - int i; - Slot_80165140 *p; - for (i = 0; i < 8; i++) { - p = &D_8019E5D8[i]; - if (p->used == 0) { - p->used = 8; - p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); - p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); - return; - } - } -} - - - - -// @class: schedule -// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) - -extern void func_80165240(void *param_1, void *param_2, void *param_3); -extern s32 D_8019E5D8; - -void func_801651B8(void * param_1) -{ - register s32 *puVar1 __asm__("$16"); /* $s0 */ - register s32 iVar2 __asm__("$17"); /* $s1 */ - register s32 p __asm__("$18"); /* $s2 */ - - p = param_1; - ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); - iVar2 = 0; - puVar1 = &D_8019E5D8; - do { - if (puVar1[3] != 0) { - s32 a0v = p; - __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); - ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); - puVar1[3] = puVar1[3] + -1; - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 4; - } while (iVar2 < 8); -} - - -struct W4 { u32 w; } __attribute__((packed, aligned(1))); -extern void func_80016ED4(void *a0); -extern s32 func_80017DC4(void *a0, void *a1); - -void func_80165240(void *param_1, void *param_2, void *param_3) -{ - - extern u8 D_80187ACC[]; - extern u32 D_80187AEC, D_80187AF0, D_80187AF4, D_80187AF8; - extern u32 D_80187AEC, D_80187AF0, D_80187AF4, D_80187AF8; - extern u32 D_80187AEC, D_80187AF0, D_80187AF4, D_80187AF8; - extern u32 D_80187AEC, D_80187AF0, D_80187AF4, D_80187AF8; - u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ - u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ - u8 *p = prim; - - func_80017DC4(param_2, mat); - ApplyMatrixSV(mat, &D_80187ACC[0x00], p); - ApplyMatrixSV(mat, &D_80187ACC[0x08], prim + 0x08); - ApplyMatrixSV(mat, &D_80187ACC[0x10], prim + 0x10); - ApplyMatrixSV(mat, &D_80187ACC[0x18], prim + 0x18); - - *(s16 *)(prim + 0x04) = 3; - prim[0x38] = 0x2c; - *(u32 *)(prim + 0x20) = D_80187AF4; - *(u32 *)(prim + 0x24) = D_80187AEC; - *(u32 *)(prim + 0x28) = D_80187AF8; - *(u32 *)(prim + 0x2c) = D_80187AF0; - *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; - *(u32 *)(prim + 0x34) = 0x50000000; - - func_80016ED4(p); -} - - -DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ - -DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ - -DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ - -DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ - - -// @class: struct -// @stuck: none — MATCH (54 ins) - -extern u8 D_80078E78[]; -extern u8 D_80078EC1; -extern void (*D_80187AFC[])(void); -extern u8 func_80165658(s32 a0, s32 a1); -extern void func_800CAE0C(s32 a0); - -void func_801654A8(s32 arg0) -{ - u8 *s1 = D_80078E78; - - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 != 0x1A) { - if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { - if (func_80165658(arg0, D_80078EC1) & 0x80) { - ((void (*)(s32))D_80187AFC[D_80078EC1 & 0x7F])(arg0); - } - } - } - if (*(u16 *)arg0 == 0x16) { - return; - } - if (*(u16 *)arg0 == 0x1A) { - return; - } - if (s1[0x49] == 0x19) { - func_800CAE0C(arg0); - } -} - - - -// @class: struct -// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) - -extern u8 D_80078EC5; -extern u8 D_80078EC1; -extern void (*D_80187AFC[])(void); -extern void func_80165B28(void *a0); - -void func_80165580(s32 _arg0) -{ - if (D_80078EC5 & 0x80) { - ((void (*)(void))func_80165B28)(); - } else { - D_80187AFC[D_80078EC1 & 0x7F](); - } -} - - -DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ - -DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ - - -extern u8 D_80187B78[]; - -u8 func_80165658(s32 a0, s32 a1) { - return D_80187B78[a1 & 0x7F]; -} - - - -extern s32 D_80187B98[]; -extern s32 D_80078EC8; - -void func_80165670(s32 a0, s32 a1) { - D_80078EC8 = D_80187B98[a1 & 0x7F]; -} - - -DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ - - -extern u8 D_80187C14[]; - -u8 func_801656D0(s32 a0, s32 a1) { - return D_80187C14[a1 & 0x7F]; -} - - - -extern u8 D_80187C34[]; - -u8 func_801656E8(s32 a0, s32 a1) { - return D_80187C34[a1 & 0x7F]; -} - - - -extern u8 D_80187C54[]; - -u8 func_80165700(s32 a0, s32 a1) { - return D_80187C54[a1 & 0x7F]; -} - - -DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ - -DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ - -DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ - -DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ - -DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ - -DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ - -DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ - -DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ - -DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ - -DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ - -DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ - -DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ - -DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ - -DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ - -DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ - -DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ - -DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ - - - -s32 func_801659DC(u8 *a0) { - - extern void (*D_80187C74[])(void); - D_80187C74[*(u8 *)((s32)a0 + 0x1A0)](); -} - - -DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ - -DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ - -DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ - -DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ - - -extern u8 D_80078EC1; -extern void (*D_80187CF0[])(void); - -void func_80165AC8(void) { - D_80187CF0[D_80078EC1 & 0x7F](); -} - - -DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ - -DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ - -DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ - -DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ - - -extern void (*D_80187D6C[])(void); - -void func_80165B28(void *a0) { - *(u32 *)((s32)a0 + 0x44) |= 8; - D_80187D6C[*(u8 *)((s32)a0 + 0x197)](); -} - - -DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ - -DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ - -DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ - -DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ - -DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80165CA0); - -extern M2C_UNK D_8019DC20; - -void func_80165E2C(u16 *arg0) { - func_8001534C(0, &D_8019DC20, 0x80, 0x80, 0, 0); - func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); -} - - -DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ - -DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ - - -extern void (*D_80187D78[])(void); - -void func_80166018(void *a0) { - D_80187D78[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ - -DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ - -DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ - -DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ - -DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ - -DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ - -DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ - - -extern void (*D_80187D80[])(void); - -void func_801663FC(void *a0) { - D_80187D80[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ - -DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ - - -extern void (*D_80187E48[])(void); - -void func_80166618(void *a0) { - D_80187E48[*(u16 *)((s32)a0 + 0x2)](); -} - - - -extern void (*D_80187E58[])(void); - -void func_80166654(void *a0) { - D_80187E58[*(u16 *)((s32)a0 + 0x2)](); -} - - -#include "common.h" - -typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ - -typedef struct { - short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ - short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ - u8 c00, c01, c02, pad23; /* 0x20 */ - u8 c10, c11, c12, pad27; /* 0x24 */ - u8 c20, c21, c22, pad2B; /* 0x28 */ - u8 c30, c31, c32, pad2F; /* 0x2C */ - int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ -} Frame_80166690_80166690; - - -s32 func_80166690(s32 param_1, s32 param_2) -{ - extern s32 func_80017758(void *a0, void *a1); - extern Blk20 D_800AE620; - extern u8 D_8019E658[]; - - Frame_80166690_80166690 c; - Blk20 blk; - Rec_80166690_80166690 *sub; - Rec_80166690_80166690 *pv; - u8 *rec; - int i6; - int lt2; - int p2; - unsigned int uVar7, uVar8, uVar9; - int iVar3; - unsigned int w9, w7, w, t, w3b; - int w3; - short sVar10; - register unsigned int zr __asm__("$0"); - - blk = D_800AE620; - i6 = (short)param_1; - c.tag = 0x50000000; - rec = &D_8019E658[i6 * 0xC4]; - sVar10 = 0; - if (rec[0] == 0) { - return 0; - } - sub = (Rec_80166690_80166690 *)(rec + 4); - uVar9 = rec[1]; - uVar8 = rec[3]; - uVar7 = uVar8 >> 1; - iVar3 = rec[2]; - w3 = iVar3 - 1; - iVar3 = w3 + zr; - if (w3 != -1) { - lt2 = i6 < 2; - p2 = (short)param_2; - do { - pv = &sub[(short)uVar9]; - c.v0 = pv->h[0]; - c.v1 = pv->h[1]; - c.v2 = pv->h[2]; - c.w0 = pv->h[3]; - c.w1 = pv->h[4]; - c.w2 = pv->h[5]; - sVar10 = sVar10 + 1; - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c12 = t; c.c02 = t; - t = uVar7 + zr; - } else { - w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); - uVar7 = w + zr; - c.c12 = w; c.c02 = w; - t = uVar8 + zr; - } - c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; - } else { - t = uVar8 + zr; - c.c10 = t; c.c00 = t; - t = uVar7 + zr; - c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; - } - - w9 = uVar9 - 1; - uVar9 = w9 + zr; - if ((int)(w9 << 16) < 0) { - uVar9 = 0xF; - } - pv = &sub[(short)uVar9]; - c.v3 = pv->h[0]; - c.v4 = pv->h[1]; - c.v5 = pv->h[2]; - c.w3 = pv->h[3]; - c.w4 = pv->h[4]; - uVar8 = uVar8 - 0x10; - w7 = uVar7 - 0x10; - uVar7 = w7 + zr; - c.w5 = pv->h[5]; - if ((int)(w7 << 16) < 0) { - uVar7 = 0; - } - - if (lt2) { - if (p2 == 0) { - t = uVar8 + zr; - c.c32 = t; c.c22 = t; - t = uVar7 + zr; - } else { - t = uVar7 + zr; - c.c32 = t; c.c22 = t; - t = uVar8 + zr; - } - c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; - } else { - t = uVar8 + zr; - c.c30 = t; c.c20 = t; - t = uVar7 + zr; - c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; - } - - __asm__ __volatile__("" :: "r"(iVar3)); - func_80017758(&c, &blk); - w3b = iVar3 - 1; - iVar3 = w3b + zr; - } while ((short)w3b != -1); - } - return (short)sVar10; -} - - - - -/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019E658). - * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). - * - * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos - * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while - * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. - * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's - * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, - * byte-neutral: every caller discards the result): - * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" - * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). - * - * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via - * family_remap with zero file-scope footprint. No register pins. - */ -s32 func_80166994(param_1, param_2, param_3, param_4) - s32 param_1; - s16 param_2; - s16 param_3; - s16 param_4; -{ - typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; - typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; - extern u8 D_8019E658[]; - extern void RotTransSV(void *a0, void *a1, void *a2); - extern s32 VectorNormalSS(void *a0, void *a1); - - Trail *p = &((Trail *)D_8019E658)[param_3]; - s32 uVar6 = *(s32 *)(param_1 + 0x34); - s16 v10[4]; - s16 v18[4]; - s16 v20[4]; - s16 v28[4]; - s16 out[4]; - s32 c; - - switch (param_2) { - case 0: - p->flag = 1; - p->count = 0; - p->idx = 0; - p->timer = 0xf4; - break; - case 1: - v20[0] = p->e[p->idx].f0; - v20[1] = p->e[p->idx].f1; - v20[2] = p->e[p->idx].f2; - v28[0] = p->e[p->idx].f3; - v28[1] = p->e[p->idx].f4; - v28[2] = p->e[p->idx].f5; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - break; - case 2: { - u8 bVar3 = p->timer - 0x10; - p->timer = bVar3; - if (bVar3 < 0x10) { - p->flag = 0; - return 1; - } - { - u8 bVar1 = p->count; - if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { - p->count = bVar1 - 1; - } - } - return 0; - } - } - - if (param_3 < 2) { - func_801484B0((s32)v10, (s32)v18); - } else { - func_80148534((s32)v10, (s32)v18); - } - func_80165FA4(uVar6, (s32)v10, (s32)v18); - ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); - RotTransSV(v18, v18, out); - - if (param_2 != 0) { - v20[0] = (v10[0] + v20[0]) >> 1; - v20[1] = (v10[1] + v20[1]) >> 1; - v20[2] = (v10[2] + v20[2]) >> 1; - v28[0] = (v18[0] + v28[0]) >> 1; - v28[1] = (v18[1] + v28[1]) >> 1; - v28[2] = (v18[2] + v28[2]) >> 1; - v20[0] = v20[0] - v28[0]; - v20[1] = v20[1] - v28[1]; - v20[2] = v20[2] - v28[2]; - VectorNormalSS(v20, v20); - v20[0] = v28[0] + v20[0] / param_4; - v20[1] = v28[1] + v20[1] / param_4; - v20[2] = v28[2] + v20[2] / param_4; - p->e[p->idx].f0 = v20[0]; - p->e[p->idx].f1 = v20[1]; - p->e[p->idx].f2 = v20[2]; - p->e[p->idx].f3 = v28[0]; - p->e[p->idx].f4 = v28[1]; - p->e[p->idx].f5 = v28[2]; - c = p->idx; - p->idx = c + 1; - if ((u8)(c + 1) > 0xf) { - p->idx = 0; - } - if (p->count < 0xf) { - p->count = p->count + 1; - } - } - - p->e[p->idx].f0 = v10[0]; - p->e[p->idx].f1 = v10[1]; - p->e[p->idx].f2 = v10[2]; - p->e[p->idx].f3 = v18[0]; - p->e[p->idx].f4 = v18[1]; - p->e[p->idx].f5 = v18[2]; - return 0; -} - - -// @class: regalloc-order -// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps -// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) -// gives the temp-form counter increment that fills the skip-branch delay slots; -// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before -// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). - - -#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) - -s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) -{ - extern unsigned char D_8019E658[]; - - register int p2 __asm__("$20"); /* $s4 */ - register int p3 __asm__("$17"); /* $s1 */ - register int t2 __asm__("$5"); /* a1 */ - register int t3 __asm__("$6"); /* a2 */ - unsigned short *puVar1; - short iVar2; - int eq; - - iVar2 = 0; - puVar1 = ((unsigned short *)&D_8011D030); - t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); - t3 = ((short)param_3); SHB(t3); p3 = t3; - eq = (p2 == p3); - do { - if ((puVar1 != ((unsigned short *)param_1)) && - ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && - (!eq || - *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { - ((void(*)(unsigned short *))func_80146C3C)(puVar1); - } - iVar2 = iVar2 + 1; - puVar1 = puVar1 + 0x2c; - } while (iVar2 < 0x1e); - ((void(*)(void *, int))func_80016714)(&D_8019E658[((short)param_4) * 0xc4], 0xc4); -} - - - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_8016706C); - - -// @class: schedule -// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. - - - - -extern void func_80149350(s32); -extern void func_800D20C0(void *a0, void *a1, s32 a2); -extern void func_80017E68(void *a0, void *a1); -extern void func_800D23D0(void *a0); -extern void RotMatrixYXZ(void *a0, void *a1); -extern s32 func_80017758(void *a0, void *a1); -extern s32 func_80017DC4(void *a0, void *a1); -extern void func_80048EAC(void *a0, void *a1); - - -s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - - extern u8 D_80187D9C[]; - extern u8 D_80187D88[]; - extern u8 D_80187DB0[]; - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80126CE0; - Fr_801670E4 f; - register u8 *p __asm__("$18"); /* $s2 */ - register s32 ent __asm__("$19"); /* $s3 */ - s16 i; - s32 d; - s32 node; - u16 c; - u8 cv; - u8 cv2; - register s32 gA __asm__("$2"); - register s32 cxv __asm__("$4"); - register s32 czv __asm__("$5"); - u8 *vc; - u8 *ap; - u8 *mp; - u8 *va; - u8 *vb; - - ent = arg0; - node = *(s32 *)(ent + 0x34); - f.v[1].z = 0; - f.v[1].y = 0; - f.v[1].x = 0; - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - f.col[1].b = 0x70; - cv = *(u8 *)(ent + 0x12); - f.cx = arg1; - __asm__ __volatile__(""); - va = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(va) : "0"(va)); - f.cy = arg2; - vb = va; - __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); - p = D_80187D9C; - i = 0; - f.col[0].b = 0; - f.col[0].g = 0; - f.col[0].r = 0; - f.col[2].b = 0; - f.col[2].g = 0; - f.col[2].r = 0; - f.col[3].b = 0; - f.col[3].g = 0; - f.col[3].r = 0; - f.code = 0x50000000; - f.cz = arg3; - f.col[1].r = cv; - f.col[1].g = cv; - ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); - - c = f.cx; - *(s16 *)(ent + 0x06) = c; - *(s32 *)(ent + 0x4C) = (s16)c; - c = f.cy; - *(s16 *)(ent + 0x0A) = c; - *(s32 *)(ent + 0x50) = (s16)c; - c = f.cz; - *(s16 *)(ent + 0x0E) = c; - *(s32 *)(ent + 0x54) = (s16)c; - func_800D20C0(&f.cx, f.a8, 7); - func_80017E68(&f.cx, f.m1); - func_800D23D0(f.a8); - RotMatrixYXZ(f.a8, f.m1); - - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 4); - - p = D_80187D88; - gA = 0xA0; - cxv = (s16)f.cx; - f.col[1].g = gA; - gA = D_801269A4; - czv = (s16)f.cz; - f.col[1].b = 0x10; - f.col[1].r = 0x10; - f.pos[0] = gA - cxv; - i = 0; - f.v[3].y = 0; - f.v[2].y = 0; - f.v[0].y = 0; - f.pos[1] = D_801269A8 - (s16)f.cy; - f.pos[2] = D_801269AC - czv; - - do { - f.v[0].x = (s8)*p++; - f.v[0].z = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].z = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].z = (s8)*p--; - func_80017758(f.v, (void *)(ent + 0x38)); - } while ((i = i + 1) < 4); - - if (*(s32 *)(ent + 0x30) > 0) { - vc = (u8 *)&f.cx; - __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); - mp = f.m1; - ap = mp; - __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); - p = D_80187DB0; - i = 0; - d = (s16)f.a8[0] >> 6; - f.cx += d; - f.cy += d; - f.cz += d; - func_80017E68(vc, ap); - f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; - func_80017DC4(&f.cx, f.m2); - func_80048EAC(f.m2, mp); - f.v[3].z = 0; - f.v[2].z = 0; - f.v[0].z = 0; - cv2 = *(u8 *)(ent + 0x12); - f.col[1].b = 0x20; - f.col[1].r = 0x20; - f.col[3].b = 0; - f.col[3].r = 0; - f.col[2].b = 0; - f.col[2].r = 0; - f.col[0].b = 0; - f.col[0].r = 0; - f.col[3].g = 0; - f.col[2].g = 0; - f.col[0].g = 0; - f.col[1].g = cv2 + 0x60; - do { - f.v[0].x = (s8)*p++; - f.v[0].y = (s8)*p++; - f.v[2].x = (s8)*p++; - f.v[2].y = (s8)*p++; - f.v[3].x = (s8)*p++; - f.v[3].y = (s8)*p--; - func_80017758(f.v, f.m1); - } while ((i = i + 1) < 8); - } -} - - - -typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ - -struct Src_80167540 { - u8 pad0[0x34]; - Mat_80167540 mat; /* 0x34 */ -}; - -struct Sub2_80167540 { - u8 pad0[0x44]; - s32 unk44; /* 0x44 */ -}; - -struct Node_80167540 { - /* 0x0 */ u16 unk0; - u8 pad2[0x4]; - /* 0x6 */ s16 unk6; - u8 pad8[0x2]; - /* 0xA */ s16 unkA; - u8 padC[0x2]; - /* 0xE */ s16 unkE; - u8 pad10[0x10]; - /* 0x20 */ struct Src_80167540 *unk20; - u8 pad24[0x28]; - /* 0x4C */ struct Sub2_80167540 *unk4C; -}; - -struct Entity_80167540 { - /* 0x0 */ s16 unk0; - /* 0x2 */ u16 unk2; - u8 pad4[0xC]; - /* 0x10 */ s16 unk10; - /* 0x12 */ s16 unk12; - u8 pad14[0x8]; - /* 0x1C */ s32 unk1C; - u8 pad20[0x10]; - /* 0x30 */ s32 unk30; - /* 0x34 */ struct Node_80167540 *unk34; - /* 0x38 */ Mat_80167540 mat; -}; - - -s32 func_80167540(s32 arg0) { - - struct Node_80167540 *node; - struct Entity_80167540 *ent; - s32 v; - - node = ((struct Entity_80167540 *)arg0)->unk34; - if (node->unk0 == 1) { - if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { - if (((struct Entity_80167540 *)arg0)->unk1C > 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); - v = -0x30; - goto shared; - } - } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { - ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); - v = 0x30; -shared: - ((struct Entity_80167540 *)arg0)->unk1C = v; - } - ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); - ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; - ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); - ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); - if (ent != 0) { - ent->mat = node->unk20->mat; - } - if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { - ((struct Entity_80167540 *)arg0)->unk30 = 0x600; - ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); - } - } else { - ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); - } -} - - - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80167714); - - -extern void (*D_80187E68[])(void); - -void func_801678B4(void *a0) { - D_80187E68[*(u16 *)((s32)a0 + 0x2)](); -} - - - -DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ - - - -extern void (*D_80187E74[])(void); - -void func_80167A9C(void *a0) { - D_80187E74[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; - -struct Fr_80167AE0 { - u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ - SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ - u32 code; /* 0x50 -> sp+0x60 */ -}; - -s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { - extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); - extern s32 func_80017758(void *a0, void *a1); - extern u8 D_80187F80; - extern u8 D_80187F94[]; - - struct Fr_80167AE0 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - - func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = 0xa0; - } else if (flags & 2) { - fr.col[1].r = 0xc0; - } else { - fr.col[1].r = 0x80; - } - - p = ((u8 *)&D_80187F80); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 2; - fr.col[1].g = fr.col[1].r >> 2; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187F94; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.matrix); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.matrix); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -// @class: schedule -// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. - -extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); -extern u16 D_800B99DA; -extern u8 D_80187DD4[]; -extern u8 D_80187DE8[]; - -s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { - u8 buf[0x54]; - u8 *p; - s16 i; - - func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); - - *(s16 *)(buf + 0x3C) = 0; - *(s16 *)(buf + 0x34) = 0; - *(s16 *)(buf + 0x24) = 0; - *(s16 *)(buf + 0x2C) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - if (D_800B99DA & 1) { - buf[0x46] = 0x58; - } else { - buf[0x46] = 0x48; - } - buf[0x45] = buf[0x46] >> 2; - buf[0x44] = buf[0x45]; - if (((u8 (*)(s32))func_80029178)(0x81) != 0) { - buf[0x45] = buf[0x45] << 2; - buf[0x46] = buf[0x46] >> 1; - } - - p = D_80187DD4; - buf[0x42] = 0; - buf[0x41] = 0; - buf[0x40] = 0; - buf[0x4A] = 0; - buf[0x49] = 0; - buf[0x48] = 0; - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = 0; - *(s32 *)(buf + 0x50) = 0x50000000; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x22) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x32) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3A) = (s8)*p--; - func_80017758(buf + 0x20, buf); - } - - p = D_80187DE8; - *(s16 *)(buf + 0x2C) = -0x12; - *(s16 *)(buf + 0x3A) = 0; - *(s16 *)(buf + 0x32) = 0; - *(s16 *)(buf + 0x22) = 0; - *(s16 *)(buf + 0x2A) = 0; - *(s16 *)(buf + 0x28) = 0; - buf[0x46] = buf[0x46] << 1; - buf[0x44] = buf[0x45] = buf[0x45] << 1; - - for (i = 0; i < 4; i++) { - *(s16 *)(buf + 0x20) = (s8)*p++; - *(s16 *)(buf + 0x24) = (s8)*p++; - *(s16 *)(buf + 0x30) = (s8)*p++; - *(s16 *)(buf + 0x34) = (s8)*p++; - *(s16 *)(buf + 0x38) = (s8)*p++; - *(s16 *)(buf + 0x3C) = (s8)*p--; - if (i == 2) { - buf[0x4E] = buf[0x46]; - buf[0x4D] = buf[0x44]; - buf[0x4C] = buf[0x4D]; - } else if (i == 3) { - buf[0x4E] = 0; - buf[0x4D] = 0; - buf[0x4C] = buf[0x4D]; - buf[0x42] = buf[0x46]; - buf[0x41] = buf[0x44]; - buf[0x40] = buf[0x44]; - } - func_80017758(buf + 0x20, buf); - } -} - - -DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_801681FC); - -DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ - -DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ - -DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80168430); - -DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ - -DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ - -DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ - -DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ - -DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ - - -extern void (*D_80187E8C[])(void); - -void func_80168744(void *a0) { - D_80187E8C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ - -DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ - -// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match -// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): -// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands -// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` -// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives -// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via -// register s32 a0v __asm__("$4"); s32 param_1 = a0v; -// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) -// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` -// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the -// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd -// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was -// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds -// to a $v0 immediate). 134-overlay family exemplar: only D_80187E7C differs -> banks x134. -#include "common.h" - -typedef struct { - u16 f00, f02, f04, f06; - s16 f08; - u16 f0a, f0c, f0e, f10, f12, f14, f16; - u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; - u32 f24; -} Thing_80168828_80168828; - - -void func_80168828() -{ - extern s32 func_80017DC4(void *a0, void *a1); - extern void func_80049CAC(s32 a0, s32 a1); - extern void func_800173BC(void *a0, void *a1); - extern u16 D_80187E7C[]; - - - register s32 a0v __asm__("$4"); - s32 param_1 = a0v; - Thing_80168828_80168828 thing; - s16 matA[16]; - s16 matB[16]; - s16 svec[4]; - u16 *p; - short i; - register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ - - c40 = 0x40; - thing.f04 = 2; - thing.f0c = 0x24; - thing.f14 = 0x28; - thing.f08 = -3; - thing.f10 = 3; - thing.f02 = 0; - thing.f00 = 0; - thing.f12 = 0; - thing.f0a = 0; - thing.f18 = c40; - thing.f19 = c40; - thing.f22 = c40; - thing.f1e = c40; - thing.f1a = 0x10; - thing.f20 = 0xff; - thing.f1c = 0xff; - thing.f21 = 0xc0; - thing.f1d = 0xc0; - thing.f24 = 0x50000000; - - svec[0] = *(u16 *)(param_1 + 6); - svec[1] = *(u16 *)(param_1 + 0xA); - svec[2] = *(u16 *)(param_1 + 0xE); - func_80017E68(svec, matA); - - svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; - ((void (*)(void *, void *))func_80017DC4)(svec, matA); - - svec[0] = *(u16 *)(param_1 + 0x12); - svec[1] = *(u16 *)(param_1 + 0x16); - svec[2] = *(u16 *)(param_1 + 0x1A); - RotMatrixYXZ(svec, matB); - - func_80048EAC(matA, matB); - - svec[1] = 0; - p = D_80187E7C; - for (i = 0; i < 4; i++) { - svec[0] = *p++; - svec[2] = *p++; - ((void (*)(void *, void *))func_80049CAC)(svec, matA); - func_80048EAC(matB, matA); - func_800173BC(&thing, matA); - } -} - - - - -extern void (*D_80187E94[])(void); - -void func_801689D8(void *a0) { - D_80187E94[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ - -DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ - - -extern void (*D_80187E9C[])(void); - -void func_80168AA8(void *a0) { - D_80187E9C[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80168B70); - -DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ - - -extern void (*D_80187EA4[])(void); - -void func_80168D58(void *a0) { - D_80187EA4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ - -DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ - -DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ - - -extern void (*D_80187EAC[])(void); - -void func_8016901C(void *a0) { - D_80187EAC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ - -DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ - -INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015AE2C", func_80169228); - - -extern void (*D_80187EB4[])(void); - -void func_801693CC(void *a0) { - D_80187EB4[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ - -DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ - -DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ - -DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ - - -extern void (*D_80187EBC[])(void); - -void func_80169830(void *a0) { - D_80187EBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ - -DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ - -DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ - - -extern void (*D_80187F70[])(void); - -void func_80169B80(void *a0) { - D_80187F70[*(u16 *)((s32)a0 + 0x2)](); -} - - - - -extern void func_800D2318(void); -extern void RotMatrixYXZ(void *a0, void *a1); -extern void ApplyMatrixSV(void *a0, void *a1, void *a2); -extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); -extern s32 func_800D222C(void *a0, void *a1, s32 a2); -extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); -extern s32 ratan2(s32 a0, s32 a1); -extern void func_80048D9C(void *a0, void *a1); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -void func_80169BBC(s32 arg0) { - - extern s32 D_801269A4; - extern s32 D_801269A8; - extern s32 D_801269AC; - extern u16 D_80187EC4[]; - extern u8 D_80187F34[]; - extern u8 D_80187F64[]; - extern u8 D_801A0128[]; - u16 rot[4]; - s16 vec[4]; - s32 pos[4]; - s16 mtx[16]; - s32 p1; - s32 s2; - - func_800D2318(); - rot[0] = *(u16 *)(arg0 + 0x12); - rot[1] = *(u16 *)(arg0 + 0x16); - rot[2] = 0; - RotMatrixYXZ(rot, mtx); - vec[0] = 0; - vec[1] = -2; - vec[2] = -0x14; - ApplyMatrixSV(mtx, vec, vec); - *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; - *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; - *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; - p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - if (p1 != 0) { - *(u16 *)(p1 + 0x12) = rot[0]; - *(u16 *)(p1 + 0x16) = rot[1]; - *(u16 *)(p1 + 0x1A) = rot[2]; - } - func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), - *(s16 *)(arg0 + 0xE), 0, 0); - s2 = func_800D222C((void *)arg0, D_80187F64, 0x17); - if (s2 != 0) { - *(s32 *)(arg0 + 0x20) = s2; - rot[0] = rot[0] + D_80187EC4[*(s32 *)(arg0 + 0x30)]; - rot[1] = rot[1] - 0x400; - RotMatrixYXZ(rot, mtx); - pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); - pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); - pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); - ApplyTransposeMatrixLV(mtx, pos, pos); - rot[2] = -ratan2(pos[0], pos[1]); - vec[0] = 0x400; - vec[1] = -0x400; - vec[2] = 0; - RotMatrixYXZ(vec, mtx); - *(s32 *)(s2 + 0x34) = (s32)D_801A0128; - RotMatrixYXZ(rot, D_801A0128); - func_80048D9C(D_801A0128, mtx); - *(u16 *)(s2 + 0x18) = 0x5000; - *(u16 *)(s2 + 0x1A) = 0x2000; - *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; - func_80128EA8(s2, arg0 + 0x24, (s32)D_80187F34); - *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; - } else { - ((void (*)(s32))func_80146C3C)(arg0); - } -} - - -DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ - - -extern void (*D_80187F78[])(void); - -void func_80169F00(void *a0) { - D_80187F78[*(u16 *)((s32)a0 + 0x2)](); -} - - - -// @class: plumbing -// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) - -extern void func_800D1FC8(s32 a0, s32 a1); -extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); -extern void func_80128EA8(s32 a0, s32 a1, s32 a2); -extern void func_80146C3C(void); - -extern char D_80187F28[]; -extern char D_80187EE8[]; - -void func_80169F3C(int param_1) -{ - int iVar1; - - ((int (*)(int, int))func_800D1FC8)(param_1, 6); - iVar1 = func_800D21C4(param_1, D_80187F28, 0x16); - if (iVar1 != 0) { - *(int *)(param_1 + 0x20) = iVar1; - *(short *)(iVar1 + 0x1a) = 0x2000; - *(short *)(iVar1 + 0x18) = 0x2000; - *(char *)(iVar1 + 0x26) = 0x60; - *(char *)(iVar1 + 0x25) = 0x60; - *(char *)(iVar1 + 0x24) = 0x60; - *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; - ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187EE8); - *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; - } else { - ((void (*)(int))func_80146C3C)(param_1); - } -} - - -DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ - - -extern void (*D_80187FB0[])(void); - -void func_8016A020(void *a0) { - D_80187FB0[*(u16 *)((s32)a0 + 0x2)](); -} - - -DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ - -DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ - -DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ - -// @class: regalloc-order -// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. - -#include "common.h" - - - -typedef struct { s16 x, y, z, pad; } SVEC_8016A290; - -struct Fr_8016A290 { - SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ - SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ - s32 pos[3]; /* 0x10 -> sp+0x20 */ - s32 _pad1c; /* 0x1C -> sp+0x2C */ - s16 mtx[32]; /* 0x20 -> sp+0x30 */ - SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ - struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ - u32 code; /* 0x90 -> sp+0xA0 */ -}; - -void func_8016A290(s32 param_1, void *param_2, void *param_3) { - extern u8 D_80187F80; - extern u8 D_80187F94[]; - - struct Fr_8016A290 fr; - u8 *p; - s32 i; - register s32 t __asm__("$2"); - register s32 zr __asm__("$0"); - s32 flags; - s32 iVar3; - - iVar3 = *(s32 *)(param_1 + 0x34); - - fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; - fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; - fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; - ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); - - *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; - *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; - *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; - func_800D20C0(&fr.center, &fr.diff, 8); - func_80017E68(&fr.center, fr.mtx); - - fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); - fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); - fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); - ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); - func_800D23D0(&fr.diff); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.pos[0] = D_801269A4 - fr.center.x; - fr.pos[1] = D_801269A8 - fr.center.y; - fr.pos[2] = D_801269AC - fr.center.z; - ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); - fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); - RotMatrixYXZ(&fr.diff, fr.mtx); - - fr.v[3].z = 0; - fr.v[2].z = 0; - fr.v[0].z = 0; - fr.v[1].z = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - flags = D_800B99DA; - if (flags & 1) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; - } else if (flags & 2) { - fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; - } else { - fr.col[1].r = *(s32 *)(param_1 + 0x30); - } - - p = ((u8 *)&D_80187F80); - fr.col[0].b = 0; - fr.col[0].g = 0; - fr.col[0].r = 0; - fr.col[2].b = 0; - fr.col[2].g = 0; - fr.col[2].r = 0; - fr.col[3].b = 0; - fr.col[3].g = 0; - fr.col[3].r = 0; - fr.code = 0x50000000; - fr.col[1].b = fr.col[1].r >> 3; - fr.col[1].g = fr.col[1].r >> 3; - i = 0; -L1: - fr.v[0].x = (s8)*p++; - fr.v[0].y = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].y = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].y = (s8)*p--; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L1; - - fr.v[3].y = 0; - fr.v[2].y = 0; - fr.v[0].y = 0; - fr.v[1].y = 0; - fr.v[1].x = 0; - fr.v[1].z = -0x20; - p = D_80187F94; - i = 0; -L2: - fr.v[0].x = (s8)*p++; - fr.v[0].z = (s8)*p++; - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p--; - func_80017758(fr.v, fr.mtx); - if ((s16)i == 1) { - fr.v[1].z = 0x20; - p += 2; - } - t = i + 1; - i = t + zr; - if ((s16)t < 4) goto L2; - - p += 2; - fr.v[0].x = 0; - fr.v[0].z = -0x20; - fr.col[0].r = fr.col[1].r; - fr.col[0].b = fr.col[1].g; - fr.col[0].g = fr.col[1].g; - i = 0; -L3: - fr.v[2].x = (s8)*p++; - fr.v[2].z = (s8)*p++; - fr.v[3].x = (s8)*p++; - fr.v[3].z = (s8)*p++; - func_80017758(fr.v, fr.mtx); - t = i + 1; - i = t + zr; - if ((s16)t < 2) goto L3; -} - - - - -extern void (*D_80187FBC[])(void); - -void func_8016A700(void *a0) { - D_80187FBC[*(u16 *)((s32)a0 + 0x2)](); -} - - -// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. -typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; -typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; - -typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; - -typedef struct Obj_8016A73C { - short unk0; - short unk2; - short unk4; - short unk6; - short unk8; - short unkA; - short unkC; - short unkE; - char pad10[0x24]; /* 0x10 .. 0x33 */ - SubA_8016A73C *unk34; /* 0x34 */ - Mat_8016A73C mat; /* 0x38 .. 0x57 */ -} Obj_8016A73C; - - - -s32 func_8016A73C(s32 arg0) { - int sp10[8]; - short v[3]; /* sp30, sp32, sp34 */ - int r; - short tmp; - - r = ((int(*)())rand)(); - v[1] = ((r & 0x7F) << 4) + 0x400; - v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; - v[2] = 0; - ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); - ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); - v[0] = 0; - v[1] = 0; - v[2] = -0x50; - ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); - - ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); - - tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; - ((Obj_8016A73C *)arg0)->unk6 = tmp; - ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; - ((Obj_8016A73C *)arg0)->unkA = tmp; - ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; - tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; - ((Obj_8016A73C *)arg0)->unkE = tmp; - ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; - ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; -} - - - -DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ - - -// @class: struct -// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) - -DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ - - -DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ - - -extern void (*D_80188004[])(void); - -void func_8016AB30(void *a0) { - D_80188004[*(u16 *)((s32)a0 + 0x2)](); -} diff --git a/src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c b/src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c new file mode 100644 index 000000000..d0e8775de --- /dev/null +++ b/src/ov_SC06_016/ov_SC06_016_jr_8015C32C.c @@ -0,0 +1,5926 @@ +#include "common.h" +#include "../shared/engine_core.h" + + +/* ==== Phase-26 §8b carried decl layer (jr_isolate_all.py) =================== + * The file-scope decl environment from earlier code regions of this object — + * file-local types, col-0 decls, DEFINE_func macro externs, and each earlier + * definition's implied prototype (types first, then decls in original order). + * Decls emit no code => byte-neutral. See cookbook §8c. */ +struct Ent_801506A4 { + unsigned short unk0; /* 0x0 */ + char pad[0x5A]; + unsigned short unk5C; /* 0x5C */ + char pad2[0x12]; + short unk70; /* 0x70 */ +}; +extern void func_801458E0(void); +extern s32 D_800AE6AC; +extern s32 D_800AE6B0; +extern s16 D_800B9A0A; +extern u8 D_80078E50; +extern void func_800D185C(u8 *a0); +extern void func_801458E8(void); +extern s32 func_80029504(void); +extern void func_80145B24(void); +extern u8 D_801873D0; +extern u8 D_80187340; +extern u8 D_8018731C; +extern u8 D_801872F8; +extern u8 D_801873AC; +extern u8 D_80187388; +extern u8 D_80187364; +extern u8 D_801872D4; +extern void func_80145934(void); +extern u8 D_80187460; +extern u8 D_8018743C; +extern u8 D_80187418; +extern u8 D_801873F4; +extern void func_80145A2C(void); +extern s32 func_800291DC(s32); +extern void func_800291C8(s32, s32); +extern void func_80162120(void); +extern void func_80029124(s32, s32); +extern s32 func_80165A50(s32); +extern void func_80029514(s32); +extern u8 D_800AF630[]; +extern u8 D_80078EC0; +extern s32 D_80126B58; +extern s32 func_80028FBC(void); +extern s32 func_80029000(void); +extern s32 func_80028D9C(void); +extern void func_8002D4C8(s32 a0, s32 a1); +extern void func_80145BF8(void); +extern s32 func_800291B4(s32 arg); +extern void func_800291A0(s32, s32); +extern void func_80145C54(void); +extern s32 func_80145CEC(); +extern s32 func_80029178(s32 arg); +extern void func_80146014(s32 a0); +extern unsigned char D_80186858[]; +extern unsigned char D_80186888[]; +extern unsigned char D_801868D8[]; +extern unsigned char D_80186908[]; +extern unsigned char D_80186938[]; +extern void func_80145EE8(s32 param_1); +extern void MoveImage(void *a0, s32 a1, s32 a2); +extern void func_80146074(void); +extern s32 func_80146128(void); +extern void func_80146360(void); +extern void func_801463A0(void); +extern void func_8014607C(void); +extern s32 *D_80126B78; +extern u8 D_80078EC1; +extern s32 D_80078EC8; +extern s32 D_80126B9C; +extern s32 D_8011F730; +extern u16 D_801152B8; +extern u16 D_8012693A; +extern u8 D_80126BE0[]; +extern u8 D_801150F0[]; +extern void *memcpy(void *dst, const void *src, u32 n); +extern void func_80146FC4(s32 a0); +extern void func_80150A70(s32 a0); +extern void func_80147098(s32 *a0); +extern void func_8014A638(s32 arg0); +extern s32 func_80155458(s32 a0); +extern s32 func_80029104(void); +extern void func_80029344(void); +extern void func_8014ADE0(s32 a0); +extern void func_8014B350(s32 a0); +extern void func_8014B7A4(s16 *param_1); +extern s32 func_80161D58(s32 a0); +extern void func_80161A90(s32 a0); +extern void func_8014B504(u16 *a0); +extern void func_80149BEC(s32 a0); +extern void func_8014B5D0(s32 *a0); +extern void func_8014C99C(u8 *a0); +extern void func_8014B190(s32 s0); +extern void func_80148648(s32 a0, s32 a1); +extern s32 func_80149228(s32 a0); +extern void func_8014A59C(s32 a0); +extern void func_8016F14C(void *a0); +extern void func_80154418(void *a0); +extern void func_80154BE4(s32 a0); +extern void func_80165694(s32 arg0); +extern void func_801654A8(s32 a0); +extern void func_8014A680(s32 a0); +extern void func_8014A6A8(s32 a0); +extern void func_8014A71C(s32 a0); +extern void func_80172588(s32 *a0); +extern void func_801473DC(s32 *a0); +extern void func_80015978(s32 a0, s32 *a1); +extern void (*D_80186988[])(void *); +extern u8 D_80126BA4; +extern s32 D_80127098; +extern s32 D_80127094; +extern s32 D_80127090; +extern void func_80146534(void); +extern void func_8001D074(s32 a0, s32 a1); +extern void func_80146554(void); +extern void func_80146578(void); +extern void func_8001CFDC(s32, s32); +extern void func_8014659C(void); +extern void func_8001D074(s32, s32); +extern void func_801465C0(void); +extern void func_801465E4(void); +extern void func_801466F0(s32 a0, s32 a1, s32 a2, s32 a3, s32 sp5, s32 sp6, s32 sp7, s32 sp8); +extern s32 D_8011F9D0; +extern s32 func_80146608(s32 a0, s32 a1, s32 a2, s32 a3, s16 arg9, s32 arg10, s32 arg11, s32 arg12, s32 arg13); +extern void func_801466B4(u16 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 D_8011F750; +extern s32 D_8011F754; +extern u8 * func_801468C8(s32 arg0, u8 arg1); +extern s32 D_8011D030; +extern s32 func_80146994(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80146924(s32 a0, s32 a1, s32 a2, s32 a3, s32 arg5); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_80146994(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_801469C8(int a0, void *a1, int a2, int a3, u16 arg5, int arg6, int arg7, int arg8); +extern s32 func_80146B9C(void *a0); +extern void func_80146AB4(s16 a0, s32 a1, s16 a2, s16 a3, u16 a4, s32 a5, s32 a6); +extern u16 D_8011DA28; +extern s32 func_80146B9C(void * arg0); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80146CA0(void *a0); +extern void func_80146CB4(void *a0); +extern void func_80146CC8(s32 a0); +extern void func_80146D30(s32 a0); +extern void func_80146D80(s32 *a0); +extern void func_80146DE8(s32 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80146D90(s32 a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146DF8(s32 *a0, s32 a1, s32 a2, s32 a3, s32 t0); +extern void func_80146E90(s32 *a0, s32 a1); +extern s32 func_80146E98(s32 a0); +extern void func_80015954(s32 a0, s32 a1); +extern void func_80149374(s32 a0, s32 a1); +extern void func_80146F58(s32 a0, s32 a1); +extern void func_80146EC0(s32 a0, s32 a1, s32 a2, s32 a3); +extern s16 func_8012A68C(void); +extern s16 func_8012A758(void); +extern void func_8004978C(s16 *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern u8 D_80126DB0[]; +extern u16 D_80126DB6; +extern void func_8014704C(s32 *a0); +extern s32 func_80147054(void *a0); +extern void func_80147060(u8 * a0); +extern void func_8014706C(void *arg0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80147084(s32 *a0); +extern void func_8014708C(void *arg0); +extern s32 func_801470A0(void *a0); +extern void func_801470AC(s32 *a0); +extern void func_801470B4(s32 arg0); +extern void func_801470C0(s32 a0); +extern void func_80147118(s32 a0); +extern s16 D_80126BB8; +extern s16 D_80126BBA; +extern s16 D_80126BBC; +extern void func_80147264(s32 a0); +extern void func_80147290(void); +extern void func_801472B4(void *a0); +extern s32 func_801472C8(struct S *a0); +extern void *D_8012707C; +extern void func_801472DC(void); +extern void func_801472F0(void *a0); +extern void func_80147364(u16, s32); +extern void func_80147300(u16 arg0); +extern void func_80147324(s32 arg0); +extern void func_801473EC(s32 *a0); +extern void func_80147460(s32 a0); +extern void func_80147514(); +extern void func_80147628(s32 a0); +extern void func_80147478(s32 a0); +extern void func_801474D8(s32 *a0); +extern void func_801474EC(s32 *a0); +extern s32 func_80012C6C(s32 a0, s32 a1, s32 a2); +extern s32 func_800129CC(s32 a0, s32 a1); +extern void func_80147514(s32 arg0); +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void func_800123F0(s32 a0, s32 a1); +extern void func_80147718(s32 a0); +extern void func_80147788(void *a0, s32 a1); +extern void func_801477A8(void *a0, s32 a1); +extern void func_801477C8(void *a0, s32 a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80147814(s32 a0, s32 a1); +extern void func_80147928(int a0, int a1); +extern void func_8014799C(int a0, int a1); +extern void func_80147A10(int a0, int a1); +extern void func_80147860(int a0, int a1, int a2, int a3); +extern void func_80147948(s32 a0, s32 a1, s32 a2); +extern void func_801479BC(s32 a0, s32 a1, s32 a2); +extern void func_80147A30(s32 a0, s32 a1, s32 a2); +extern void func_801478B8(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147948(int a0, int a1, int a2); +extern void func_801479BC(int a0, int a1, int a2); +extern void func_80147A30(int a0, int a1, int a2); +extern void func_80147AD4(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147A84(s32 arg0); +extern void func_80147C30(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147AAC(s32 arg0); +extern void func_80147CC8(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4); +extern void func_80147B5C(s32 a0, void *a1); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void *a4); +extern void func_80147B18(s32 a0); +extern void func_80147B5C(s32 arg0, void *arg1); +extern void func_80147C30(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147DC0(s32 a0, s32 a1); +extern void func_80147D38(s32 a0, s32 a1, s32 a2, s32 a3, void * a4); +extern void func_800484EC(s32 a0, s32 a1, s32 a2); +extern void func_80147E44(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_80147F78(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern void func_80147F50(s32 arg0); +extern void func_80148038(s32 a0, s32 a1); +extern s32 ratan2(s32 a0, s32 a1); +extern s32 csqrt(s32 a0); +extern s32 func_80012A60(s32 a0, s32 a1); +extern void func_80148094(int param_1, short *param_2, int *param_3); +extern void func_801485B8(s32 a0, s32 a1, s32 a2); +extern void func_801484B0(s32 a0, s32 a1); +extern s32 func_80154358(void *a0); +extern void func_801484E8(s32 a0, s32 a1); +extern void func_80148534(s32 a0, s32 a1); +extern void func_8014856C(s32 a0, s32 a1); +extern void func_801485B8(s32 arg0, s32 arg1, s32 arg2); +extern void func_80148634(void *a0); +extern u8 D_800B9A64; +extern s32 func_80014DC0(); +extern s32 func_80014D68(); +extern s32 func_80014D94(); +extern s32 func_80014CF8(); +extern void func_800120DC(); +extern s32 func_800CF8B4(); +extern u16 func_801487F4(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern u8 func_8014880C(s32 *a0); +extern u16 func_80148818(s32 *a0); +extern s32 func_80047D3C(s32 a0); +extern s32 func_80148824(void *arg0); +extern s32 func_801488A8(u8 *a0); +extern s32 func_8014891C(s32 a0); +extern s32 func_80148980(u8 *a0); +extern s32 func_801489E8(s32 a0); +extern s32 func_80148A48(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_80148AAC(u8 *a0); +extern s32 func_80148C18(void); +extern s32 func_80148C20(s32 a0, s16 a1); +extern s32 func_80148C34(s32 a0, s32 a1); +extern s32 func_80148C4C(s32 a0, s32 a1); +extern s32 func_80148C64(s32 a0, s32 a1); +extern s32 func_80148C7C(void); +extern s32 func_80148C84(s32 a0, s32 a1); +extern s32 func_80148C9C(s32 a0, s32 a1); +extern s32 func_80148CB4(s32 a0, s32 a1); +extern s32 func_80148CCC(s32 a0, s32 a1); +extern s32 func_80148CE4(void); +extern s32 func_80148CEC(void); +extern s32 func_80148CF4(s32 a0, s32 a1); +extern s32 func_80148D0C(s32 a0, s32 a1); +extern s32 func_80148D24(void *a0, int a1); +extern s32 func_80148D3C(void); +extern s32 func_80148F60(void); +extern s32 func_80148F68(s32 a0); +extern s32 func_80148F74(s32 a0); +extern s32 func_80148F80(s32 a0); +extern s32 func_80148F8C(s32 a0); +extern s32 func_80148F98(void); +extern s32 func_80148FA0(s32 a0); +extern s32 func_80148FAC(s32 a0); +extern s32 func_80148FB8(s32 a0); +extern s32 func_80148FC4(s32 a0); +extern s32 func_80148FD0(void); +extern s32 func_80148FD8(void); +extern s32 func_80148FE0(s32 a0); +extern s32 func_80148FEC(s32 a0); +extern s32 func_80148FF8(s32 a0); +extern s32 func_80149004(void); +extern void func_8014900C(s32 *a0); +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern void func_80149048(s32 *a0); +extern void func_8014905C(u8 *a0); +extern void func_801490E0(s32 *a0, s16 a1); +extern void func_801490E8(s32 *a0, s16 a1); +extern void func_801490F0(s32 *a0, s16 a1); +extern void func_80149078(s32 *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_80012B04(s32 a0, s32 a1, s32 a2); +extern void func_801490F8(s32 a0, s32 a1); +extern s32 func_801491C4(s32 a0); +extern s32 func_80149184(s32 a0); +extern s32 D_801151D4; +extern void func_80149204(s32 *a0); +extern void func_80149210(s32 a0, s32 a1); +extern s32 func_80149284(s32 *a0, s32 a1); +extern void func_80149350(s32 arg0); +extern void func_80149290(s32 a0); +extern void func_8012F14C(s32); +extern void func_80149374(s32 arg0, s32 arg1); +extern void func_801493D0(s32 param_1, s32 param_2, s32 param_3); +extern void func_8012F038(s32); +extern void func_8014942C(s32 arg0); +extern void func_8012EF70(s32 a0, s32 a1); +extern void func_80149544(s32 arg0, s32 arg1, s32 arg2); +extern void func_8012EFB8(s32 a0); +extern void func_80149584(s32 arg0, s32 arg1, s32 arg2); +extern void func_8014964C(s32 param_1, s32 param_2); +extern s32 func_801496D4(void *a0); +extern void func_8015AD08(); +extern void func_80149704(void); +extern void func_8015ACC4(); +extern void func_80149724(void); +extern u8 D_80078EBF; +extern s32 func_80149744(struct S_80149744 *a0); +extern void func_8015F7A0(); +extern void func_80149788(void); +extern void func_801653B8(); +extern void func_80149864(void); +extern s16 currentLocationId; +extern s32 func_8016F1AC(void); +extern s32 func_80149884(void); +extern void func_80160B00(); +extern void func_801498C0(void); +extern s32 func_80149AA8(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80146750(void *a0); +extern s32 func_801498E0(s32 *a0); +extern s32 func_8012E5CC(s32 a0, s32 a1, s32 a2); +extern void func_80147364(u16 a0, s32 a1); +extern s32 func_800CCF28(s32 a0); +extern u8 D_80126B5C; +extern s32 func_80149954(s32 s0); +extern s32 func_80149A64(s32 *a0); +extern void func_8015DAC4(s32 *a0); +extern void func_8015554C(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern void func_80149B14(s32 *a0); +extern u8 func_8014BEF8(void); +extern s32 func_80149B54(s32 * arg0); +extern void func_8015DE24(s32 *a0); +extern void func_80157510(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80029178(s32 a0); +extern s32 func_80149C08(s32 arg0); +extern void func_801577C8(); +extern void func_80149C94(void); +extern void func_80157D20(void); +extern void func_80149CB4(void); +extern s32 func_80149CD4(s32 a0); +extern u8 func_8014B5B8(s32 *a0); +extern s32 func_80149D10(s32 a0); +extern s32 func_80149E94(s32 a0); +extern s32 func_80149DD8(s32 a0); +extern s32 func_80149D9C(s32 a0); +extern u8 D_801202A0[]; +extern s32 func_80149F2C(s32 a0, s32 a1); +extern s32 func_80149E94(s32 arg0); +extern void func_80149FA8(void); +extern s32 D_80186A50[]; +extern u8 D_80078E78[]; +extern s32 func_80149FB0(s32 a0); +extern s32 func_80135260(s32, s32, s32, s32); +extern void func_8014A1B0(s32 a0, s32 a1); +extern s32 func_8014A048(s32 param_1); +extern u16 func_80156370(u16 a0); +extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); +extern void func_8015D4B4(); +extern void func_8014A218(void); +extern s32 func_8014C278(s32 a0, s32 a1, s32 a2); +extern s32 func_8014C2B0(void *a0, void *a1, s32 a2); +extern s32 func_8014A238(s32 arg0); +extern s32 func_8014A2E4(s32 a0); +extern void func_8014A380(s32 a0, s32 a1); +extern s16 D_801152B0; +extern s16 D_801152B4; +extern s32 func_8014A3E0(struct S_8014A3E0 *a0); +extern s32 func_8014A454(s32 a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8015EDD4(); +extern void func_8014A4FC(void); +extern s32 func_8014A674(s32 *a0); +extern s32 func_8014A69C(s32 *a0); +extern s32 func_8014A6C4(s32 a0); +extern void func_8015E184(); +extern void func_8014A830(void); +extern s32 func_80029AF4(void); +extern s32 func_8014A850(s32 param_1); +extern void func_8014AA04(s32 a0); +extern void func_801599A4(void *a0); +extern void func_80159B3C(void *a0); +extern s32 func_80165A20(s32 a0); +extern void func_8014AB7C(); +extern void func_8014AC10(); +extern void func_8014AA28(void); +extern void func_8014AB5C(void); +extern void func_80162CCC(void); +extern void func_8014AB7C(s32 arg0); +extern void func_8014ABF0(void); +extern void func_80016714(void *a0, s32 a1); +extern void func_8014AC10(s32 arg0); +extern void func_8014ACC0(s32 a0, s32 a1); +extern void func_8014AD30(s32 a0, u16 *a1, s32 a2, s32 a3); +extern void func_8014ACE8(void *a0, s32 a1, s32 a2); +extern void func_80146AFC(void *a0); +extern void func_8014ADA8(s32 a0, s32 a1); +extern void func_8014AD7C(s32 a0); +extern s32 D_80078E8C; +extern void func_8014B034(s32 arg0); +extern void func_8014B00C(s32 arg0); +extern void func_8014B084(void); +extern s16 D_80078E90; +extern void func_8014B034(s32 a0); +extern u16 D_80078EAC; +extern u8 D_80078EBA; +extern void func_800D10EC(void); +extern void func_8002AC98(void); +extern s32 func_8014B154(s32 *a0); +extern void func_8014B12C(void); +extern void func_8014B2F8(void); +extern void func_8014B4C4(void); +extern void func_8014B160(s32 a0); +extern s32 func_8016F1C4(void); +extern s16 D_80078E96; +extern s16 D_80078EB8; +extern u16 D_80078EA6; +extern void func_8014B2A8(void); +extern void func_8014B310(void); +extern void func_8014B2D0(void); +extern s32 D_80078E94; +extern s32 D_80078ECC; +extern void func_8014B33C(void); +extern u8 D_80062BF4[]; +extern void func_8014BC80(s32 a0, s32 a1); +extern void func_80019064(void *a0); +extern s32 D_80078E98; +extern void func_80166244(); +extern void func_8014B4D4(void *a0); +extern s16 D_80078E9A; +extern u8 D_80126D1C; +extern s32 D_80126D74; +extern void func_8014B598(s32 a0, s32 a1); +extern void func_8014B5B0(s32 *a0); +extern void func_8014B5C4(s32 *a0, s32 a1, s32 a2); +extern void func_8014B5D8(s32 s1); +extern s32 D_80078E9C; +extern s32 D_80078ED0; +extern void func_8014B6F0(s32 a0, s32 a1); +extern void func_8014B768(s32 a0, s32 a1); +extern void func_8014B944(s32 a0, s32 a1, s32 a2); +extern s32 D_80078EA4; +extern u16 D_80078EB2; +extern s16 D_80078EB4; +extern void func_8014BB0C(void); +extern void func_8014BB24(s32 a0, s32 a1, s32 a2); +extern void func_8014BC0C(s32 a0, s32 a1); +extern void func_8014BC44(s32 a0, s32 a1); +extern u8 D_800B9A17; +extern void func_8014BCC0(s32 a0, s32 a1); +extern u16 D_80078EB6; +extern s32 func_8014BCEC(s32 a0, s32 a1); +extern void func_8014BD24(s32 a0, s32 a1); +extern void func_8014BD60(s32 param_1, s32 param_2); +extern void func_8014BD98(s32 a0, u16 a1); +extern void func_8014BDC8(void); +extern void func_8014BDE0(void); +extern s32 func_8017267C(s32 *a0); +extern s32 func_80013294(void *a0, void *a1); +extern void func_80029ED4(s32 a0); +extern void func_8014BDE8(s32 a0); +extern void func_8014BE78(void); +extern void func_8014BE9C(void); +extern void func_80029124(s32 a0, s32 a1); +extern void func_8014BEC0(void); +extern void func_8014BF18(s32 a0); +extern void func_8014BF48(void); +extern u8 func_8014BF6C(void); +extern void func_8014BF8C(u8 arg0); +extern void func_8014BFB0(void); +extern u8 func_8014BFD4(void); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_8014C010(s32 a0, s32 a1); +extern s32 func_8014C050(s32 a0, s32 a1); +extern s32 func_8014C088(s32 a0, s32 a1); +extern s32 func_8014C0C8(s32 a0_unused, s32 a1, s32 a2); +extern s32 func_8014C118(void * a0, s32 a1, s32 a2); +extern s32 func_8014C168(s32 * param_1, s32 param_2); +extern void func_8014C1C8(s32 arg0, s32 arg1, void *arg2); +extern u8 D_80186AD8[]; +extern void func_8014C1A0(s32 arg0, s32 arg1); +extern s32 func_80013328(s32 a0, s32 a1); +extern s32 func_8014C59C(void *a0, void *a1); +extern s32 func_8014C308(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +extern s32 func_8014C43C(void *a0, s32 a1, s32 a2, s32 a3, s16 a5); +extern s32 func_8014C3A4(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C3D0(void *a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014C43C(void * a0, s32 a1, s32 a2, s32 a3, s16 a4); +extern s32 ratan2(s32 dx, s32 dy); +extern u8 D_80186AE0; +extern s32 func_8014C5FC(s32 a0, s32 a1, void *a2); +extern s16 func_8014C5D0(s32 a0, s32 a1); +extern s32 func_8014C5FC(s32 a0, s32 a1, void * a2); +extern u8 D_80126D17; +extern void func_8014C6AC(void); +extern void func_8014C6C0(void); +extern u8 D_80126D1E; +extern void func_8014C6D0(void); +extern void func_8014C6E0(void); +extern s32 func_8014C860(s32 a0, s32 a1); +extern void func_8014C8C8(s32 a0, s32 *a1); +extern void func_8014C88C(s32 a0); +extern void func_8014C8C8(s32 dst, s32 * src); +extern void func_8014C8F0(s32 arg0); +extern u8 D_801151F0[]; +extern s32 func_8014C918(s32 a0, s32 a1); +extern s32 D_80126B50; +extern void func_8014C968(void); +extern void func_8014C978(void); +extern s32 func_8014C98C(void); +extern void func_80139914(s32 a0); +extern s32 func_8014CA00(s32 a0); +extern u16 func_8014CA70(s32 a0, s32 a1); +extern s32 func_8014CA14(s32 a0, s32 a1); +extern u16 func_8014CAE4(s32 *a0, s32 a1); +extern s32 func_8014CA88(s32 *a0, s32 a1); +extern s32 func_8014CAFC(void); +extern s32 func_8014CB0C(void); +extern s32 func_8014CB1C(void); +extern u8 D_80126D1F; +extern s32 func_8014CB2C(void); +extern s32 func_8014CB58(void); +extern u8 D_80126D1D; +extern void func_8014CB68(void); +extern s32 func_8014CB7C(void); +extern s32 func_8014CB8C(void); +extern struct Packed8 D_80126C98; +extern short D_80126C9E; +extern void func_8014CB9C(struct Packed8 *a0); +extern s32 D_80126CDC; +extern void func_8014CBD8(void); +extern s16 D_80126CC4; +extern void func_8014CBE8(void); +extern void func_8014CBF8(void *a0); +extern void func_8014D3E0(s32 a0); +extern void func_8014D04C(void); +extern void func_8014CCB4(void); +extern void func_8014CC28(s32 a0); +extern void func_8014CD0C(u8 *a0); +extern void func_8014CF04(s32 a0, void *a1, void *a2); +extern void func_8014CD80(s32 a0, void *a1, void *a2); +extern void func_8014D0A4(s32 a0); +extern void func_8014D2A0(s32 a0, void *a1, void *a2); +extern void func_8014D12C(s32 a0, void *a1, void *a2); +extern void func_8014D438(s32 a0); +extern void func_8014D3E0(s32 _arg0); +extern void func_8014D610(s32 a0, void *a1, void *a2); +extern void func_8014D4C0(s32 a0, void *a1, void *a2); +extern void func_8014D790(s32 a0); +extern void func_8014D738(void); +extern s32 func_8014DD8C(s32 a0, void *a1, void *a2); +extern void func_8014D820(s32 a0, void *a1, void *a2); +extern s32 func_80135888(s32 a0, s32 a1, s32 a2, s32 a3); +extern s32 func_8014DCE0(s32 arg0, s32 arg1, s32 arg2); +extern s32 func_8014DD8C(s32 arg0, void *arg1, void *arg2); +extern void func_8014DF94(s32 arg0); +extern void func_8014DF3C(void); +extern s32 func_8014E284(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E048(s32 a0, u16 *a1, u16 *a2); /* u16*: def lhu semantics (T5b reconcile; ptr param type codegen-neutral for the caller) */ +extern s32 func_80135A4C(s32 a0, s32 a1, s32 *a2, s32 a3); +extern s32 func_80133784(s32 a0, void *a1, s32 a2); +extern u8 D_801152A8[]; /* canonical TU type (engine_core) — read via *(u16*) cast */ +extern s16 D_801152AC; +extern s32 func_8014E048(s32 param_1, u16 * param_2, u16 * param_3); +extern void func_8014E48C(s32 a0); +extern void func_8014E434(void); +extern void func_8014E5B4(s32 a0, void *a1, void *a2); +extern s32 func_8014E514(u8 *a0, s32 a1, s32 a2); +extern void func_8014E6F8(struct SubE6F8 *a0); +extern void func_8014E6A0(void); +extern s32 func_8014E83C(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014E790(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014E83C(s32 arg0, s16 * arg1, s16 * arg2); +extern void func_8014E934(s32 _arg0); +extern s32 func_8014EA4C(void *a0, void *a1, void *a2, s32 a3); +extern s32 func_8014E98C(void *a0); +extern u16 D_800B99DA; +extern s32 D_801150D8; +extern s16 D_801152AA; +extern u8 D_80126720[]; +extern s16 D_80126724; +extern s32 func_8014EA4C(void * a0, void * a1, void * a2, s32 _arg3); +extern s32 func_8014ED80(struct SubED80 *a0); +extern int D_8019E488; +extern void func_8014ED28(s32 _arg0); +extern s32 func_8014EE14(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014EE14(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F24C(struct SubF24C *a0); +extern void func_8014F1F4(void); +extern s32 func_8014F2E0(s32 a0, s16 *a1, s16 *a2); +extern s32 func_8014F2E0(s32 arg0, s16 * arg1, s16 * arg2); +extern s32 func_8014F4C0(); +extern s32 func_8014F468(void); +extern int func_8014F74C(); +extern int func_8014F6F4(void); +extern u8 D_800D3918[]; +extern u8 D_801152A8[]; +extern s32 D_801152BC; +extern int func_8014F74C(s32 arg0); +extern s32 func_8014FA70(s32 a0); +extern s32 D_8019E48C; +extern void func_8014FA04(s32 a0); +extern s32 func_8014FBC0(); +extern s32 func_8014FC18(u8 *self); +extern int func_8014FD54(int param_1); +extern void func_8014FCFC(void); +extern void func_80150170(void *a0); +extern s32 func_8014FE60(void *a0); +extern void func_8014FDF4(struct S8014FDF4 *a0); +extern s32 func_8014FE60(void *e); +extern s32 func_80134510(s32 arg); +extern s32 func_80150150(s32 a, s32 b); +extern s32 func_80150460(s32 a, s32 b); +extern void func_801504D8(u16 *a0); +extern s32 func_80150480(s32 _arg0); +extern s32 func_80150528(void *a0, void *a1, void *a2); +extern s32 func_80150528(void *arg0, void *arg1, void *arg2); +extern s32 func_801506A4(s32 a0, s32 a1); +extern s32 func_801505FC(s32 a0); +extern s32 func_801506A4(s32 arg0, s32 arg1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8015086C(int param_1); +extern s32 func_801508B4(s32 a0); +extern s32 func_8015094C(s32 a0); +extern short func_801508F8(s32 a0); +extern s32 D_80186B10; +extern s32 D_80126990; +extern s32 D_80126994; +extern u8 D_80126948[]; +extern s32 func_80021174(s32 a0, s32 a1); +extern s32 func_8015094C(s32 param_1); +extern void func_80150B9C(void); +extern s32 func_80151184(s32 a0, s32 a1, s32 a2); +extern s32 func_80150BA4(s32 a0); +extern s32 func_801619D0(void *a0); +extern void func_80150BC8(s32 *a0); +extern s32 func_80150480(s32 a0); +extern u16 D_800AE6DC; +extern void func_80150C48(s32 a0); +extern int func_80151184(int arg, int a1, int a2); +extern int func_80150CA0(int arg); +extern void func_80150EC4(s32 a, s32 b); +extern void func_80150CC4(s32 a); +extern void func_80150CE4(s32 a); +extern void func_80150D04(s32 a); +extern void func_80150D24(s32 a); +extern void func_80150D44(s32 a); +extern void func_80150D64(s32 a); +extern void func_80150D84(s32 a); +extern void func_80150DA4(s32 a); +extern void func_80150DC4(s32 a); +extern void func_80150DE4(s32 a); +extern void func_80150E04(s32 a); +extern void func_80150E24(s32 a); +extern void func_80150E44(s32 a); +extern void func_80150EC4(s32 a0, s32 a1); +extern void func_80150E64(s32 a0); +extern void func_80150E84(s32 a0); +extern void func_80150EA4(s32 a0); +extern u8 D_800AE6C0; +extern s16 D_800AE6C8; +extern s16 D_800AE6CA; +extern s16 D_800AE6CC; +extern s32 D_800AE6C4; +extern s16 D_800AE6CE; +extern u8 D_800AE6BE; +extern u8 D_801201F8[]; +extern void func_80150F78(void); +extern void func_80150F80(s32 a0); +extern int func_80150FB4(int arg); +extern void func_80150FD8(s32 a0); +extern int func_80151014(int arg); +extern void func_80151038(s32 a0); +extern int func_80151070(int arg); +extern int func_80151094(int arg); +extern void func_801510B8(void); +extern void func_801510C0(void); +extern int func_801510C8(int arg); +extern int func_801510EC(int arg); +extern s32 func_8012DB84(void); +extern s32 func_80151110(void); +extern void func_80151130(void); +extern int func_80151138(int arg); +extern void func_8015115C(s32 *a0, s16 a1); +extern s32 func_80151164(s32 a0, s32 a1); +extern s32 func_80151184(s32 arg0, s32 arg1, s32 arg2); +extern void func_801511A8(u8 *a0); +extern void func_801511C4(u8 *a0); +extern int func_80151204(int arg, int a1); +extern int func_801511E0(int arg); +extern int func_80151204(int a0, int a1); +extern void func_80151238(void *a0); +extern void func_8015126C(u16 *p); +extern void func_80151780(s32 a0); +extern void func_801516F0(s32 *a0); +extern void func_8015173C(s32 *a0); +extern s16 D_8011DB1A; +extern s32 D_80127518; +extern s32 D_801151FC; +extern s32 func_801725CC(u8 *a0); +extern s32 func_80029D3C(void); +extern void func_80151878(void); +extern void func_80153B58(s32 *a0); +extern s32 func_80151880(s32 a0); +extern s32 func_801518D8(s32 a0); +extern s32 func_80151944(void); +extern s32 func_80151924(void); +extern void func_8014E934(s32 a0); +extern void func_8014F3E8(s32 a0); +extern void func_801519C8(s32 a0); +extern void func_80151980(s32 a0); +extern M2C_UNK D_800D5880; +extern s32 D_800D58AC; +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_801519C8(s32 arg0); +extern void func_80151C54(s32 a0); +extern void func_801542DC(s32 *a0, s32 a1); +extern void func_8015BDD0(s32 *a0); +extern void func_80165718(s32 a0); +extern u8 D_800D46E4[]; +extern void func_80151AE4(s32 arg0); +extern void (*D_80186BB8[])(void); +extern void func_80151D24(void *a0); +extern void func_80151DB0(s32 a0); +extern void func_80151D60(void *a0); +extern s32 func_80172630(u8 *a0); +extern s32 D_80062C14; +extern void func_80151DB0(s32 param_1); +extern void func_80151E78(s32 *a0); +extern void func_80151ECC(struct S80151ECC *a0); +extern void func_80151FB4(s32 a0); +extern void func_80151F38(s32 *a0); +extern void func_801553C0(s32 a0); +extern void func_80153C18(); +extern void (*D_80186BDC[])(void); +extern void func_80152058(void *a0); +extern void func_801520DC(s32 a0); +extern void func_80152094(s32 a0); +extern void func_80147324(s32 a0); +extern u8 D_80062C04[]; +extern M2C_UNK D_80186BCC; +extern void func_801520DC(s32 arg0); +extern void func_801470B4(s32 a0); +extern void func_8015369C(s32 a0); +extern void func_80152194(s32 *a0); +extern s32 func_801536DC(s32 a0); +extern void func_8015220C(s32 a0); +extern s32 func_80153800(s32 a0); +extern void func_801522CC(s32 a0); +extern void func_80152254(s32 *a0); +extern void (*D_80186BF0[])(void); +extern void func_80152370(void *a0); +extern void func_801523F4(s32 a0); +extern void func_801523AC(s32 a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern u8 D_80186BFC[]; +extern void func_801523F4(s32 arg0); +extern void func_801525F4(int); +extern s32 func_801535F4(void *arg0); +extern void func_8015BF48(s32 *a0); +extern void func_80152500(int param_1); +extern void func_801525F4(s32 a0); +extern void (*D_80186C0C[])(void); +extern void func_80152698(void *a0); +extern void func_80152714(s32 a0); +extern void func_801526D4(s32 a0); +extern void func_80152790(s32 a0); +extern void (*D_80186C24[])(void); +extern void func_8015282C(void *a0); +extern void func_801528B0(s32 a0); +extern void func_80152868(s32 a0); +extern M2C_UNK D_80186C14; +extern void func_801528B0(s32 arg0); +extern void func_8015294C(s32 a0); +extern void func_80152A08(s32 a0); +extern void func_80152AC8(s32 a0); +extern void func_80152A50(s32 *a0); +extern void (*D_80186C38[])(void); +extern void func_80152B6C(void *a0); +extern void func_80152BF0(s32 a0); +extern void func_80152BA8(s32 a0); +extern void func_80152C80(s32 *a0); +extern void func_80152C40(s32 *a0); +extern void (*D_80186C54[])(void); +extern void func_80152D24(void *a0); +extern void func_80152DA8(s32 a0); +extern void func_80152D60(s32 a0); +extern M2C_UNK D_80186C44; +extern void func_80152DA8(s32 arg0); +extern void func_80152E4C(s32 a0); +extern void func_80152EFC(s32 a0); +extern void func_80152FBC(s32 a0); +extern void func_80152F44(s32 *a0); +extern void (*D_80186C68[])(void); +extern void func_80153060(void *a0); +extern void func_801530E4(s32 a0); +extern void func_8015309C(s32 a0); +extern void func_80155440(s32 *a0); +extern void func_801530E4(s32 arg0); +extern void func_80153150(struct S80153150 *a0); +extern void func_801531BC(s32 a0); +extern void func_8015327C(s32 a0); +extern void func_80153204(s32 *a0); +extern void (*D_80186C7C[])(void); +extern void func_80153320(void *a0); +extern void func_801533A4(s32 a0); +extern void func_8015335C(s32 a0); +extern void func_80153410(s32 *a0); +extern void func_80153490(s32 a0); +extern void func_80153550(s32 a0); +extern void func_801534D8(s32 *a0); +extern void (*D_8011DB28)(s32 a0); +extern s32 func_801536DC(s32 param_1); +extern void func_800139C8(s32 a0, void *a1, void *a2); +extern s32 func_80153978(s32 a0, u16 *src); +extern s32 func_80133784(s32 a0, void *src, s32 dst); +extern s32 func_801539F8(s32 a0, void *a1); +extern s32 func_801539F8(s32 a0, void * a1); +extern s32 func_8016DA04(s32 a0); +extern s32 func_80153BD8(s32 a0); +extern s32 func_80153BF0(s32 a0); +extern void func_80153C18(void); +extern u16 D_8011F748; +extern void func_80153C30(void); +extern void func_80153C74(s16 a0, s16 a1); +extern s16 D_8011DB18; +extern void func_80153C44(int a0, int a1, s16 a2); +extern s16 D_8011DB0C; +extern s32 D_80115210; +extern void func_80153C8C(void); +extern void func_80153C9C(void); +extern s32 func_80153CBC(void); +extern s32 D_80186C90; +extern void (*D_80186CB8[])(void *a0); +extern void func_80153CCC(S80153CCC *a0); +extern void func_80153D7C(s32 a0); +extern void func_80153D34(s32 a0); +extern u8 D_80186C98; +extern void func_80153D7C(s32 param_1); +extern void func_8015410C(void); +extern void func_80153E00(s32 param_1); +extern void func_80151664(void); +extern void func_80154134(u8 *a0); +extern void func_80154190(u8 *a0, s32 a1); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80154218(u8 *a0, s32 a1, s32 a2); +extern void func_801541D8(u8 *a0, s32 a1, s32 a2); +extern s32 func_801549F8(s32 a0, s32 a1, s32 a2); +extern void func_801542A4(); +extern void func_801542A4(s32 *a0, s32 a1); +extern void func_8015430C(); +extern void func_8015430C(u8 *arg0, s32 arg1, s32 arg2); +extern void func_8015444C(void *a0, s32 *a1, s32 *a2, s32 *a3); +extern s32 func_80154358(void * arg0); +extern void func_80154AB4(s32 a0, s32 a1); +extern void func_80154B20(s32 a0, s32 a1, s32 a2); +extern void func_80154AE0(s32 a0, s32 a1, s32 a2); +extern void func_80154B7C(u8 *a0, s32 a1); +extern void func_80154B4C(u8 *a0, s32 a1); +extern void func_80154BC8(void *a0, s32 a1, s32 a2); +extern void func_80154B98(void *a0, s32 a1, s32 a2); +extern u8 D_800D8D10[]; +extern s16 D_80078E9E; +extern void func_801550FC(s32 a0); +extern void func_80154ED8(s32 a0, s32 a1); +extern void func_80154F9C(s32 a0); +extern void func_800183E0(s32 a0); +extern void func_801550FC(s32 arg0); +extern void func_8001D150(s32, s32); +extern void func_8001D130(int, int); +extern void func_80155150(int param_1); +extern s32 D_800DE2A4[]; +extern void func_801552F4(s32 a0); +extern void func_80155344(s32 a0); +extern s32 func_80155394(s32 *a0); +extern void func_801553A8(s32 *a0); +extern s32 func_80029178(s32); +extern int (*D_80186D04[])(void); +extern s32 func_80155458(s32 param_1); +extern s32 func_801659DC(u8 *a0); +extern s32 func_801554B8(void *arg0); +extern void func_801555F4(void *a0); +extern void func_80155518(s32 *a0); +extern void func_80155580(void *a0); +extern void (*D_80186D08[])(void); +extern s32 func_80161104(void); +extern void func_801555F4(void *); +extern void func_801555BC(void *a0); +extern int func_80155A44(int param_1); +extern int func_80161208(); +extern u8 D_800D4DA8[]; +extern void func_80155B20(s32 *a0); +extern s32 D_800D4DB4; +extern void func_80155B9C(s32 a0); +extern u8 D_800D4DD4[]; +extern void func_80155C0C(s32 *a0); +extern void func_8014ED28(s32 a0); +extern int func_80155FF8(int arg, int a1); +extern s32 D_800D4DF4; +extern void func_80155C64(s32 a0); +extern void func_8015E880(s32 *a0); +extern void func_80155D70(s32 param_1); +extern void func_80155E30(void *a0); +extern s32 func_80161208(); +extern void func_80155EA4(void *arg0); +extern void func_80155F58(void); +extern s32 func_80155F80(); +extern s32 func_80155F60(void); +extern s32 func_80155F80(s32 a0); +extern int func_80155FB0(int arg, int a1); +extern int func_80155FD4(int arg, int a1); +extern int func_80156044(int arg, int a1); +extern S801563EC *func_801563EC(u16 idx); +extern s32 func_80029B4C(s32 a0, s32 a1); +extern s32 func_80029BC8(s32 a0, s32 a1); +extern s32 func_80029C44(s32 a0, s32 a1); +extern s32 func_8015640C(s32 a0, s32 a1); +extern s32 rand(void); +extern u32 func_8015616C(s32 param_1, u16 param_2); +extern u16 func_80156370(u16 param_1); +extern S801563EC * func_801563EC(u16 idx); +extern s32 func_801564B0(s32 a0); +extern s32 func_8002A1B4(void); +extern s32 func_8002A400(void); +extern s32 func_8002A670(void); +extern s32 func_8002A8E0(void); +extern s32 D_801151E0[]; +extern s32 func_801565C0(void); +extern void func_80156A14(s32 *a0); +extern void func_80156648(s32 *a0); +extern u8 D_8011DAD8[]; +extern s32 func_8014C568(void *a0); +extern void func_801567BC(s32 a0); +extern B8 D_80128120[]; +extern B8 D_80128138[]; +extern S8 D_80126AF0[]; +extern u8 D_80126730[]; +extern void func_80156848(s32 param_1, s32 param_2); +extern unsigned char D_8011520C[]; +extern unsigned short D_8018716C[]; +extern void func_80156A1C(s32 param_1, s32 param_2); +extern s32 D_801150E0[]; +extern void func_80156A88(s32 a0, s32 a1); +extern void func_80156B74(s32 param_1, u32 param_2, u8 *param_3); +extern void func_80156ECC(int param_1, int param_2, int param_3, int param_4, int param_5); +extern void func_80156FA8(s16 *param_1, s16 *param_2, s16 *param_3); +extern void func_80157158(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern s32 func_80135004(s32 a0, void *a1, s32 a2); +extern s32 func_80135260(s32 a0, s32 a1, s32 a2, s32 a3); +extern u32 func_801571C4(s32 a0, u16 a1, u16 a2, s32 a3, s32 a4, s32 a5, s32 a6, s32 a7, s32 a8, s32 a9, u16 a10, s32 a11, s32 a12); +extern void func_801575E4(void *a0); +extern void func_801574DC(s32 *a0); +extern void func_80157544(void *a0); +extern void (*D_8018717C[])(void); +extern void func_8014CC28(s32 a0); /* defined */ +extern void func_8014F3E8(s32 a0); /* declared */ +extern void func_8015BDD0(s32 *a0); /* defined */ +extern void func_801575E4(void *a0); /* defined */ +extern void func_80157580(s32 arg0); +extern u8 D_800D4F14[]; +extern void func_801576A8(void *arg0); +extern s32 func_8015773C(u8 *a0); +extern s32 func_8015771C(u8 *a0); +extern s32 func_8015773C(u8 * arg0); +extern int D_8019E4C0; +extern void func_801578C0(s32 a0); +extern void func_80157788(int param_1); +extern void func_801577C8(s32 arg0); +extern void (*D_801871A4[])(void); +extern void func_80157808(void *param_1); +extern void func_80157880(s32 a0); +extern s32 func_801725A4(u8 *a0); +extern u8 D_800D5128; +extern u8 D_80187184; +extern void func_801578C0(s32 param_1); +extern void func_80147A84(int); +extern void func_80148038(int, int); +extern void func_80147460(int); +extern void func_80146D90(int); +extern void func_80161450(void *a0); +extern void func_80157A8C(int); +extern void func_80154A74(int, int); +extern unsigned char D_800D5178; +extern unsigned char D_80187194; +extern void func_8015795C(int param_1); +extern void func_80161D20(s32 a0, s32 a1); +extern void func_80157A8C(s32 a0); +extern void func_8016706C(s32 a0); +extern u8 D_800D51AC[]; +extern void func_80157AC8(s32 param_1); +extern void func_80157B74(int param_1); +extern void func_8016158C(void *a0); +extern void func_8015BE04(s32 *a0); +extern void func_80157BC8(s32 a0); +extern void func_80157CCC(s32 a0); +extern void func_80157DC4(void *a0); +extern void func_80157FC4(void *a0); +extern void func_80157D74(u16 *a0); +extern void (*D_801871E4[])(void); +extern void func_80157E38(void *); +extern void func_80157E00(void *a0); +extern void func_80157E38(void * a0); +extern s32 func_80157F64(s32 *a0); +extern s32 func_80156600(void *a0); +extern void func_80157EA4(void *a0); +extern void (*D_801871EC[])(void); +extern void func_80158038(void *); +extern void func_80158000(void *a0); +extern s32 D_800D51E0; +extern s32 D_801871B8; +extern void func_80158038(void * param); +extern u8 D_800D524C[]; +extern void func_80161418(void *a0); +extern void func_801580B4(s32 a0); +extern void func_801581AC(s32 a0); +extern void (*D_801871F8[])(void); +extern void func_8015824C(void *a0); +extern void func_801582C0(void *); +extern void func_80158288(void *a0); +extern u8 D_800D52A8[]; +extern void func_801585A4(s32 *a0); +extern void func_801582C0(void *a0); +extern s32 func_801585AC(s32 *a0); +extern u8 D_800D52E8[]; +extern void func_80158344(s32 *a0); +extern s32 func_801615C4(void *a0, s32 a1); +extern u8 D_801871C8; +extern u8 D_800D533C; +extern void func_80158434(s32 param_1); +extern void func_80158548(s32 param_1); +extern void func_801585EC(u8 *a0); +extern void func_80158794(void); +extern s32 D_8019E4C8; +extern s32 D_8019E4D4; +extern s32 D_8019E4D8; +extern void func_80158880(s32 *param); +extern void func_8015879C(s32 param_1); +extern void func_80158814(void *arg0); +extern void (*D_80187234[])(s32 *); +extern void func_80158AE4(void *a0); +extern void func_80158AB4(void *a0); +extern void func_8016F264(void); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80165A78(s32); +extern void func_80158AE4(void * a0); +extern M2C_UNK D_800D58D8; +extern void func_80158BB0(void *arg0); +extern s32 func_80159404(s32 a0, s32 a1); +extern void func_80158C40(s32 *a0); +extern void func_80158CD8(s32 *a0); +extern s32 func_80159434(s32 a0, s32 a1); +extern void func_80158D60(s32 a0); +extern M2C_UNK D_800D5904; +extern void func_80158E24(s32 *a0); +extern s32 D_80187208[]; +extern int rand(void); +extern s32 func_8013767C(s32 a0); +extern void func_80158F00(int param_1); +extern u8 D_80110C3C[]; +extern s32 func_801399F0(s32); +extern void func_80139914(s32); +extern s32 func_80159464(void); +extern void func_801594E8(s32, s32); +extern void func_80158FA4(s32 param_1); +extern s32 func_801399F0(s32 a0); +extern u8 D_80110C94[]; +extern u8 D_80110CD4[]; +extern void func_80159070(void *a0); +extern s32 func_80029A94(s32); +extern void func_80175454(void); +extern void func_800298BC(void *); +extern void func_8002992C(s32); +extern void func_800CF804(void); +extern void func_800CF818(void); +extern u8 D_80110D0C[]; +extern void func_80159120(s32 a0); +extern void func_801592CC(s32 *a0); +extern u8 D_800AE6BD; +extern s32 D_8019E4D0; +extern void func_8015934C(void *arg0); +extern void func_801593E4(A801593E4 *a0); +extern void (*D_80187484[])(void); +extern void func_80159698(void *a0); +extern s32 func_801596D4(void *a0); +extern void func_80174B6C(void); +extern void func_80129248(s16 a0); +extern void func_8013C938(void); +extern void func_8013CB20(void); +extern void func_8013C98C(void); +extern void func_8002850C(s32, s32, s32); +extern void func_80028620(s32, void *); +extern s16 D_800B9AAC[]; +extern s16 D_800B9B00; +extern u16 D_801270C0; +extern u32 D_800AFAE8[]; +extern char D_801872A4[]; +extern s32 func_801596F0(s32 param_1); +extern s32 func_80159874(void); +extern void func_800167B8(s32 a0); +extern s32 func_8015987C(s32 a0); +extern int func_800167F0(int arg); +extern int func_801598BC(void); +extern void func_80159968(void *a0); +extern void func_801598E0(u8 *a0); +extern void (*D_80187528[])(void); +extern void func_80159A20(void *a0); +extern void func_801599E0(void *a0); +extern void func_80159A18(void); +extern void func_80159BE4(s32); +extern void func_80159B08(s32 *a0); +extern void func_80159B70(void *a0); +extern void func_80159B3C(void * a0); +extern void (*D_8018767C[])(void); +extern void func_80159BAC(s32 a0); +extern s32 func_80172590(u8 *a0); +extern unsigned char D_80187498; +extern void func_80159BE4(s32 arg0); +extern void func_8015A1C8(s32 a0); +extern void func_8015A2D8(s32); +extern void func_8015A1FC(s32 *a0); +extern void func_8015A264(void *a0); +extern void func_8015A230(s32 *a0); +extern void (*D_80187684[])(void); +extern void func_8015A2A0(s32 a0); +extern int D_801874A8; +extern s32 func_80172608(u8 *a0); +extern void func_8015A2D8(s32 param_1); +extern u8 D_800D48DC; +extern s32 func_8015AB7C(s32 a0); +extern s32 D_8011F9C4; +extern s32 func_8015ABD4(s32 a0, s32 a1, s32 a2); +extern s32 func_80161CD0(s32 a0, s32 a1); +extern M2C_UNK D_801874C8; +extern void func_8015AC48(s32 arg0); +extern void func_8015AC90(s32 a0); +extern void func_8015ADB0(s32 a0); +extern void func_8015ACC4(s32 *arg0); +extern void func_8015AD3C(void *a0); +extern void func_8015AD08(void *arg0); +extern void (*D_8018768C[])(void); +extern void func_8015ADB0(s32); +extern void func_8015AD78(s32 a0); +extern void func_8015ADB0(s32 arg0); +extern s32 func_80161A60(s32 a0); +extern s32 func_801619A4(s32 *a0); +extern s32 func_80149C08(s32 a0); +extern s32 func_8015B6F4(s32 a0); +extern s32 func_8015B7B4(s32 a0); +extern void func_8015B8F8(s32 *a0); +extern void func_800CCCC0(s32 a0); +extern s32 func_8015B858(u8 *a0); +extern s32 func_800CF8B4(void); +extern void func_80147A84(s32 a0); +extern s32 func_80172644(u8 *a0); +extern void func_800CCB78(s32 a0); +extern s32 func_80161488(void *a0); +extern void func_8015CC40(s32 *a0); +extern void func_8015CF8C(s32 *a0); +extern s32 func_8015AE2C(); +extern s32 D_800D4A9C; +extern int func_8015B6F4(int param_1); +extern u8 D_800D4F8C[]; +extern u8 D_800D4BE0[]; +extern s32 func_8014A51C(void); +extern s32 D_800D4B48; +extern void func_8015BD8C(s32 *a0); +extern s32 func_8015BE94(); +extern void func_8015BE38(struct Obj *a0); +extern s32 func_8015BE74(void); +extern void func_80161124(void *a0); +extern s32 func_8015BE94(s32 *a0); +extern s32 func_8015BEC4(void); +extern s32 func_8015B950(void); +extern s32 func_8015BEE4(void); +extern void func_8015BF04(s32 *a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015BFF4(void *a0); +extern void func_8015BF7C(s32 *a0); +extern void func_8015C030(s32 *a0, s32 a1); +extern void func_8015BFB0(s32 *a0, s32 a1); +extern void (*D_801876B4[])(void); +extern void func_8015C0C4(s32); +extern void func_8015C08C(s32 a0); +extern s32 func_8015C128(s32 param_1); +/* ==== end §8b carried decl layer ==== */ + + + + +extern u16 D_800B99DA; + +extern s32 func_80149FB0(s32 a0); +extern s32 func_801496D4(void*); +extern void func_80149704(void); +extern s32 func_801619A4(s32*); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_801498E0(s32*); +extern s32 func_80149954(s32); +extern s32 func_80149A64(s32*); +extern void func_800CCCC0(s32 a0); +extern int func_80148AFC(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_8014C010(s32 a0, s32 a1); +extern void func_80147324(s32 a0); +extern void func_8014D738(void); +extern void func_8014CC28(s32); +extern void func_8014F3E8(s32); +extern s32 func_80146E98(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_80159BE4(s32 a0); +extern void func_8015C0C4(s32 a0); +extern void func_8015C6E0(s32*); + +void func_8015C32C(s32 arg0) { + + extern void (*D_80187534[])(void *); + s32 iVar2; + u32 uVar4; + s32 vin[4]; + s32 vout[4]; + + func_80149FB0(arg0); + if (((s32 (*)(s32))func_801496D4)(arg0) != 0) { + D_80187534[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149704)(arg0); + return; + } + switch (((s32 (*)(s32))func_801619A4)(arg0)) { + case 0: + case 1: + case 6: + if (((s32 (*)(s32))func_80149AA8)(arg0) != 0) { + D_80187534[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(s32))func_80149B54)(arg0) != 0) { + D_80187534[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_80149BAC)(arg0); + return; + } + break; + case 3: + ((void (*)(s32))func_801498E0)(arg0); + break; + case 4: + ((void (*)(s32))func_80149954)(arg0); + break; + case 5: + if (((s32 (*)(s32))func_80149A64)(arg0) != 0) { + D_80187534[*(u16 *)arg0]((void *)arg0); + func_800CCCC0(arg0); + return; + } + } + if ((func_80148AFC((void *)arg0) & 0xff) != 0) { + vin[0] = 0; + vin[1] = 0; + vin[2] = -0x4000; + func_8001382C((s32)*(s16 *)(*(s32 *)(arg0 + 0x20) + 0x12), vin, vout); + *(s32 *)(arg0 + 0x234) += vout[0]; + *(s32 *)(arg0 + 0x238) += vout[1]; + *(s32 *)(arg0 + 0x23c) += vout[2]; + } + func_8001382C((s16)-*(u16 *)(*(s32 *)(arg0 + 0x20) + 0x12), (void *)(arg0 + 0x234), vout); + func_80146DB8((s32 *)arg0, vout); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if ((D_800B99DA & 3) == 0) { + func_8014C010(arg0, 1); + func_80147324(0x65f); + } + if (((s32 (*)(s32))func_8014D738)(arg0) != 0) { + D_80187534[*(u16 *)arg0]((void *)arg0); + ((void (*)(s32))func_8015C6E0)(arg0); + return; + } + iVar2 = ((s32 (*)(s32))func_8014CC28)(arg0); + uVar4 = ((u32 (*)(s32))func_8014F3E8)(arg0); + if (uVar4 != 0) { + if ((uVar4 & 0x4000) == 0) { + if (func_80146E98(arg0) != 0) { + D_80187534[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 0); + func_80159BE4(arg0); + } + } else { + func_80147078((s32 *)arg0, 4); + func_8015C0C4(arg0); + } + } else { + if (iVar2 == 0) { + D_80187534[*(u16 *)arg0]((void *)arg0); + func_80147078((s32 *)arg0, 3); + ((void (*)(s32))func_8015BE94)(arg0); + } + } +} + + +DEFINE_func_8015C6A4() /* dedup: shared engine-core @0x8015C6A4 (src/shared) */ + +DEFINE_func_8015C6AC() /* dedup: shared engine-core @0x8015C6AC (src/shared) */ + +DEFINE_func_8015C6E0() /* dedup: shared engine-core @0x8015C6E0 (src/shared) */ + + +extern void (*D_801876C0[])(void); + +void func_8015C714(void *a0) { + D_801876C0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015C750() /* dedup: shared engine-core @0x8015C750 (src/shared) */ + +DEFINE_func_8015C788() /* dedup: shared engine-core @0x8015C788 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (match_one 88/88); fn-ptr-array dispatch, top-level if/else needed branch-polarity invert (small block falls through, big block at L854) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80149704(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); +extern void func_8014C010(s32 a0, s32 a1); + + +void func_8015C7E4(u16 *param_1) +{ + + extern void (*D_80187534[])(void*); + extern int D_801874D8; + s32 iVar1; + u32 uVar2; + + iVar1 = ((s32 (*)(u16 *))func_80161B18)(param_1); + if ((iVar1 == 0) && (iVar1 = ((s32 (*)(u16 *))func_80161B84)(param_1), iVar1 == 0)) { + iVar1 = ((s32 (*)(u16 *))func_801496D4)(param_1); + if (iVar1 != 0) { + ((void (**)(u16*))D_80187534)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + } else { + uVar2 = ((s32 (*)(u16 *))func_801487F4)(param_1); + if (((uVar2 & 0x80) == 0) && (iVar1 = ((s32 (*)(u16 *))func_801488A8)(param_1), iVar1 == 0)) { + ((void (**)(u16*))D_80187534)[*param_1](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + } else { + iVar1 = ((s32 (*)(u16 *))func_80161240)(param_1); + if (iVar1 == 0) { + iVar1 = ((s32 (*)(u16 *))func_80146E98)(param_1); + if (iVar1 != 0) { + ((void (*)(u16 *))func_80148AAC)(param_1); + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801874D8); + ((void (*)(u16 *, s32))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *))func_80146CA0)(param_1); + } + if ((param_1[0x5c] & 0x2000) != 0) { + ((void (*)(u16 *, s32))func_80161C24)(param_1, param_1[0xb7]); + ((void (*)(u16 *, s32))func_8014C010)(param_1, 2); + } + } + } + } + } + return; +} + + + + +// @class: struct +// @stuck: none — dispatch + control flow on a single callee-saved param; expect MATCH + +extern s32 func_80149FB0(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161240(void *a0); +extern s32 func_80146E98(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80161C24(s32, s32); + + +void func_8015C944(int param_1) { + + extern void (*D_80187534[])(); + func_80149FB0(param_1); + func_80147AD4(param_1, 0, 0, 0); + ((void (*)(int))func_801473EC)(param_1); + ((void (*)(int))func_8014D738)(param_1); + if (*(int *)(param_1 + 0x170) == 0) { + (*D_80187534[*(unsigned short *)param_1])(param_1); + ((void (*)(int, int))func_80147078)(param_1, 0); + ((void (*)(int))func_80159B70)(param_1); + } else { + if (((int (*)(int))func_80161240)(param_1) == 0) { + if (func_80146E98(param_1) != 0) { + ((void (*)(int))func_80146CA0)(param_1); + } + if ((*(unsigned short *)(param_1 + 0xb8) & 0x2000) != 0) { + func_80161C24(param_1, *(unsigned short *)(param_1 + 0x16e)); + } + } + } +} + + + +// @class: schedule +// @stuck: none — MATCH (goto forces the func_80161240 block to the function tail; bnez-to-end layout vs early-return fall-through) + + +extern s32 func_80149FB0(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_801496D4(void *a0); +extern u16 func_801487F4(s32 *a0); +extern s32 func_801488A8(u8 *a0); +extern void func_80148AAC(u8 *a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_80146E90(s32 *a0, s32 a1); +extern void func_80146C98(s32 *a0, s16 a1); +extern void func_80161240(void *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80149704(void); + + +void func_8015CA28(u16 *param_1) { + + extern void (*D_80187534[])(void*); + extern int D_801874D8; + ((void (*)(void))func_80149FB0)(); + if (((int (*)(u16 *))func_80161B18)(param_1) != 0) return; + if (((int (*)(u16 *))func_80161B84)(param_1) != 0) return; + if (((int (*)(u16 *))func_801496D4)(param_1) != 0) { + ((void (**)(u16*))D_80187534)[*param_1](param_1); + ((void (*)(u16 *))func_80149704)(param_1); + return; + } + if ((((u32 (*)(u16 *))func_801487F4)(param_1) & 0x80) != 0 || ((int (*)(u16 *))func_801488A8)(param_1) != 0) { + if ((((int (*)(u16 *))func_80148AAC)(param_1) & 0xff) != 0) { + ((void (*)(u16 *, int, int, int))func_80147AD4)(param_1, 0, 0, 0); + ((void (*)(u16 *))func_801473EC)(param_1); + } + if (((int (*)(u16 *))func_8014D738)(param_1) != 0) { + ((void (*)(u16 *, void *))func_80146DB8)(param_1, &D_801874D8); + ((void (*)(u16 *, int))func_80146E90)(param_1, 0x14); + ((void (*)(u16 *, int))func_80146C98)(param_1, 2); + } + if (*(int *)(param_1 + 0xb8) != 0) + goto do161240; + } + ((void (**)(u16*))D_80187534)[*param_1](param_1); + ((void (*)(u16 *, int))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; +do161240: + ((void (*)(u16 *))func_80161240)(param_1); +} + + +DEFINE_func_8015CB94() /* dedup: shared engine-core @0x8015CB94 (src/shared) */ + +DEFINE_func_8015CBCC() /* dedup: shared engine-core @0x8015CBCC (src/shared) */ + +DEFINE_func_8015CBD4() /* dedup: shared engine-core @0x8015CBD4 (src/shared) */ + +DEFINE_func_8015CBDC() /* dedup: shared engine-core @0x8015CBDC (src/shared) */ + +DEFINE_func_8015CBE4() /* dedup: shared engine-core @0x8015CBE4 (src/shared) */ + +DEFINE_func_8015CBEC() /* dedup: shared engine-core @0x8015CBEC (src/shared) */ + +DEFINE_func_8015CBF4() /* dedup: shared engine-core @0x8015CBF4 (src/shared) */ + +DEFINE_func_8015CBFC() /* dedup: shared engine-core @0x8015CBFC (src/shared) */ + +DEFINE_func_8015CC04() /* dedup: shared engine-core @0x8015CC04 (src/shared) */ + +DEFINE_func_8015CC0C() /* dedup: shared engine-core @0x8015CC0C (src/shared) */ + +DEFINE_func_8015CC40() /* dedup: shared engine-core @0x8015CC40 (src/shared) */ + + + +void func_8015CC74(s32 *a0) { + + extern void (*D_801876D0[])(void); + D_801876D0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CCB0() /* dedup: shared engine-core @0x8015CCB0 (src/shared) */ + +DEFINE_func_8015CCD0() /* dedup: shared engine-core @0x8015CCD0 (src/shared) */ + +#define NULL 0 + +struct Sub_8015CD20 { + u8 pad0[0x12]; + u16 unk12; /* +0x12 */ +}; + +struct Ent_8015CD20 { + u16 unk0; /* +0x00 */ + u8 pad2[0x1E]; + struct Sub_8015CD20 *unk20; /* +0x20 */ + u8 pad24[0x94]; + s16 unkB8; /* +0xB8 */ + u8 pad1BA[0x102]; + s8 unk1BC; /* +0x1BC */ + u8 pad1BD[0x77]; + s32 unk234; /* +0x234 */ +}; + + + +s32 func_8015CD20(s32 arg0) { + extern void (*D_80187534[])(struct Ent_8015CD20 *); + extern u8 D_801874E8; + extern u8 D_801876D8; + extern u8 D_801876E8; + + s32 temp_v0; + s32 var_v0; + struct Sub_8015CD20 *sp; + + ((void(*)())func_80149FB0)(); + if (((s32(*)(struct Ent_8015CD20 *))func_801496D4)(((struct Ent_8015CD20 *)arg0)) != 0) { + D_80187534[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((struct Ent_8015CD20 *)arg0)->unk1BC = 0xA; + ((s32(*)(struct Ent_8015CD20 *))func_80149724)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_80148AFC)(((struct Ent_8015CD20 *)arg0)) & 0xFF) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801874E8); + } else { + ((void(*)(struct Ent_8015CD20 *))func_80146D90)(((struct Ent_8015CD20 *)arg0)); + } + return; + } + temp_v0 = ((struct Ent_8015CD20 *)arg0)->unk234; + if (temp_v0 == 0) { + if (((s32(*)(struct Ent_8015CD20 *))func_80148980)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801876D8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x15); + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0xAA; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_8014891C)(((struct Ent_8015CD20 *)arg0)) != 0) { + ((void(*)(struct Ent_8015CD20 *, u8 *))func_80146DB8)(((struct Ent_8015CD20 *)arg0), &D_801876E8); + ((void(*)(struct Ent_8015CD20 *))func_80147A84)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *))func_801473EC)(((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80154150)(((struct Ent_8015CD20 *)arg0), 0x14); + ((struct Ent_8015CD20 *)arg0)->unkB8 = 1; + } + if (((s32(*)(struct Ent_8015CD20 *))func_801489E8)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 + 0x71; + goto block_13; + } + if (((s32(*)(struct Ent_8015CD20 *))func_80148A48)(((struct Ent_8015CD20 *)arg0)) != 0) { + sp = ((struct Ent_8015CD20 *)arg0)->unk20; + var_v0 = sp->unk12 - 0x71; +block_13: + sp->unk12 = var_v0 & 0xFFF; + } + } else { + ((struct Ent_8015CD20 *)arg0)->unk234 = temp_v0 - 1; + } + ((void(*)(struct Ent_8015CD20 *))func_8014FA04)(((struct Ent_8015CD20 *)arg0)); + if (((s32(*)(struct Ent_8015CD20 *))func_8014E434)(((struct Ent_8015CD20 *)arg0)) == 0) { + D_80187534[((struct Ent_8015CD20 *)arg0)->unk0](((struct Ent_8015CD20 *)arg0)); + ((void(*)(struct Ent_8015CD20 *, s32))func_80147078)(((struct Ent_8015CD20 *)arg0), 0); + ((void(*)(struct Ent_8015CD20 *))func_80159B70)(((struct Ent_8015CD20 *)arg0)); + } else { + ((void(*)(struct Ent_8015CD20 *))func_801725E0)(((struct Ent_8015CD20 *)arg0)); + } +} + + + +DEFINE_func_8015CF24() /* dedup: shared engine-core @0x8015CF24 (src/shared) */ + +DEFINE_func_8015CF58() /* dedup: shared engine-core @0x8015CF58 (src/shared) */ + +DEFINE_func_8015CF8C() /* dedup: shared engine-core @0x8015CF8C (src/shared) */ + + + +void func_8015CFC0(s32 *a0) { + + extern void (*D_80187708[])(void); + D_80187708[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015CFFC() /* dedup: shared engine-core @0x8015CFFC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (uVar1 pinned $s3, uVar5 pinned $s1; param_1->s2, iVar4->s0 fall out) + + +void func_8015D01C(int param_1) { + extern s32 func_801725F4(u8 *a0); + extern int D_800D550C; + extern int D_801876F8; + + int iVar4; + register unsigned short uVar1 __asm__("$19"); + register unsigned short uVar5 __asm__("$17"); + short sVar2; + short sVar3; + + ((void (*)(int, void *))func_80154274)(param_1, &D_800D550C); + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + iVar4 = *(short *)(*(int *)(param_1 + 0x20) + 0x12); + uVar1 = *(unsigned short *)(*(int *)(*(int *)(param_1 + 0x180) + 0x20) + 0x12); + uVar5 = (uVar1 + 0x800) & 0xfff; + sVar2 = func_80012A60(iVar4, (short)uVar1); + sVar3 = func_80012A60(iVar4, uVar5); + if (sVar2 < sVar3) { + *(short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar1; + } else { + *(unsigned short *)(*(int *)(param_1 + 0x20) + 0x12) = uVar5; + } + *(int *)(param_1 + 0x38) = (int)&D_801876F8 | 0x40000000; + ((void (*)(int))func_801725F4)(param_1); + ((void (*)(int))func_80146CA0)(param_1); +} + + + + + +// @class: struct +// @stuck: none — MATCH (pending gate) + +extern s32 func_80149FB0(s32 a0); +extern void func_8014FA04(s32 a0); +extern void func_8014E6A0(void); +extern void (*D_80187534[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_801725F4(u8 *a0); +extern void func_80146CA0(void *a0); + +void func_8015D104(void *arg0) { + ((void (*)(void))func_80149FB0)(); + ((void (*)(void *))func_8014FA04)(arg0); + if (((s32 (*)(void *))func_8014E6A0)(arg0) == 0) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + ((void (*)(void *))func_801725F4)(arg0); + *(s32 *)((u8 *)arg0 + 0x234) = 0xFF1D0000; + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10) = 0x600; + *(u16 *)((u8 *)arg0 + 0x244) = *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x10); + func_80146CA0(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_8015D1B8); + + +// @class: regalloc-order +// @stuck: pinning a0->$s1 and buffer-ptr->$s0; body copy already matches +extern void func_80013F3C(s32 a0); +extern void func_80012558(s32 a0, s32 a1); +extern void func_800126C4(s32 a0, s32 a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern void *memcpy(void *dst, const void *src, u32 n); + +extern s32 D_80187764; + +void func_8015D380(s32 a0) { + s16 out[4]; + s32 buf[8]; + register s32 s1 __asm__("$17") = a0; + register s32 *s0 __asm__("$16") = buf; + ((void (*)(void *))func_80013F3C)((void *)s0); + ((void (*)(void *, s32))func_80012558)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12)); + ((void (*)(void *, s32))func_800126C4)((void *)s0, *(s16 *)(*(s32 *)(s1 + 0x20) + 0x10)); + ApplyMatrixSV((void *)s0, (void *)&D_80187764, (void *)out); + memcpy((void *)(s1 + 0x138), (void *)out, 8); +} + + + + +// @class: plumbing +// @stuck: none — MATCH + +extern unsigned char D_80186848[]; + +extern void func_801553C0(s32 a0); +extern void func_80154A74(s32 a0, s32 a1); + +void func_8015D414(int param_1) +{ + *(unsigned char *)(param_1 + 0x1bd) = 8; + *(unsigned char **)(param_1 + 0x38) = D_80186848; + *(short *)(param_1 + 0x138) = 0; + *(short *)(param_1 + 0x13a) = 0; + *(short *)(param_1 + 0x13c) = 0; + *(short *)(param_1 + 0x13e) = 0; + *(short *)(param_1 + 0xA) = *(short *)(param_1 + 0xA) + 0x48; + *(short *)(*(int *)(param_1 + 0x20) + 0x10) = 0; + ((void (*)(void))func_801553C0)(); + func_80154A74(param_1, 0x11); +} + + +DEFINE_func_8015D480() /* dedup: shared engine-core @0x8015D480 (src/shared) */ + +DEFINE_func_8015D4B4() /* dedup: shared engine-core @0x8015D4B4 (src/shared) */ + + + +s32 func_8015D4E8(s16 *a0) { + + extern void (*D_8018776C[])(void); + D_8018776C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015D524() /* dedup: shared engine-core @0x8015D524 (src/shared) */ + +DEFINE_func_8015D544() /* dedup: shared engine-core @0x8015D544 (src/shared) */ + +DEFINE_func_8015D57C() /* dedup: shared engine-core @0x8015D57C (src/shared) */ + + +// @class: loose-typing +// @stuck: none — MATCH (field 0xb8 compared as u16 == 0x8000, not s16 == -0x8000) + +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern void func_80154A74(int, int); +extern s32 func_80161208(); +extern void func_80154150(int, int); +extern void func_80146CA0(void *a0); +extern void func_80149374(int, int); + +extern unsigned char D_80187778[]; + +void func_8015D5E8(int param_1) +{ + int iVar1; + int iVar2; + + if (((int (*)(void))func_80161B18)() != 0) + return; + if (((int (*)(int))func_80161B84)(param_1) != 0) + return; + if ((*(unsigned short *)(param_1 + 0xb8) & 0x4000) != 0) + func_80154A74(param_1, 0x17); + if (((int (*)(int))func_80161208)(param_1) != 0) + return; + if (*(unsigned short *)(param_1 + 0xb8) == 0x8000) { + *(int *)(param_1 + 0x234) = *(int *)(param_1 + 0x234) + -3; + func_80154150(param_1, 0x1a); + ((void (*)(int))func_80146CA0)(param_1); + } else { + iVar1 = *(int *)(param_1 + 0x178); + if (iVar1 != 0) { + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 6) = + (short)((signed char)D_80187778[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xc)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 10) = + (short)((signed char)D_80187778[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0xe)); + iVar2 = *(int *)(param_1 + 0x234); + *(int *)(param_1 + 0x234) = iVar2 + 1; + *(short *)(iVar1 + 0xe) = + (short)((signed char)D_80187778[iVar2] + + *(unsigned short *)(*(int *)(iVar1 + 0x78) + 0x10)); + func_80149374(param_1, iVar1 + 4); + } + } +} + + + +extern int func_80148AFC(void*); +extern s32 func_80161B18(void *); +extern s32 func_80161B84(void *); +extern u16 func_80148800(s32*); +extern u8 func_8014BEF8(void); +extern s32 func_80165624(s32); +extern s32 func_801488A8(u8*); +extern void func_8014D738(void); +extern s32 func_80161208(); +extern void func_80154A74(s32, s32); +extern void func_8015DAC4(s32*); +extern void func_8015DE24(s32*); +extern void func_8015DA5C(s32); +extern void func_8015F948(s32*); +extern void func_800CAF14(void *); +extern void func_80154150(s32, s32); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80149374(s32, s32); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *); +extern void func_8015C714(void *); +extern void func_801483E8(void); + +extern void (*D_80187534[])(void *); +extern u8 D_80078E78[]; +extern u8 D_80187778[]; + +void func_8015D738(void *arg0) { + + extern u8 D_801874F8[]; + extern u8 D_80187508[]; + u8 *p = D_80078E78; + s32 s1; + ((void (*)(void))func_80148AFC)(); + if (func_80161B18(arg0) != 0) return; + if (func_80161B84(arg0) != 0) return; + s1 = *(s32 *)((char *)arg0 + 0x178); + if (s1 != 0) { + if (*(u16 *)s1 == 0x360) goto block_808; + } + __asm__ __volatile__(""); + if (s1 != 0) { + if (*(u16 *)s1 != 0) goto block_7F4; + } + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +block_7F4: + if (((s32 (*)(void *))func_80148800)(arg0) & 0x80) { + block_808: + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DAC4)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x10) && ((s32 (*)(void *))func_8014BEF8)(arg0) != 0) { + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + ((void (*)(void *))func_8015DE24)(arg0); + return; + } + if ((((s32 (*)(void *))func_80148800)(arg0) & 0x20) && p[0x49] == 0xA) { + if (((s32 (*)(void *))func_80165624)(arg0) != 0) { + ((void (*)(void *))func_8015DA5C)(arg0); + ((void (*)(void *))func_8015F948)(arg0); + return; + } + ((void (*)(void *, s32))func_80154A74)(arg0, 0x11); + func_800CAF14(arg0); + return; + } + if (((s32 (*)(void *))func_801488A8)(arg0) != 0 && *(u16 *)(*(s32 *)((char *)arg0 + 0x178)) != 0x82) { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1B); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_801874F8); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1A); + ((void (*)(void *, void *))func_80146DB8)(arg0, &D_80187508); + } + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + s1 = *(s32 *)((char *)arg0 + 0x178); + *(s16 *)(s1 + 6) = (s16)((s8)D_80187778[*(s32 *)((char *)arg0 + 0x234)] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xc)); + *(s16 *)(s1 + 0xa) = (s16)((s8)D_80187778[*(s32 *)((char *)arg0 + 0x234) + 1] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0xe)); + *(s16 *)(s1 + 0xe) = (s16)((s8)D_80187778[*(s32 *)((char *)arg0 + 0x234) + 2] + *(u16 *)(*(s32 *)(s1 + 0x78) + 0x10)); + ((void (*)(void *, void *))func_80149374)(arg0, (void *)(s1 + 4)); + *(s16 *)(*(s32 *)(s1 + 0x20) + 0x12) = (*(u16 *)(*(s32 *)((char *)arg0 + 0x20) + 0x12) + 0x800) & 0xFFF; + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (func_80161208(arg0) != 0) return; + ((void (*)(void *))func_801483E8)(arg0); +} + + +DEFINE_func_8015DA5C() /* dedup: shared engine-core @0x8015DA5C (src/shared) */ + +DEFINE_func_8015DA90() /* dedup: shared engine-core @0x8015DA90 (src/shared) */ + +DEFINE_func_8015DAC4() /* dedup: shared engine-core @0x8015DAC4 (src/shared) */ + + + +void func_8015DAF8(s32 *a0) { + + extern void (*D_801877AC[])(void); + D_801877AC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DB34() /* dedup: shared engine-core @0x8015DB34 (src/shared) */ + +DEFINE_func_8015DB6C() /* dedup: shared engine-core @0x8015DB6C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187534[])(void *); +extern int func_8015DD74(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015DCB8(s32 a0); + +void func_8015DBD4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015DD74)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015DCB8)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DC84() /* dedup: shared engine-core @0x8015DC84 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801877B4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015DCB8(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015DD74() /* dedup: shared engine-core @0x8015DD74 (src/shared) */ + +DEFINE_func_8015DDF0() /* dedup: shared engine-core @0x8015DDF0 (src/shared) */ + +DEFINE_func_8015DE24() /* dedup: shared engine-core @0x8015DE24 (src/shared) */ + + + +void func_8015DE58(s32 *a0) { + + extern void (*D_801877CC[])(void); + D_801877CC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015DE94() /* dedup: shared engine-core @0x8015DE94 (src/shared) */ + +DEFINE_func_8015DECC() /* dedup: shared engine-core @0x8015DECC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015F89C/func_8015F9A4 in same overlay) + +extern void (*D_80187534[])(void *); +extern int func_8015E0D4(int); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); +extern void func_8015E018(s32 a0); + +void func_8015DF34(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x4000) { + ((void (*)(void))func_8015E0D4)(); + } + if (*(u16 *)((u8 *)arg0 + 0xB8) == 0x8000) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x178) != 0) { + ((void (*)(void *))func_8015E018)(arg0); + } + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015DFE4() /* dedup: shared engine-core @0x8015DFE4 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (proxy gate) + +extern s8 D_801877B4[]; +extern void func_80149374(s32 a0, s32 a1); + +void func_8015E018(s32 param_1) { + s32 iVar1; + s32 iVar2; + + iVar2 = *(s32 *)(param_1 + 0x178); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 6) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xc); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 10) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0xe); + + iVar1 = *(s32 *)(param_1 + 0x234); + *(s32 *)(param_1 + 0x234) = iVar1 + 1; + *(s16 *)(iVar2 + 0xe) = (s16)D_801877B4[iVar1] + *(s16 *)(*(s32 *)(iVar2 + 0x78) + 0x10); + + func_80149374(param_1, iVar2 + 4); +} + + +DEFINE_func_8015E0D4() /* dedup: shared engine-core @0x8015E0D4 (src/shared) */ + +DEFINE_func_8015E150() /* dedup: shared engine-core @0x8015E150 (src/shared) */ + +DEFINE_func_8015E184() /* dedup: shared engine-core @0x8015E184 (src/shared) */ + + + +s32 func_8015E1B8(s32 a0) { + + extern void (*D_801877EC[])(void); + D_801877EC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E1F4() /* dedup: shared engine-core @0x8015E1F4 (src/shared) */ + +DEFINE_func_8015E22C() /* dedup: shared engine-core @0x8015E22C (src/shared) */ + +DEFINE_func_8015E288() /* dedup: shared engine-core @0x8015E288 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); fn-ptr table folds %lo via extern array, 0x234 single word store + + +extern void func_8015E40C(s32 a0); +extern s32 func_80161B18(void *a0); +extern s32 func_80161B84(void *a0); +extern s32 func_80161208(); +extern void func_8015E5B0(u8*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +extern void (*D_80187534[])(void*); + +void func_8015E344(u16 *param_1) +{ + ((s32 (*)(void))func_8015E40C)(); + if (((s32 (*)(u16 *))func_80161B18)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161B84)(param_1) == 0 && + ((s32 (*)(u16 *))func_80161208)(param_1) == 0) { + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *))func_8015E5B0)(param_1); + *(s32 *)((char *)param_1 + 0x234) = 1; + } + if ((param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187534)[param_1[0]](param_1); + ((s32 (*)(u16 *, s32))func_80147078)(param_1, 0); + ((s32 (*)(u16 *))func_80159BE4)(param_1); + } + } +} + + +DEFINE_func_8015E40C() /* dedup: shared engine-core @0x8015E40C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (pending whole-binary gate); s16 v[3] array forces all 3 locals addressable (reload-from-stack), u16* psVar1 → lhu null/flag check + + +extern u16 D_801877FC; +extern u16 D_801877FE; +extern u16 D_80187800; +extern s32 D_80187804; + +extern void func_80149350(s32 arg0); +extern void func_80013E94(void *a0, void *a1); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); + +void func_8015E4B0(s32 param_1) +{ + u16 *psVar1; + s16 v[3]; + s32 local_10; + + psVar1 = *(u16 **)(param_1 + 0x18c); + if ((psVar1 != (u16 *)0) && (*psVar1 != 0)) { + v[0] = D_801877FC + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0xc); + v[1] = D_801877FE + *(s16 *)(*(s32 *)(psVar1 + 0x3c) + 0xe) * 2; + v[2] = D_80187800 + *(u16 *)(*(s32 *)(psVar1 + 0x3c) + 0x10); + ((s32 (*)(s32, s16 *, s16 *))func_80149350)(param_1, &v[0], &v[0]); + ((s32 (*)(s32 *, s32 *))func_80013E94)(&D_80187804, &local_10); + ((s32 (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x1f, param_1, v[0], v[1], v[2], local_10, 0); + } + return; +} + + + + +extern void func_8013C9C4(void *a0); +extern s32 D_8018780C; + +void func_8015E588(void) { + func_8013C9C4(&D_8018780C); +} + + +DEFINE_func_8015E5B0() /* dedup: shared engine-core @0x8015E5B0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (clean -O2 reconstruction; table-of-fnptr indexed by param_1[0]) + + +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159BE4(s32 arg0); + +/* function-pointer dispatch table */ +extern void (*D_80187534[])(void*); + +void func_8015E698(u16 *param_1) +{ + if (func_80161208() == 0 && (param_1[0x5c] & 0x8000) != 0) { + ((void (**)(u16*))D_80187534)[param_1[0]](param_1); + ((void (*)(u16 *, s32))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159BE4)(param_1); + } +} + + +DEFINE_func_8015E714() /* dedup: shared engine-core @0x8015E714 (src/shared) */ + +DEFINE_func_8015E84C() /* dedup: shared engine-core @0x8015E84C (src/shared) */ + +DEFINE_func_8015E880() /* dedup: shared engine-core @0x8015E880 (src/shared) */ + +DEFINE_func_8015E8B4() /* dedup: shared engine-core @0x8015E8B4 (src/shared) */ + + + +void func_8015E8E8(s32 *a0) { + + extern void (*D_80187820[])(void); + D_80187820[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015E924() /* dedup: shared engine-core @0x8015E924 (src/shared) */ + +DEFINE_func_8015E95C() /* dedup: shared engine-core @0x8015E95C (src/shared) */ + +DEFINE_func_8015E9B8() /* dedup: shared engine-core @0x8015E9B8 (src/shared) */ + + +extern u16 func_801487F4(s32*); +extern void func_80147078(s32*, s16); +extern void func_80159B70(void *a0); +extern s32 func_80149D10(s32); +extern void func_80175150(void *a0); +extern void func_8016EE40(s32 a0, s32 a1); +extern s32 func_80149744(struct S_80149744*); +extern void func_80149788(void); +extern s32 func_80161B84(void *a0); +extern s32 func_8014A4B4(void *a0); +extern void func_8014A4FC(void); +extern s32 func_80149AA8(s32*); +extern void func_80149AD4(s32*); +extern s32 func_80149B54(s32*); +extern void func_80149BAC(s32*); +extern s32 func_800CF8B4(void); +extern s32 func_801491C4(s32); +extern s32 func_80148E54(void *a0); +extern void func_8001382C(s32 a0, void *a1, void *a2); +extern void func_80146DB8(s32*, s32*); +extern void func_80147A84(s32); +extern void func_801473EC(s32*); +extern void func_80154150(s32, s32); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); /* canonical no-proto (§17a-1) */ +extern void func_801483E8(void); + +extern void (*D_80187534[])(void *); + +void func_8015EA3C(void *arg0) { + + extern s16 D_801152A0; + s32 invec[4]; + s32 outbuf[4]; + s32 temp; + s32 r; + + if (!(((s32 (*)(void))func_801487F4)() & 8)) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; + } + r = ((s32 (*)(void *))func_80149D10)(arg0); + if (r == 1) goto Lcase1; + if (r < 2) goto Ldefault; + if (r == 2) goto Lcase2; + goto Ldefault; +Lcase1: + D_80187534[*(u16 *)arg0](arg0); + func_80175150(arg0); + return; +Lcase2: + func_8016EE40(*(s32 *)((u8 *)arg0 + 0x21C), 0x01000000); + return; +Ldefault: + if (((s32 (*)(void *))func_80149744)(arg0) != 0) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149788)(arg0); + return; + } + if (func_80161B84(arg0) != 0) { + return; + } + if (func_8014A4B4(arg0) != 0) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *))func_8014A4FC)(arg0); + return; + } + if (((s32 (*)(void *))func_80149AA8)(arg0) != 0) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149AD4)(arg0); + return; + } + if (((s32 (*)(void *))func_80149B54)(arg0) != 0) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *))func_80149BAC)(arg0); + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + ((s32 (*)(void *))func_801491C4)(arg0)) & 0xFFF; + } + temp = func_80148E54(arg0); + if ((s16)temp >= 0) { + s32 d = temp - *(u16 *)(*(s32 *)((u8 *)arg0 + 0x20) + 0x12); + invec[0] = 0; + invec[1] = 0; + invec[2] = 0xFFFC0000; + func_8001382C((s16)d, invec, outbuf); + ((void (*)(void *, void *))func_80146DB8)(arg0, outbuf); + ((void (*)(void *))func_80147A84)(arg0); + ((void (*)(void *))func_801473EC)(arg0); + ((void (*)(void *, s32))func_80154150)(arg0, 0x1E); + } else { + ((void (*)(void *, s32))func_80154150)(arg0, 0x1D); + } + if (((s32 (*)(void *))func_8014D738)(arg0) != 0) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 9); + func_8015C714(arg0); + return; + } + if (((s32 (*)(s32))func_80161208)(arg0) == 0) { /* §17a-1 */ + ((void (*)(void *))func_801483E8)(arg0); + } +} + + +DEFINE_func_8015ED6C() /* dedup: shared engine-core @0x8015ED6C (src/shared) */ + +DEFINE_func_8015EDA0() /* dedup: shared engine-core @0x8015EDA0 (src/shared) */ + +DEFINE_func_8015EDD4() /* dedup: shared engine-core @0x8015EDD4 (src/shared) */ + + + +s32 func_8015EE08(s32 a0) { + + extern void (*D_80187828[])(void); + D_80187828[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015EE44() /* dedup: shared engine-core @0x8015EE44 (src/shared) */ + + +// @class: plumbing +// @stuck: none — MATCH (straight STUB call sequence; param saved to $s0 across calls) + +extern void func_8014CBF8(void *a0); +extern void func_801474EC(s32 *a0); +extern void func_80154274(s32 *a0, s32 a1); +extern void func_80146DB8(s32 *a0, s32 *a1); +extern void func_801477E8(s32 *a0, s32 a1); +extern void func_80146CA0(void *a0); + +extern int D_800D4C48; +extern int D_80187518; + +void func_8015EE7C(s32 param_1) +{ + ((int (*)(void))func_8014CBF8)(); + ((int (*)(int))func_801474EC)(param_1); + ((int (*)(int, void *))func_80154274)(param_1, &D_800D4C48); + ((int (*)(int, void *))func_80146DB8)(param_1, &D_80187518); + ((int (*)(int, int))func_801477E8)(param_1, 0xFFF40000); + ((int (*)(int))func_80146CA0)(param_1); +} + + + +extern void (*D_80187534[])(void *); + +extern void func_80148038(s32 a0, s32 a1); +extern void func_80147460(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80161418(void *a0); +extern s32 func_801725A4(u8 *a0); + +void func_8015EEE0(void *arg0) +{ + ((void (*)(void *, s32))func_80148038)(arg0, 0x10000); + ((void (*)(void *))func_80147460)(arg0); + ((void (*)(void *, s32, s32, s32))func_80147AD4)(arg0, 0, 0, 0x1000); + ((void (*)(void *))func_801473EC)(arg0); + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s32))func_80147078)(arg0, 0); + func_80159B70(arg0); + } else { + if (((s32 (*)(void *))func_80161418)(arg0) == 0) { + ((void (*)(void *))func_801725A4)(arg0); + } + } +} + + +DEFINE_func_8015EF9C() /* dedup: shared engine-core @0x8015EF9C (src/shared) */ + +DEFINE_func_8015EFA4() /* dedup: shared engine-core @0x8015EFA4 (src/shared) */ + +DEFINE_func_8015EFD8() /* dedup: shared engine-core @0x8015EFD8 (src/shared) */ + + + +void func_8015F00C(s32 *a0) { + + extern void (*D_80187830[])(void); + D_80187830[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F048() /* dedup: shared engine-core @0x8015F048 (src/shared) */ + +DEFINE_func_8015F080() /* dedup: shared engine-core @0x8015F080 (src/shared) */ + +extern s32 D_80062BE8; +extern void (*D_80187534[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8014AB5C(void); +extern void func_80159B70(void *a0); +extern void func_80019064(void *a0); +extern void func_80147324(s32 a0); +extern s32 func_80161208(void); +extern int func_80155FF8(int arg, int a1); + +void func_8015F118(void *a0) { + u16 flag; + + *(s32 *)((u8 *)a0 + 0x44) = *(s32 *)((u8 *)a0 + 0x44) | 2; + flag = *(u16 *)((u8 *)a0 + 0xB8); + if (flag == 0x8000) { + (*D_80187534[*(u16 *)a0])(a0); + ((void (*)(void *, s32))func_80147078)(a0, 0); + func_80159B70(a0); + } else { + if (flag & 0x4000) { + ((void (*)(s32))func_8014AB5C)(0x19); + ((void (*)(s32))func_8014AB5C)(0x1D); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 0, 0, 1); + func_801466F0(0x19, (s32)a0, 0, 0, 0, 1, 0, 1); + func_801466F0(0x1D, (s32)a0, 0, 0, 0, 0, 0, 1); + func_80019064(&D_80062BE8); + func_80147324(0x9DA); + } + if (((s32 (*)(s32 *))func_80161208)(a0) == 0) { + func_80155FF8((int)a0, *(u8 *)((u8 *)a0 + 0x1AA)); + } + } +} + + +DEFINE_func_8015F260() /* dedup: shared engine-core @0x8015F260 (src/shared) */ + +DEFINE_func_8015F2BC() /* dedup: shared engine-core @0x8015F2BC (src/shared) */ + +DEFINE_func_8015F2F0() /* dedup: shared engine-core @0x8015F2F0 (src/shared) */ + + + +void func_8015F324(s32 *a0) { + + extern void (*D_80187838[])(void); + D_80187838[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F360() /* dedup: shared engine-core @0x8015F360 (src/shared) */ + +DEFINE_func_8015F380() /* dedup: shared engine-core @0x8015F380 (src/shared) */ + + +extern void (*D_80187534[])(void *); + +extern s32 func_80149884(void); +extern s32 func_801496D4(void*); +extern void func_80149724(void); +extern void func_801477E8(s32*, s32); +extern u16 func_80148800(s32*); +extern s32 func_80148980(u8*); +extern void func_8014F1F4(void); +extern void func_8014FCFC(void); +extern s32 func_80146A6C(s32, void*, s32, s32, s32, s32, s32); +extern void func_80147A84(s32 a0); +extern void func_801473EC(s32*); +extern void func_80146DB8(s32*, s32*); +extern void func_80146E90(s32*, s32); +extern void func_8014ED28(s32 a0); +extern void func_8014FA04(s32 a0); +extern s32 func_801725B8(u8*); +extern void func_80147324(s32 a0); +extern void func_80019064(void*); +extern void func_801484B0(s32, s32); +extern void func_80148534(s32, s32); + +void func_8015F448(s32 arg0) { + + extern u8 D_80062BD0; + extern s32 D_80187840; + extern s32 D_80187850; + extern s32 D_80187860; + s32 sp20[2]; + s32 sp28[2]; + + if (((*(u32 *)(arg0 + 0x44) & 0x100) && (func_80149884() != 0)) || + (((s32 (*)(s32))func_801496D4)(arg0) != 0)) { + D_80187534[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0); + return; + } + + if (*(u8 *)(arg0 + 0x245) == 0) { + if (*(u8 *)(arg0 + 0x244) == 0) { + if (((s32 (*)(s32))func_80148800)(arg0) & 0x10) { + *(u8 *)(arg0 + 0x244) = 1; + *(u8 *)(arg0 + 0x245) = 1; + } + } else if (((s32 (*)(s32))func_80148800)(arg0) & 0x80) { + *(u8 *)(arg0 + 0x244) = 0; + *(u8 *)(arg0 + 0x245) = 1; + } + } + + if (*(u16 *)(arg0 + 0xB8) & 0x3000) { + if (*(u16 *)(arg0 + 0xB8) & 0x2000) { + ((void (*)(void *, void *))func_801484B0)(sp20, sp28); + func_80147324(0x56D); + } else { + ((void (*)(void *, void *))func_80148534)(sp20, sp28); + func_80147324(0x56E); + } + ((void (*)(s32 *))func_80019064)(&(*(s32 *)&D_80062BD0)); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 0, 0); + ((void (*)(s32, s32, s32, s32, s32, s32, s32))func_80146A6C)(0x25, arg0, *(s16 *)(arg0 + 6), + (s16)(*(u16 *)(arg0 + 0xA) - 0x14), + *(s16 *)(arg0 + 0xE), 1, 0); + } + + if (*(u16 *)(arg0 + 0xB8) & 0x8000) { + if (*(u8 *)(arg0 + 0x245) != 0) { + *(u8 *)(arg0 + 0x245) = 0; + *(u16 *)(arg0 + 0xB8) = *(u16 *)(arg0 + 0xBA); + if (((s32 (*)(s32))func_80148980)(arg0) != 0) { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187840); + } else { + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187850); + } + } + } else { + *(u16 *)(arg0 + 0x246) = *(u16 *)(arg0 + 6); + *(u16 *)(arg0 + 0x248) = *(u16 *)(arg0 + 0xA); + *(u16 *)(arg0 + 0x24A) = *(u16 *)(arg0 + 0xE); + func_80147A84(arg0); + ((void (*)(s32))func_801473EC)(arg0); + if (((s32 (*)(s32))func_8014F1F4)(arg0) != 0) { + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 0x246); + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0x248); + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0x24A); + } + } + + if (((s32 (*)(s32))func_8014FCFC)(arg0) == 0) { + D_80187534[*(u16 *)arg0]((void *)arg0); + *(u8 *)(arg0 + 0x1BE) = 0xA; + ((void (*)(s32))func_80149724)(arg0); + ((void (*)(s32, s32))func_801477E8)(arg0, 0xFFE80000); + ((void (*)(s32, s32 *))func_80146DB8)(arg0, &D_80187860); + ((void (*)(s32, s32))func_80146E90)(arg0, 0x10); + return; + } + + func_8014ED28(arg0); + func_8014FA04(arg0); + ((void (*)(s32))func_801725B8)(arg0); +} + + +DEFINE_func_8015F738() /* dedup: shared engine-core @0x8015F738 (src/shared) */ + +DEFINE_func_8015F76C() /* dedup: shared engine-core @0x8015F76C (src/shared) */ + +DEFINE_func_8015F7A0() /* dedup: shared engine-core @0x8015F7A0 (src/shared) */ + + + +s32 func_8015F7D4(s32 a0) { + + extern void (*D_80187870[])(void); + D_80187870[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8015F810() /* dedup: shared engine-core @0x8015F810 (src/shared) */ + +DEFINE_func_8015F848() /* dedup: shared engine-core @0x8015F848 (src/shared) */ + + +extern void (*D_80187534[])(void *); +extern void func_801466F0(s32, s32, s32, s32, s32, s32, s32, s32); +extern void func_80147078(s32 *, s16); +extern void func_80159B70(void *); +extern s32 func_80161208(void); + +void func_8015F89C(void *arg0) { + u16 flags = *(u16 *)((u8 *)arg0 + 0xB8); + if (!(flags & 0x4000)) { + if (flags & 0x8000) { + D_80187534[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + return; + } + } else { + func_801466F0(1, arg0, 0, -0x1E, 0, 0, 0, 0); + } + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_8015F948() /* dedup: shared engine-core @0x8015F948 (src/shared) */ + + +extern void (*D_80187534[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(void); + +void func_8015F9A4(void *arg0) { + if (*(u16 *)((u8 *)arg0 + 0xB8) & 0x8000) { + D_80187534[*(u16 *)arg0](arg0); + func_80147078(arg0, 0); + func_80159B70(arg0); + } else { + ((s32 (*)(void *))func_80161208)(arg0); + } +} + + +DEFINE_func_8015FA24() /* dedup: shared engine-core @0x8015FA24 (src/shared) */ + +DEFINE_func_8015FA44() /* dedup: shared engine-core @0x8015FA44 (src/shared) */ + +DEFINE_func_8015FA78() /* dedup: shared engine-core @0x8015FA78 (src/shared) */ + + + +void func_8015FAAC(s32 *a0) { + + extern void (*D_8018787C[])(void); + D_8018787C[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern s32 func_801612B8(void *a0, s32 a1); +extern void func_8016007C(s32 a0); +extern void (*D_80187534[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern s32 func_8015BE94(); +extern void func_8015C0C4(s32 a0); +extern void func_8015FBE0(s32 *a0); + +void func_8015FAE8(void *arg0) { + s32 v; + + v = func_801612B8(arg0, 0); + if (v == 0 || v == 0x8000) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 3); + ((void (*)(void *))func_8015BE94)(arg0); + } else if ((v & 0x4000) != 0) { + ((void (*)(void *))func_8016007C)(arg0); + *(u32 *)((u8 *)arg0 + 0x184) |= 0x80000000; + D_80187534[*(u16 *)arg0](arg0); + ((void (*)(void *, s16))func_80147078)(arg0, 4); + ((void (*)(void *))func_8015C0C4)(arg0); + } else { + ((void (*)(void *))func_8015FBE0)(arg0); + } +} + + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_8015FBE0); + +extern void func_801599A4(void *a0); + +// @class: struct +// @stuck: none — MATCH (indexed fn-ptr table call + byte-offset struct stores; mirrors sibling func_801599A4 idiom) + +extern s32 D_800AE6B0; +extern void (*D_80187534[])(void *); + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_8015FCC8(void *param_1) { + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187534[*(u16 *)param_1](param_1); + ((void (*)(void *, s32))func_80147078)(param_1, 0); + func_80159B70(param_1); + } else { + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + *(u8 *)((s32)param_1 + 0x1A0) = (u8)*(s32 *)((s32)param_1 + 0x184); + ((s32 (*)(void *, s32))func_8014BFF4)(param_1, 1); + func_80146CA0(param_1); + } +} + + + +// @class: plumbing +// @stuck: none — MATCH expected; simple 3-call sequence with global table index + +extern unsigned int D_80187890[]; + +extern void func_80147324(s32 arg0); +extern s32 func_8013767C(s32 a0); +extern void func_80146CA0(void *a0); + +void func_8015FD74(int param_1) +{ + ((int (*)(int))func_80147324)(0x18); + *(int *)(param_1 + 0x198) = func_8013767C(D_80187890[*(unsigned char *)(param_1 + 0x1a0)]); + ((int (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_8015FDCC() /* dedup: shared engine-core @0x8015FDCC (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr-table dispatch + ushort struct fields) + + +extern void (*D_80187534[])(void*); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern void func_80154A74(s32 a0, s32 a1); +extern s32 func_80161208(); + +void func_8015FE70(u16 *param_1) +{ + if ((param_1[0x5c] & 0x8000) != 0) { + if (param_1[0x5d] == 0) { + ((void (**)())D_80187534)[param_1[0]](); + ((void (*)(u16 *, s16))func_80147078)(param_1, 0); + ((void (*)(u16 *))func_80159B70)(param_1); + return; + } + param_1[0x5c] = param_1[0x5d]; + } + if ((param_1[0x5c] & 0x4000) != 0) { + ((void (*)(u16 *, s16))func_80154A74)(param_1, 0x11); + } + ((void (*)(u16 *))func_80161208)(param_1); +} + + + +extern s32 D_800AE6B0; +extern void (*D_80187534[])(void *); +extern u8 D_80078EC1; +extern u8 D_80078EC2; +extern u16 D_801270C0; + +extern void func_8016007C(s32 a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern u8 func_801656E8(s32 a0, s32 a1); +extern void func_80150820(s32 a0, s32 a1); +extern void func_8014BFF4(s32 a0, s32 a1); +extern void func_80165670(s32 a0, s32 a1); +extern void func_80165840(void); +extern void func_801658DC(void); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_8016004C(s32 a0); + +void func_8015FF20(void *param_1) { + s32 v2; + u8 cur; + + if ((D_800AE6B0 & 0x80FFFFFF) != 0) { + ((void (*)(void))func_8016007C)(); + D_80187534[*(u16 *)param_1](param_1); + ((void (*)(void *, s16))func_80147078)(param_1, 0); + func_80159B70(param_1); + return; + } + + v2 = *(s32 *)((s32)param_1 + 0x184); + if (v2 < 0) { + func_80150820((s32)param_1, func_801656E8((s32)param_1, v2 & 0xFF) & 0xFF); + } else { + if (*(u8 *)((s32)param_1 + 0x1A0) != *(u8 *)((s32)param_1 + 0x196)) { + *(u8 *)((s32)param_1 + 0x1A0) = (u8)v2; + *(u8 *)((s32)param_1 + 0x197) = 0; + *(u8 *)((s32)param_1 + 0xBE) = 0; + *(u8 *)((s32)param_1 + 0xBF) = 0; + func_8014BFF4((s32)param_1, 1); + } + + cur = *(u8 *)((s32)param_1 + 0x1A0); + D_80078EC1 = cur; + D_80078EC2 = cur; + func_80165670((s32)param_1, cur); + ((void (*)(void *))func_80165840)(param_1); + ((void (*)(void *))func_801658DC)(param_1); + func_80154A74((s32)param_1, 0x11); + D_801270C0 = 1; + } + + ((void (*)(void *))func_8016004C)(param_1); +} + + +DEFINE_func_8016004C() /* dedup: shared engine-core @0x8016004C (src/shared) */ + +DEFINE_func_8016007C() /* dedup: shared engine-core @0x8016007C (src/shared) */ + +DEFINE_func_801600D0() /* dedup: shared engine-core @0x801600D0 (src/shared) */ + +DEFINE_func_80160104() /* dedup: shared engine-core @0x80160104 (src/shared) */ + + + +void func_80160138(s32 *a0) { + + extern void (*D_8018790C[])(void); + D_8018790C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160174() /* dedup: shared engine-core @0x80160174 (src/shared) */ + +DEFINE_func_801601AC() /* dedup: shared engine-core @0x801601AC (src/shared) */ + +DEFINE_func_801601E4() /* dedup: shared engine-core @0x801601E4 (src/shared) */ + +DEFINE_func_80160244() /* dedup: shared engine-core @0x80160244 (src/shared) */ + + +extern void (*D_80187534[])(void*); +extern void func_80154A74(s32 a0, s32 a1); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_801602A4(s32 *a0) { + if (*(u16 *)((u8 *)a0 + 0xB8) == 0x8000) { + ((void (**)())D_80187534)[*(u16 *)a0](); + func_80154A74((s32)a0, 0x11); + ((void (*)(s32, s32))func_80147078)((s32)a0, 0); + func_80159B70(a0); + } else { + ((s32 (*)(s32 *))func_80161208)(a0); + } +} + + +DEFINE_func_8016032C() /* dedup: shared engine-core @0x8016032C (src/shared) */ + +DEFINE_func_80160334() /* dedup: shared engine-core @0x80160334 (src/shared) */ + +DEFINE_func_80160368() /* dedup: shared engine-core @0x80160368 (src/shared) */ + + + +void func_8016039C(s32 *a0) { + + extern void (*D_8018791C[])(void); + D_8018791C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_801603D8() /* dedup: shared engine-core @0x801603D8 (src/shared) */ + +DEFINE_func_80160410() /* dedup: shared engine-core @0x80160410 (src/shared) */ + + + + + + + +/* data */ +extern u8 D_80078EC0; +extern u8 D_80078EBF; +extern void (*D_80187534[])(void *); + +/* callees (engine_core.h canonical sigs) */ +extern void func_80149020(s32 *a0); +extern void func_80149034(s32 *a0); +extern u16 func_80148800(s32 *a0); +extern s32 func_80149B54(s32 *a0); +extern void func_80149BAC(s32 *a0); +extern s32 func_80149AA8(s32 *a0); +extern void func_80149AD4(s32 *a0); +extern s32 func_80146E98(s32 a0); +extern u16 func_801487F4(s32 *a0); +extern void func_8015E9B8(s32 *a0); +extern void func_80159B70(void *a0); +extern s32 func_800CF8B4(); +extern s32 func_801491C4(s32 a0); +extern void func_80147AD4(s32 a0, s32 a1, s32 a2, s32 a3); +extern void func_801473EC(s32 *a0); +extern void func_8014D738(void); +extern void func_8015C714(void *a0); +extern s32 func_80161208(); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_8015F00C(s32 *a0); + +void func_80160534(u8 *p) { + + extern s16 D_801152A0; + func_80149020((s32 *)p); + func_80149034((s32 *)p); + if ((D_80078EC0 & 0x7F) != 0 && (func_80148800((s32 *)p) & 0x90) != 0) { + if (D_80078EBF == 0x80) { + D_80187534[*(u16 *)p](p); + func_80147078((s32 *)p, 0x13); + func_8015F00C((s32 *)p); + return; + } + if (func_80149B54((s32 *)p) != 0) { + D_80187534[*(u16 *)p](p); + func_80149BAC((s32 *)p); + return; + } + } + if (func_80149AA8((s32 *)p) != 0) { + D_80187534[*(u16 *)p](p); + func_80149AD4((s32 *)p); + return; + } + if (func_80146E98((s32)p) != 0) { + if ((func_801487F4((s32 *)p) & 8) != 0) { + D_80187534[*(u16 *)p](p); + func_80147078((s32 *)p, 0x11); + func_8015E9B8((s32 *)p); + } else { + D_80187534[*(u16 *)p](p); + func_80147078((s32 *)p, 0); + func_80159B70(p); + } + return; + } + if (func_800CF8B4() != 0) { + *(u16 *)(*(s32 *)(p + 0x20) + 0x12) = + ((*(u16 *)&D_801152A0) + func_801491C4((s32)p)) & 0xFFF; + } + func_80147AD4((s32)p, *(s32 *)(p + 0x234), *(s32 *)(p + 0x238), + *(s32 *)(p + 0x23C)); + func_801473EC((s32 *)p); + if (((s32 (*)(s32 *))func_8014D738)((s32 *)p) != 0) { + D_80187534[*(u16 *)p](p); + func_80147078((s32 *)p, 9); + func_8015C714(p); + } else { + ((s32 (*)(void *))func_80161208)(p); + } +} + + +DEFINE_func_801607B8() /* dedup: shared engine-core @0x801607B8 (src/shared) */ + +DEFINE_func_801607E4() /* dedup: shared engine-core @0x801607E4 (src/shared) */ + +DEFINE_func_80160818() /* dedup: shared engine-core @0x80160818 (src/shared) */ + + + +void func_8016084C(s32 *a0) { + + extern void (*D_80187924[])(void); + D_80187924[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160888() /* dedup: shared engine-core @0x80160888 (src/shared) */ + +DEFINE_func_801608C0() /* dedup: shared engine-core @0x801608C0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (function-pointer table folds %lo via extern array indexed by halfword) + +typedef void (*code)(unsigned short *); + +extern void (*D_80187534[])(void*); + +extern u16 func_801487F4(s32 *a0); +extern s32 func_80161208(); +extern void func_80160A74(s32 *a0); +extern void func_80154150(s32 a0, s32 a1); +extern void func_80146CA0(void *a0); + +void func_80160920(unsigned short *param_1) +{ + if ((((int (*)(void))func_801487F4)() & 8) == 0) { + ((code *)D_80187534)[*param_1](param_1); + ((void (*)(unsigned short *))func_80160A74)(param_1); + } else { + if (((int (*)(unsigned short *))func_80161208)(param_1) == 0 && param_1[0x5c] == 0x8000) { + ((void (*)(unsigned short *, int))func_80154150)(param_1, 0x25); + ((void (*)(unsigned short *))func_80146CA0)(param_1); + } + } + return; +} + + + + +// @class: struct +// @stuck: none — MATCH (pending byte-gate); function-pointer table %lo-fold via extern array + + +extern u16 func_801487F4(s32 *a0); +extern void func_80160A74(s32 *a0); +extern s32 func_80161208(); + +/* function-pointer dispatch table; indexed by *param_1 (×4 = ptr size) */ +extern void (*D_80187534[])(void*); + +void func_801609B8(u16 *param_1) { + if ((((u32 (*)(void))func_801487F4)() & 8) == 0) { + ((void (**)(u16*))D_80187534)[*param_1](param_1); + ((void (*)(u16 *))func_80160A74)(param_1); + } else { + ((void (*)(u16 *))func_80161208)(param_1); + } +} + + +DEFINE_func_80160A28() /* dedup: shared engine-core @0x80160A28 (src/shared) */ + +DEFINE_func_80160A74() /* dedup: shared engine-core @0x80160A74 (src/shared) */ + +DEFINE_func_80160ACC() /* dedup: shared engine-core @0x80160ACC (src/shared) */ + +DEFINE_func_80160B00() /* dedup: shared engine-core @0x80160B00 (src/shared) */ + + + +s32 func_80160B34(s32 a0) { + + extern void (*D_80187930[])(void); + D_80187930[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160B70() /* dedup: shared engine-core @0x80160B70 (src/shared) */ + +DEFINE_func_80160BB4() /* dedup: shared engine-core @0x80160BB4 (src/shared) */ + +DEFINE_func_80160C28() /* dedup: shared engine-core @0x80160C28 (src/shared) */ + +DEFINE_func_80160CB4() /* dedup: shared engine-core @0x80160CB4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (mirrors byte-matched func_8015DBD4 in same overlay; dispatch via D_80187534 + func_80147078/func_80159B70 tail, func_80161208 else) + +extern void (*D_80187534[])(void *); +extern u16 func_80148800(s32 *a0); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); +extern s32 func_80161208(); + +void func_80160D10(void *arg0) { + if (*(u32 *)((u8 *)arg0 + 0x44) & 0x10) { + D_80187534[*(u16 *)arg0](arg0); + } else { + if (*(s32 *)((u8 *)arg0 + 0x1AC) == 0) { + if ((((s32 (*)(void *))func_80148800)(arg0) & 0xF0) == 0) { + goto dd0; + } + } else { + s32 t = *(s32 *)((u8 *)arg0 + 0x1AC) - 0xAAA8; + *(s32 *)((u8 *)arg0 + 0x1AC) = t; + if (t >= 0) { + goto dd0; + } + } + D_80187534[*(u16 *)arg0](arg0); + } + ((void (*)(void *, s16))func_80147078)(arg0, 0); + func_80159B70(arg0); + return; +dd0: + ((s32 (*)(void *))func_80161208)(arg0); +} + + +DEFINE_func_80160DEC() /* dedup: shared engine-core @0x80160DEC (src/shared) */ + +DEFINE_func_80160E3C() /* dedup: shared engine-core @0x80160E3C (src/shared) */ + +DEFINE_func_80160E70() /* dedup: shared engine-core @0x80160E70 (src/shared) */ + + +extern void (*D_80187940[])(void); + +void func_80160EA4(void *a0) { + D_80187940[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80160EE0() /* dedup: shared engine-core @0x80160EE0 (src/shared) */ + +DEFINE_func_80160F00() /* dedup: shared engine-core @0x80160F00 (src/shared) */ + +DEFINE_func_80160F70() /* dedup: shared engine-core @0x80160F70 (src/shared) */ + +DEFINE_func_80160FE0() /* dedup: shared engine-core @0x80160FE0 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH + +extern void func_80149020(s32 *a0); +extern void (*D_80187534[])(void *); +extern void func_80147078(s32 *a0, s16 a1); +extern void func_80159B70(void *a0); + +void func_80161034(void *a0) +{ + func_80149020(a0); + D_80187534[*(u16 *)a0](a0); + func_80147078(a0, 0); + func_80159B70(a0); +} + + +DEFINE_func_80161094() /* dedup: shared engine-core @0x80161094 (src/shared) */ + +DEFINE_func_801610FC() /* dedup: shared engine-core @0x801610FC (src/shared) */ + +DEFINE_func_80161104() /* dedup: shared engine-core @0x80161104 (src/shared) */ + +DEFINE_func_80161124() /* dedup: shared engine-core @0x80161124 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80161208); + +DEFINE_func_80161240() /* dedup: shared engine-core @0x80161240 (src/shared) */ + +DEFINE_func_80161278() /* dedup: shared engine-core @0x80161278 (src/shared) */ + +DEFINE_func_801612B8() /* dedup: shared engine-core @0x801612B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_8016130C); + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80161374); + +DEFINE_func_80161418() /* dedup: shared engine-core @0x80161418 (src/shared) */ + +DEFINE_func_80161450() /* dedup: shared engine-core @0x80161450 (src/shared) */ + +DEFINE_func_80161488() /* dedup: shared engine-core @0x80161488 (src/shared) */ + +DEFINE_func_801614E4() /* dedup: shared engine-core @0x801614E4 (src/shared) */ + +DEFINE_func_8016151C() /* dedup: shared engine-core @0x8016151C (src/shared) */ + +DEFINE_func_80161554() /* dedup: shared engine-core @0x80161554 (src/shared) */ + +DEFINE_func_8016158C() /* dedup: shared engine-core @0x8016158C (src/shared) */ + +DEFINE_func_801615C4() /* dedup: shared engine-core @0x801615C4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_8016163C); + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80161774); + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80161888); + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_8016191C); + +DEFINE_func_8016197C() /* dedup: shared engine-core @0x8016197C (src/shared) */ + +DEFINE_func_801619A4() /* dedup: shared engine-core @0x801619A4 (src/shared) */ + +DEFINE_func_801619D0() /* dedup: shared engine-core @0x801619D0 (src/shared) */ + +DEFINE_func_80161A00() /* dedup: shared engine-core @0x80161A00 (src/shared) */ + +DEFINE_func_80161A30() /* dedup: shared engine-core @0x80161A30 (src/shared) */ + +DEFINE_func_80161A60() /* dedup: shared engine-core @0x80161A60 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80161A90); + +DEFINE_func_80161B18() /* dedup: shared engine-core @0x80161B18 (src/shared) */ + +DEFINE_func_80161B84() /* dedup: shared engine-core @0x80161B84 (src/shared) */ + +DEFINE_func_80161BE0() /* dedup: shared engine-core @0x80161BE0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80161C24); + + +// @class: struct +// @stuck: none — MATCH (indexed-global %lo-fold via extern u16 array, §18) + +extern u16 D_80187970[]; +extern void func_80147324(s32 arg0); + +void func_80161C98(int param_1, u32 param_2) +{ + if (param_2 < 8) { + func_80147324(D_80187970[param_2]); + } + return; +} + + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80161CD0); + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80161D20); + +DEFINE_func_80161D58() /* dedup: shared engine-core @0x80161D58 (src/shared) */ + + +// @class: other +// @stuck: none — MATCH (short-circuit && chain; reused 0x80FFFFFF mask const, andi-0xFF on callee ret) + +extern s32 D_800AE6B0; +extern s32 D_800AE6A8; +extern s32 func_80029178(s32 arg); +extern void func_80029124(s32, s32); +extern void func_800D1734(void *); +extern s32 D_801879D4; + +void func_80161D88(void) { + if ((D_800AE6B0 & 0x80FFFFFF) == 0 && (D_800AE6A8 & 0x80FFFFFF) == 0 && + (func_80029178(0x141) & 0xFF) != 0) { + func_80029124(0x141, 0); + func_80029124(0x95, 1); + func_800D1734(&D_801879D4); + } +} + + +// @class: regalloc-order +// @stuck: none — MATCH (175 ins, relocation-masked). Giant, 3 similar guarded blocks. base=&D_800AF630 +// hoisted to $s2 (referenced only to build the 3 stored pointers base+0x65A8/0x65E0/0x6618 -> $s1); +// guard reads (D_800B5BD8/C10/C48) + the "=1" + coord stores use direct symbols. Coord idiom: +// -(s32)(u16)D_800AF7BC/2 + K (negu;srl31;addu;sra1). a2=func_800291DC(8) survives in $s3 for the +// final (a2&0x7FFF)==(s16)D_80078EB0 test. KEY RESIDUAL (cracked): target computes each pointer into +// scratch $v0 then `addu $s1,$v0` (dead-intermediate copy) and stores $s1 — natural C ALWAYS coalesces +// that copy into a direct `addiu $s1,$s2,off` (172 ins, 3 short). Forcing the un-coalesced copy needs +// an explicit `move` inline-asm (an empty "=r"/"0" re-tie is only a barrier, won't emit the copy). +#include "common.h" + + + + + + + +void func_80161E08(s32 param_1) { + extern void func_80024054(void *a0, void *a1); + extern void func_8001CE28(void *a0, void *a1); + extern void func_800242D0(s32 a0, void *a1, s32 a2); + extern void func_8001CE68(void *a0, void *a1); + extern int func_801620C4(void); + extern void func_801622C4(void); + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_80078EB0; + extern u16 D_800B5BD8; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern u16 D_800B5C10; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern u16 D_800B5C48; + extern s16 D_800B5C74; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern u8 * D_8019E4E0[]; + extern u8 D_801879A0[]; + extern u8 D_801879C0[]; + extern u8 D_8019E4EC[]; + extern u8 D_8019E514[]; + extern u8 D_8019E52C[]; + + u8 *base = &(*(u8 *)&D_800AF630); + u8 *p; + s32 a2; + + if (*((u16 *)param_1) != 0x1A && + currentLocationId != 0x3012 && + currentLocationId != 0x3054 && + currentLocationId != 0x3079 && + currentLocationId != 0x3096 && + ((a2 = func_800291DC(8)) & 0x8000) != 0) { + + if (D_800B5BD8 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65A8)); + D_8019E4E0[0] = p; + func_80024054(&D_801879A0, &D_8019E4EC); + func_8001CE28(p, &D_8019E4EC); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -(s32)(u16)D_800AF7BE / 2 + 0x28; + } + + if (D_800B5C10 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x65E0)); + D_8019E4E0[1] = p; + func_80024054(&D_801879C0, &D_8019E514); + func_8001CE28(p, &D_8019E514); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -(s32)(u16)D_800AF7BE / 2 + 0x30; + } + + if (D_800B5C48 == 0) { + __asm__("move %0,%1" : "=r"(p) : "r"(base + 0x6618)); + D_8019E4E0[2] = p; + func_800242D0((s16)func_801620C4(), &D_8019E52C, 0x84); + func_8001CE68(p, &D_8019E52C); + D_800B5C74 = 1; + D_800B5C50 = -(s32)(u16)D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -(s32)(u16)D_800AF7BE / 2 + 0x10; + } + + func_800242D0((s16)func_801620C4(), &D_8019E52C, 0x84); + if ((a2 & 0x7FFF) == (s32)D_80078EB0) { + func_801622C4(); + } + } +} + + + +DEFINE_func_801620C4() /* dedup: shared engine-core @0x801620C4 (src/shared) */ + +DEFINE_func_80162120() /* dedup: shared engine-core @0x80162120 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (do-while scan over 3-entry global; increments placed AFTER the call so p++ schedules between load and jal, i++ into the delay slot) + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019E4E0[]; + +void func_8016216C(void) +{ + int *p; + int i; + + func_800291C8(8, 0); + i = 0; + p = D_8019E4E0; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern s32 func_800291DC(s32); +extern u8 D_80078E78[]; +extern u8 D_80078EB0; +extern u8 D_80078EB1; +extern s32 D_801879D4; + +s32 func_801621CC(s32 arg0) { + register s32 s0 __asm__("$16") = arg0; /* $s0: arg0, crosses the call */ + register u8 *s1 __asm__("$17") = D_80078E78; /* $s1: base, hoisted for the loop */ + register s32 i __asm__("$5"); /* $a1: counter (pin fixes the i/d swap) */ + u32 a2; + s32 d; /* $a0: natural alloc; load via $v0 temp */ + s32 v, last, hi, lo; + char pad[8]; /* phantom 8B local -> frame 0x28 (vars=8) */ + + a2 = func_800291DC(8); + if ((a2 & 0x8000) == 0) { + return 0; + } + a2 &= 0x7FFF; + if (((a2 >> 8) == D_80078EB1) && ((a2 & 0xFF) <= (u32)D_80078EB0)) { + return (s32)&D_801879D4; + } + d = s1[0x39] - 1; + i = 0; + if (s0 <= 0) { + return 0; + } + hi = (a2 >> 8) & 0xFF; + last = s0 - 1; + lo = a2 & 0xFF; + do { + if ((s8)d < 0) { + d = 0x17; + } + v = (s8)d; + if (hi == v) { + if (i != last) { + return (s32)&D_801879D4; + } + i++; + if ((u32)s1[0x38] < (u32)lo) { + return (s32)&D_801879D4; + } + goto bot; + } + i++; + bot: + d--; + } while (i < s0); + return 0; +} + + + + +// @class: schedule +// @stuck: none — MATCH +extern void func_80029124(s32, s32); +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); +extern int D_8019E4E0[]; + +void func_801622C4(void) +{ + int *p; + int i; + + ((int (*)(int, int))func_80029124)(0x141, 1); + ((int (*)(int, int))func_800291C8)(8, 0); + i = 0; + p = &D_8019E4E0; + do { + ((int (*)(int, int))func_80016714)(*p, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + + +extern void (*D_801879F8[])(void); + +void func_80162330(void *a0) { + D_801879F8[*(u8 *)((s32)a0 + 0x15)](); +} + + +DEFINE_func_8016236C() /* dedup: shared engine-core @0x8016236C (src/shared) */ + +DEFINE_func_801623B8() /* dedup: shared engine-core @0x801623B8 (src/shared) */ + +DEFINE_func_80162414() /* dedup: shared engine-core @0x80162414 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (160 ins, relocation-masked). Keys: (1) base=&D_800AF630 hoisted, pinned $s2; +// uVar2 UNPINNED (a $s3 pin forced the final `uVar2 & 0x7FFF` in-place+early, breaking the lh delay +// slot). (2) item pinned $s1, dest INLINED (D_801D96Dx in both call args) so it lands $s0 AFTER a0. +// (3) base assigned BEFORE the func_800291DC call so the return-copy `addu $s3,$v0` schedules after +// the base lui/addiu. (4) THE MOVE: each block's `addu $s1,$v0,$zero` = compute `base+off` into a +// $v0-PINNED temp `t`, then `item = t`. Two distinct hard regs ($v0 vs $s1) can't coalesce, forcing +// the exact `addiu $v0,$s2,off ; addu $s1,$v0` pair the target emits (plain `item=base+off` coalesces +// into one `addiu $s1` — 3 ins short). (5) store D_8019E538[i] via `extern int D_8019E538[]` (folds +// %lo, consistent with func_80162760). Coord = (s16)(-D_800AF7Bx / 2 + K) (negu; srl 31; addu; sra 1). + +#include "common.h" + + + + + + + + +s32 func_80162438(s32 _unused0) { + extern void func_80024054(void *, void *); + extern void func_8001CE28(void *, void *); + extern void func_8001CE68(void *, void *); + extern void func_800242D0(s32, void *, s32); + extern s32 func_801626B8(void); + extern void func_80162760(void); + extern u8 D_80187A04[]; + extern s32 D_80187A1C; + extern u8 D_8019E544[]; + extern u8 D_8019E56C[]; + extern u8 D_8019E588[]; + extern int D_8019E538[]; + extern u16 D_800B5BD8; + extern u16 D_800B5C10; + extern u16 D_800B5C48; + extern u16 D_800AF7BC; + extern u16 D_800AF7BE; + extern s16 D_800B5BE0; + extern s16 D_800B5BE2; + extern s16 D_800B5C04; + extern u8 D_800B5BFF; + extern s16 D_800B5C18; + extern s16 D_800B5C1A; + extern s16 D_800B5C3C; + extern u8 D_800B5C37; + extern s16 D_800B5C50; + extern s16 D_800B5C52; + extern s16 D_800B5C74; + + u32 uVar2; + register u8 *base __asm__("$18"); + register u8 *item __asm__("$17"); + + base = &(*(u8 *)&D_800AF630); + uVar2 = func_800291DC(0x12); + if ((uVar2 & 0x8000) != 0) { + if (D_800B5BD8 == 0) { + register u8 *t __asm__("$2") = base + 0x65A8; + item = t; + D_8019E538[0] = (s32)item; + func_80024054(D_80187A04, D_8019E544); + func_8001CE28(item, D_8019E544); + D_800B5C04 = 1; + D_800B5BFF = 1; + D_800B5BE0 = -D_800AF7BC / 2 + 0xD0; + D_800B5BE2 = -D_800AF7BE / 2 + 0x28; + } + if (D_800B5C10 == 0) { + register u8 *t __asm__("$2") = base + 0x65E0; + item = t; + D_8019E538[1] = (s32)item; + func_80024054(((u8 *)&D_80187A1C), D_8019E56C); + func_8001CE28(item, D_8019E56C); + D_800B5C3C = 1; + D_800B5C37 = 1; + D_800B5C18 = -D_800AF7BC / 2 + 0xD0; + D_800B5C1A = -D_800AF7BE / 2 + 0x30; + } + if (D_800B5C48 == 0) { + register u8 *t __asm__("$2") = base + 0x6618; + item = t; + D_8019E538[2] = (s32)item; + func_800242D0((s16)func_801626B8(), D_8019E588, 0x84); + func_8001CE68(item, D_8019E588); + D_800B5C74 = 1; + D_800B5C50 = -D_800AF7BC / 2 + 0xD0; + D_800B5C52 = -D_800AF7BE / 2 + 0x10; + } + func_800242D0((s16)func_801626B8(), D_8019E588, 0x84); + if ((uVar2 & 0x7FFF) == (s32)(*(s16 *)&D_80078EB0)) { + func_80162760(); + } + } +} + + + +DEFINE_func_801626B8() /* dedup: shared engine-core @0x801626B8 (src/shared) */ + +DEFINE_func_80162714() /* dedup: shared engine-core @0x80162714 (src/shared) */ + + +// @class: schedule +// @stuck: none — MATCH (24 ins). do-while; load+call first, then p++ and i++ AFTER the call so gcc schedules p++/arg ahead of jal and i++ into the delay slot. + +extern void func_800291C8(s32, s32); +extern void func_80016714(void *a0, s32 a1); + +extern int D_8019E538[]; + +void func_80162760(void) +{ + int *p; + int i; + + func_800291C8(0x12, 0); + i = 0; + p = D_8019E538; + do { + int v = *p; + ((void (*)(int, int))func_80016714)(v, 0x38); + p = p + 1; + i = i + 1; + } while (i < 3); +} + + +DEFINE_func_801627C0() /* dedup: shared engine-core @0x801627C0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_801627E8); + + +extern void (*D_80187A40[])(void); + +void func_80162834(void *a0) { + D_80187A40[*(u8 *)((s32)a0 + 0x1)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (stub: alloc + global init + two calls; $s0 holds param_1 across calls) + +extern void func_8001CB6C(u8 *a0, s32 a1, s32 a2, s32 a3); +extern void func_80162968(s32 a0); +extern s32 func_80162ACC(u8 *a0); + +extern u8 D_800B5CB8; +extern s32 D_80187A30; +extern s32 D_800B5CBC; +extern u8 D_800B5CDF; +extern s32 D_800B5CEC; + +void func_80162870(s32 param_1) { + *(s32 *)(param_1 + 8) = (s32)&D_800B5CB8; + func_8001CB6C(&D_800B5CB8, (s32)&D_80187A30, 0x250, 0x1A0); + D_800B5CEC = param_1 + 0xC; + D_800B5CDF = 0x14; + D_800B5CBC |= 0x60000000; + func_80162968(param_1); + func_80162ACC((u8 *)param_1); +} + + +DEFINE_func_801628F4() /* dedup: shared engine-core @0x801628F4 (src/shared) */ + +DEFINE_func_80162968() /* dedup: shared engine-core @0x80162968 (src/shared) */ + +DEFINE_func_80162AC0() /* dedup: shared engine-core @0x80162AC0 (src/shared) */ + +DEFINE_func_80162ACC() /* dedup: shared engine-core @0x80162ACC (src/shared) */ + +DEFINE_func_80162AE0() /* dedup: shared engine-core @0x80162AE0 (src/shared) */ + +DEFINE_func_80162AF4() /* dedup: shared engine-core @0x80162AF4 (src/shared) */ + +DEFINE_func_80162B1C() /* dedup: shared engine-core @0x80162B1C (src/shared) */ + +DEFINE_func_80162CC4() /* dedup: shared engine-core @0x80162CC4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80162CCC); + +DEFINE_func_80162D28() /* dedup: shared engine-core @0x80162D28 (src/shared) */ + +DEFINE_func_80162D88() /* dedup: shared engine-core @0x80162D88 (src/shared) */ + +DEFINE_func_80162DE8() /* dedup: shared engine-core @0x80162DE8 (src/shared) */ + +DEFINE_func_80162E48() /* dedup: shared engine-core @0x80162E48 (src/shared) */ + +DEFINE_func_80162EA8() /* dedup: shared engine-core @0x80162EA8 (src/shared) */ + +DEFINE_func_80162F08() /* dedup: shared engine-core @0x80162F08 (src/shared) */ + +DEFINE_func_80162F60() /* dedup: shared engine-core @0x80162F60 (src/shared) */ + +DEFINE_func_80162F80() /* dedup: shared engine-core @0x80162F80 (src/shared) */ + +DEFINE_func_80162FA0() /* dedup: shared engine-core @0x80162FA0 (src/shared) */ + +DEFINE_func_80162FC0() /* dedup: shared engine-core @0x80162FC0 (src/shared) */ + +DEFINE_func_80162FF4() /* dedup: shared engine-core @0x80162FF4 (src/shared) */ + +DEFINE_func_801630C4() /* dedup: shared engine-core @0x801630C4 (src/shared) */ + +DEFINE_func_80163194() /* dedup: shared engine-core @0x80163194 (src/shared) */ + +DEFINE_func_80163234() /* dedup: shared engine-core @0x80163234 (src/shared) */ + +DEFINE_func_8016325C() /* dedup: shared engine-core @0x8016325C (src/shared) */ + +DEFINE_func_801632E0() /* dedup: shared engine-core @0x801632E0 (src/shared) */ + +DEFINE_func_801632F0() /* dedup: shared engine-core @0x801632F0 (src/shared) */ + +DEFINE_func_80163328() /* dedup: shared engine-core @0x80163328 (src/shared) */ + +DEFINE_func_801633A8() /* dedup: shared engine-core @0x801633A8 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (21 ins, relocation-masked) + + +s32 func_80163408(s32 param_1, s32 param_2, s32 param_3, s32 param_4) { + extern int func_8016345C(int, unsigned short, int, unsigned short, void *); + extern unsigned char D_8019DC10[8]; + + unsigned char sp18[8]; + memcpy(sp18, D_8019DC10, 8); + return func_8016345C(((int)param_1), ((int)param_2), ((int)param_3), ((int)param_4), sp18); +} + + + +DEFINE_func_8016345C() /* dedup: shared engine-core @0x8016345C (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (unaligned 8-byte memcpy from global into stack buffer, then forward to callee) + +extern char D_8019DC10[8]; + +extern void *memcpy(void *dst, const void *src, unsigned int n); +extern void func_80163534(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4, s32 a5); + +void func_801634D8(s32 param_1, u16 param_2, u16 param_3, s32 param_4, u16 param_5) +{ + char buf[8]; + + memcpy(buf, D_8019DC10, 8); + ((void (*)(s32, u16, u16, s32, u16, s32))func_80163534)(param_1, param_2, param_3, param_4, param_5, (s32)buf); +} + + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80163534); + +DEFINE_func_80163664() /* dedup: shared engine-core @0x80163664 (src/shared) */ + +DEFINE_func_801636D0() /* dedup: shared engine-core @0x801636D0 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80163764); + +DEFINE_func_8016380C() /* dedup: shared engine-core @0x8016380C (src/shared) */ + +DEFINE_func_801638A0() /* dedup: shared engine-core @0x801638A0 (src/shared) */ + +DEFINE_func_80163950() /* dedup: shared engine-core @0x80163950 (src/shared) */ + + +extern void (*D_80187A48[])(void); + +void func_80163A58(void *a0) { + D_80187A48[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80163A94() /* dedup: shared engine-core @0x80163A94 (src/shared) */ + +DEFINE_func_80163C2C() /* dedup: shared engine-core @0x80163C2C (src/shared) */ + + +void func_80163EC8(s32 param_1) { + extern Blk8 D_8019DC18; + extern u16 D_800B99DA; + extern u8 func_801656D0(s32 a0, s32 a1); + extern s32 func_80012F74(s32 a0, s32 a1, s32 a2, s32 a3); + extern void func_80015978(s32 a0, s32 *a1); + extern void func_8014C4AC(s32 a0, s32 a1, s32 a2, s16 *a3, s32 a4); + + Blk8 in; + u16 out[4]; + s16 buf[4]; + s32 psVar6; + s32 iVar8; + s32 iVar7; + register s32 uVar5 __asm__("$2"); /* PIN (flagged): uVar5 -> $v0 */ + u16 uVar4; + u8 uVar3; + + in = D_8019DC18; + psVar6 = *(s32 *)(param_1 + 0x4c); + iVar8 = *(s32 *)(param_1 + 0x20); + func_80162D88((s32 *)param_1); + + if (*(s32 *)(psVar6 + 0x184) == 0) { + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + } + if (*(s16 *)(*(s32 *)(psVar6 + 0x184) + 0x36) == *(u16 *)(psVar6 + 0x194)) { + goto LAB_matched; + } + *(s32 *)(psVar6 + 0x184) = 0; + uVar5 = *(s32 *)(psVar6 + 0x44); + *(s16 *)(psVar6 + 0x18a) = 0; + *(s16 *)(psVar6 + 0x188) = 0; + *(s32 *)(psVar6 + 0x44) = uVar5 & ~0x20; + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + return; + +LAB_matched: + *(s16 *)(psVar6 + 0x18a) = *(u16 *)(psVar6 + 0x18a) + 1; + if ((D_800B99DA & 3) == 0) { + if (*(s16 *)(psVar6 + 0x188) >= *(u8 *)(param_1 + 0x67)) { + *(s16 *)(psVar6 + 0x188) = *(s16 *)(psVar6 + 0x188) - *(u8 *)(param_1 + 0x67); + } else { + *(s16 *)(psVar6 + 0x188) = 0; + } + if (*(s16 *)(psVar6 + 0x188) < 0) { + *(s16 *)(psVar6 + 0x188) = 0; + } + } + + *(s16 *)(param_1 + 0x66) = *(u16 *)(param_1 + 0x66) + 0x40; + uVar5 = func_80148800((s32 *)psVar6); + if ((uVar5 & 0x80) != 0) { + *(s16 *)(param_1 + 0x66) = 0; + uVar3 = func_801656D0(psVar6, func_8014CA00(*(s32 *)(psVar6 + 0x184)) & 0xff); + *(s16 *)(psVar6 + 0x188) = *(u16 *)(psVar6 + 0x188) + uVar3; + *(s16 *)(iVar8 + 0x1a) = 0x4000; + *(s16 *)(iVar8 + 0x18) = 0x4000; + *(s32 *)(iVar8 + 0x48) = *(s16 *)(param_1 + 0x58); + *(s32 *)(iVar8 + 0x4c) = *(s16 *)(param_1 + 0x5a); + *(s32 *)(iVar8 + 0x50) = *(s16 *)(param_1 + 0x5c); + ((void (*)(s32, s32, s32))func_80149350)(param_1, (s32)&in, (s32)out); + *(s16 *)(param_1 + 0x6) = out[0]; + *(s16 *)(param_1 + 0xa) = out[1]; + *(s16 *)(param_1 + 0xe) = out[2]; + } + + if (0x80 < *(s16 *)(psVar6 + 0x188)) { + *(s16 *)(psVar6 + 0x188) = 0x80; + } + if (*(s16 *)(psVar6 + 0x188) >= 0x80) { + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0xe); + func_8014C4AC(iVar7, 0xe, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + func_80146994(0x33, param_1, 0, iVar7); + } + } else { + if (*(s16 *)(psVar6 + 0x18a) < 0x80 && *(u16 *)psVar6 != 0x19) { + goto LAB_end; + } + iVar7 = *(s32 *)(psVar6 + 0x184); + if (iVar7 != 0) { + func_80015978(iVar7 + 4, (s32 *)buf); + buf[3] = 0; + uVar4 = func_80156370(0x21); + func_8014C4AC(iVar7, 0x21, uVar4, buf, *(s16 *)(iVar8 + 0x12)); + if ((*(s32 *)(iVar7 + 0xb4) & 0x40000) != 0) { + func_8014AD30(param_1, (u16 *)buf, 0, *(s16 *)(iVar7 + 0x60)); + } + } + } + + uVar5 = func_8014CA00(iVar7); + *(s32 *)(psVar6 + 0x184) = uVar5; + if (0x1e < (u32)uVar5) { + *(s32 *)(psVar6 + 0x184) = 0; + } + func_80146E90((s32 *)param_1, 0x20); + *(s32 *)(psVar6 + 0x44) = *(s32 *)(psVar6 + 0x44) & ~0x20; + func_80147324(0x449); + func_80146CA0((void *)param_1); + func_80146CA0((void *)param_1); + +LAB_end: + uVar4 = func_80012F74(*(s16 *)(iVar8 + 0x1a), 0x1800, 3, 1); + *(s16 *)(iVar8 + 0x1a) = uVar4; + *(s16 *)(iVar8 + 0x18) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0x6), *(s16 *)(param_1 + 0x58), 8, 1); + *(s16 *)(param_1 + 0x6) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xa), *(s16 *)(param_1 + 0x5a), 8, 1); + *(s16 *)(param_1 + 0xa) = uVar4; + uVar4 = func_80012F74(*(s16 *)(param_1 + 0xe), *(s16 *)(param_1 + 0x5c), 8, 1); + *(s16 *)(param_1 + 0xe) = uVar4; +} + + +DEFINE_func_80164270() /* dedup: shared engine-core @0x80164270 (src/shared) */ + +DEFINE_func_801642AC() /* dedup: shared engine-core @0x801642AC (src/shared) */ + +DEFINE_func_8016432C() /* dedup: shared engine-core @0x8016432C (src/shared) */ + +DEFINE_func_80164410() /* dedup: shared engine-core @0x80164410 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80164418); + +DEFINE_func_80164530() /* dedup: shared engine-core @0x80164530 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH expected (fn-ptr table dispatch via u16 idx, $s0 holds *(s32*)(p+0x20) across the call) + +extern void (*D_80187A9C[])(void); +extern void func_80162D28(s32 *a0); + +void func_80164744(s32 param_1) +{ + s32 iVar1; + + iVar1 = *(s32 *)(param_1 + 0x20); + D_80187A9C[*(u16 *)(param_1 + 2)](); + if (iVar1 != 0) { + ((void (*)(s32))func_80162D28)(param_1); + } +} + + + + +// @class: other +// @stuck: none — MATCH (relocation-masked); key was `if (iVar1 != 0) { big } else { func_80164930 }` (non-zero case first → beqz, not bnez) + + +extern void func_8014659C(void); +extern void func_8001C810(s32 a0, s32 a1); +extern void func_80164A74(s32 *a0); +extern void func_80146CA0(void *a0); +extern void func_80164930(s32 a); + +extern u16 D_800DF2E0; +extern s32 D_80187A64; +extern s16 D_80187A98; +extern s16 D_80187A96; +extern s16 D_80187A94; + +void func_801647A4(int param_1) { + s32 iVar1; + + iVar1 = ((s32 (*)(void))func_8014659C)(); + *(s32 *)(param_1 + 0x20) = iVar1; + if (iVar1 != 0) { + ((void (*)(s32, void *))func_8001C810)(iVar1, &D_800DF2E0); + *(s32 **)(iVar1 + 0x80) = &D_80187A64; + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + *(u16 *)(iVar1 + 0x2c) = *(u16 *)(iVar1 + 0x2c) | 0xb0; + D_80187A98 = 0x80; + D_80187A96 = 0x80; + D_80187A94 = 0x80; + *(u16 *)(iVar1 + 0x1a) = 0; + *(u16 *)(param_1 + 0x60) = 0; + *(u16 *)(param_1 + 0x62) = 0x200; + ((s32 (*)(s32))func_80164A74)(param_1); + ((void (*)(s32))func_80146CA0)(param_1); + } else { + func_80164930(param_1); + } +} + + +DEFINE_func_80164864() /* dedup: shared engine-core @0x80164864 (src/shared) */ + +// @class: regalloc-order — wave-3 real-TU crack (§42a); cracked at Max. +// Fix: D_80187A98 read needs direct-addressed `lhu` (u16). Cannot use `*(u16*)&D_80187A98` +// (forces &sym into a held reg -> drift) NOR a block-scoped `extern u16` (conflicting-types +// ERROR vs the ambient s16, cc1 exit 33). Solution: flip the file-scope decl (5802) to u16 — +// byte-neutral to the only other user (func_801647A4 store-only) — and reference directly. +typedef struct { + u16 f0; + u8 pad0[0x4e]; + int f50; + u8 pad1[0x14]; +} Ent_80164930_80164930; + + +void func_80164930(s32 param_1) { + int iVar3 = *(int *)(((int)param_1) + 0x20); + if (*(int *)(((int)param_1) + 0x50) == 0) { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x100; + short nv; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) + 0x71; + nv = D_80187A98 - 8; + D_80187A98 = nv; + D_80187A96 = nv; + D_80187A94 = nv; + if (nv < -0x80) { + int i, lim; + Ent_80164930_80164930 *p; + for (i = 0, lim = 0x19, p = ((Ent_80164930_80164930 *)&D_8011F9D0); i < 0x14; i++) { + if (p->f0 == lim && p->f50 != 0) { + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)(p); + } + p++; + } + ((void(*)(Ent_80164930_80164930 *))func_80162CCC)((Ent_80164930_80164930 *)((int)param_1)); + } else { + ((void(*)(int))func_80164ACC)(((int)param_1)); + } + } else { + short sVar1 = *(u16 *)(iVar3 + 0x1c) + 0x40; + u16 uVar2; + *(short *)(iVar3 + 0x1c) = sVar1; + *(short *)(iVar3 + 0x18) = sVar1; + uVar2 = *(u16 *)(iVar3 + 0x1a) - 0x200; + *(u16 *)(iVar3 + 0x1a) = uVar2; + if ((int)((unsigned)uVar2 << 0x10) < 0) { + *(short *)(iVar3 + 0x1a) = 0; + } + *(short *)(iVar3 + 0x12) = *(u16 *)(iVar3 + 0x12) - 0x71; + } +} + + + +DEFINE_func_80164A74() /* dedup: shared engine-core @0x80164A74 (src/shared) */ + +DEFINE_func_80164ACC() /* dedup: shared engine-core @0x80164ACC (src/shared) */ + + +extern void (*D_80187AA8[])(void); + +void func_80164BA0(void *a0) { + D_80187AA8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void func_80146578(void); +extern void func_8001CD50(s32 a0, s32 a1); +extern void func_800233CC(void *, unsigned short); +extern void func_80164DD0(s32 a0); +extern void func_80146CA0(void *a0); +extern void func_80164DB0(void); + +extern u8 D_8019E598; +extern u8 D_8019E599; +extern u8 D_8019E59A; +extern u8 D_8019E59B; +extern u8 D_8019E59C; +extern u8 D_8019E59D; +extern u8 D_8019E59E; +extern u8 D_8019E59F; + +void func_80164BDC(s32 param_1) +{ + register s32 p1 __asm__("$17"); /* $s1 */ + register s32 iVar1 __asm__("$16"); /* $s0 */ + register s32 base __asm__("$18"); /* $s2 */ + + p1 = param_1; + iVar1 = ((s32 (*)(void))func_80146578)(); + base = (s32)&D_8019E598; + *(s32 *)(p1 + 0x20) = iVar1; + if (iVar1 != 0) { + func_8001CD50(iVar1, base); + ((void (*)(s32, s32))func_800233CC)(base, 0x60); + *(u32 *)(iVar1 + 4) = *(u32 *)(iVar1 + 4) | 0x50000000; + D_8019E599 = 0xf0; + *(u8 *)base = 0xf0; + D_8019E59A = 0xc0; + D_8019E59E = 0; + D_8019E59D = 0; + D_8019E59C = 0; + D_8019E59F = 0; + D_8019E59B = 0; + *(s16 *)(iVar1 + 0x1e) = 0xccc; + *(s16 *)(iVar1 + 0x10) = 0x400; + *(s16 *)(p1 + 0x60) = 0x700; + *(s16 *)(p1 + 0x62) = -0x60; + func_80164DD0(p1); + ((void (*)(s32))func_80146CA0)(p1); + } else { + ((void (*)(s32))func_80164DB0)(p1); + } +} + + +DEFINE_func_80164CD4() /* dedup: shared engine-core @0x80164CD4 (src/shared) */ + +DEFINE_func_80164D4C() /* dedup: shared engine-core @0x80164D4C (src/shared) */ + +DEFINE_func_80164DB0() /* dedup: shared engine-core @0x80164DB0 (src/shared) */ + +DEFINE_func_80164DD0() /* dedup: shared engine-core @0x80164DD0 (src/shared) */ + + + + + +extern u8 D_8019E598; +extern u8 D_8019E599; +extern u8 D_8019E59A; + +s32 func_80164E40(void) { + u8 *p = &D_8019E598; + if (*p != 0) { + *p -= 0x10; + } + if (D_8019E599 != 0) { + D_8019E599 -= 0x10; + } + if (D_8019E59A != 0) { + D_8019E59A -= 0x10; + } + return *(s32 *)p == 0; +} + + + +extern void (*D_80187AB8[])(void); + +void func_80164EA4(void *a0) { + D_80187AB8[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: struct +// @stuck: none — MATCH + + /* stride 0x10 */ +extern DStruct D_8019E5E4[]; + +extern void func_80165124(void *a0); +extern void func_80146CA0(void *a0); + +void func_80164EE0(int param_1) +{ + int i; + + for (i = 7; i >= 0; i--) { + D_8019E5E4[i].f0 = 0; + } + *(short *)(param_1 + 0x2e) = 0x4000; + *(short *)(param_1 + 0x2c) = 0x4000; + *(short *)(param_1 + 0x60) = 0; + *(short *)(param_1 + 0x62) = 0; + ((void (*)(int))func_80165124)(param_1); + *(short *)(param_1 + 0x66) = 0; + ((void (*)(int))func_80146CA0)(param_1); +} + + +DEFINE_func_80164F44() /* dedup: shared engine-core @0x80164F44 (src/shared) */ + +DEFINE_func_80165024() /* dedup: shared engine-core @0x80165024 (src/shared) */ + +DEFINE_func_80165064() /* dedup: shared engine-core @0x80165064 (src/shared) */ + +DEFINE_func_801650C4() /* dedup: shared engine-core @0x801650C4 (src/shared) */ + +DEFINE_func_80165124() /* dedup: shared engine-core @0x80165124 (src/shared) */ + +// @class: struct +// @stuck: none — MATCH (30 ins) +// +// Unaligned slot-fill: loop over 8 slots (0x10 stride) of a global table, +// fill the first free one (field @0xC == 0). Two unaligned block copies from +// param_1 (packed struct assigns -> lwl/lwr/swl/swr). Key: recompute +// p = &D_8019E5D8[i] each iteration (NOT p++) so gcc reduces base+i*0x10 into +// a SINGLE pointer IV with immediate offsets 0/8/0xC. Hand-incrementing p makes +// combine_givs split the field offsets into a second pointer IV (+2 ins). + + +typedef struct { u8 d[8]; } __attribute__((packed, aligned(1))) B8_80165140; +typedef struct { u8 d[4]; } __attribute__((packed, aligned(1))) B4_80165140; +typedef struct { B8_80165140 a; B4_80165140 b; s32 used; } Slot_80165140; + + +s32 func_80165140(s32 param_1) { + extern Slot_80165140 D_8019E5D8[8]; + + int i; + Slot_80165140 *p; + for (i = 0; i < 8; i++) { + p = &D_8019E5D8[i]; + if (p->used == 0) { + p->used = 8; + p->a = *(B8_80165140 *)(((u8 *)param_1) + 0x2c); + p->b = *(B4_80165140 *)(((u8 *)param_1) + 0x50); + return; + } + } +} + + + + +// @class: schedule +// @stuck: none — MATCH (pins $s2/$s1/$s0 + zero-code barrier hoists $a0 copy into beqz delay slot) + +extern void func_80165240(void *param_1, void *param_2, void *param_3); +extern s32 D_8019E5D8; + +void func_801651B8(void * param_1) +{ + register s32 *puVar1 __asm__("$16"); /* $s0 */ + register s32 iVar2 __asm__("$17"); /* $s1 */ + register s32 p __asm__("$18"); /* $s2 */ + + p = param_1; + ((s32 (*)(s32, s32, s32))func_80165240)(p, p + 0x2c, p + 0x50); + iVar2 = 0; + puVar1 = &D_8019E5D8; + do { + if (puVar1[3] != 0) { + s32 a0v = p; + __asm__ __volatile__("" : "=r"(a0v) : "0"(a0v)); + ((s32 (*)(s32, s32, s32))func_80165240)(a0v, (s32)puVar1, (s32)(puVar1 + 2)); + puVar1[3] = puVar1[3] + -1; + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 4; + } while (iVar2 < 8); +} + + +struct W4 { u32 w; } __attribute__((packed, aligned(1))); +extern void func_80016ED4(void *a0); +extern s32 func_80017DC4(void *a0, void *a1); + +void func_80165240(void *param_1, void *param_2, void *param_3) +{ + + extern u8 D_80187ACC[]; + extern u32 D_80187AEC, D_80187AF0, D_80187AF4, D_80187AF8; + extern u32 D_80187AEC, D_80187AF0, D_80187AF4, D_80187AF8; + extern u32 D_80187AEC, D_80187AF0, D_80187AF4, D_80187AF8; + extern u32 D_80187AEC, D_80187AF0, D_80187AF4, D_80187AF8; + u8 prim[0x40]; /* $sp+0x10 .. 0x50 */ + u8 mat[0x20]; /* $sp+0x50 .. 0x70 */ + u8 *p = prim; + + func_80017DC4(param_2, mat); + ApplyMatrixSV(mat, &D_80187ACC[0x00], p); + ApplyMatrixSV(mat, &D_80187ACC[0x08], prim + 0x08); + ApplyMatrixSV(mat, &D_80187ACC[0x10], prim + 0x10); + ApplyMatrixSV(mat, &D_80187ACC[0x18], prim + 0x18); + + *(s16 *)(prim + 0x04) = 3; + prim[0x38] = 0x2c; + *(u32 *)(prim + 0x20) = D_80187AF4; + *(u32 *)(prim + 0x24) = D_80187AEC; + *(u32 *)(prim + 0x28) = D_80187AF8; + *(u32 *)(prim + 0x2c) = D_80187AF0; + *(struct W4 *)(prim + 0x30) = *(struct W4 *)param_3; + *(u32 *)(prim + 0x34) = 0x50000000; + + func_80016ED4(p); +} + + +DEFINE_func_8016533C() /* dedup: shared engine-core @0x8016533C (src/shared) */ + +DEFINE_func_80165374() /* dedup: shared engine-core @0x80165374 (src/shared) */ + +DEFINE_func_801653B8() /* dedup: shared engine-core @0x801653B8 (src/shared) */ + +DEFINE_func_801653F4() /* dedup: shared engine-core @0x801653F4 (src/shared) */ + + +// @class: struct +// @stuck: none — MATCH (54 ins) + +extern u8 D_80078E78[]; +extern u8 D_80078EC1; +extern void (*D_80187AFC[])(void); +extern u8 func_80165658(s32 a0, s32 a1); +extern void func_800CAE0C(s32 a0); + +void func_801654A8(s32 arg0) +{ + u8 *s1 = D_80078E78; + + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 != 0x1A) { + if ((*(s32 *)(arg0 + 0x1F8) & 0x80FFFFFF) == 0) { + if (func_80165658(arg0, D_80078EC1) & 0x80) { + ((void (*)(s32))D_80187AFC[D_80078EC1 & 0x7F])(arg0); + } + } + } + if (*(u16 *)arg0 == 0x16) { + return; + } + if (*(u16 *)arg0 == 0x1A) { + return; + } + if (s1[0x49] == 0x19) { + func_800CAE0C(arg0); + } +} + + + +// @class: struct +// @stuck: none — MATCH (function-pointer-array dispatch; & 0x80 branch + & 0x7f index fold) + +extern u8 D_80078EC5; +extern u8 D_80078EC1; +extern void (*D_80187AFC[])(void); +extern void func_80165B28(void *a0); + +void func_80165580(s32 _arg0) +{ + if (D_80078EC5 & 0x80) { + ((void (*)(void))func_80165B28)(); + } else { + D_80187AFC[D_80078EC1 & 0x7F](); + } +} + + +DEFINE_func_801655E4() /* dedup: shared engine-core @0x801655E4 (src/shared) */ + +DEFINE_func_80165624() /* dedup: shared engine-core @0x80165624 (src/shared) */ + + +extern u8 D_80187B78[]; + +u8 func_80165658(s32 a0, s32 a1) { + return D_80187B78[a1 & 0x7F]; +} + + + +extern s32 D_80187B98[]; +extern s32 D_80078EC8; + +void func_80165670(s32 a0, s32 a1) { + D_80078EC8 = D_80187B98[a1 & 0x7F]; +} + + +DEFINE_func_80165694() /* dedup: shared engine-core @0x80165694 (src/shared) */ + + +extern u8 D_80187C14[]; + +u8 func_801656D0(s32 a0, s32 a1) { + return D_80187C14[a1 & 0x7F]; +} + + + +extern u8 D_80187C34[]; + +u8 func_801656E8(s32 a0, s32 a1) { + return D_80187C34[a1 & 0x7F]; +} + + + +extern u8 D_80187C54[]; + +u8 func_80165700(s32 a0, s32 a1) { + return D_80187C54[a1 & 0x7F]; +} + + +DEFINE_func_80165718() /* dedup: shared engine-core @0x80165718 (src/shared) */ + +DEFINE_func_80165770() /* dedup: shared engine-core @0x80165770 (src/shared) */ + +DEFINE_func_801657A0() /* dedup: shared engine-core @0x801657A0 (src/shared) */ + +DEFINE_func_801657D8() /* dedup: shared engine-core @0x801657D8 (src/shared) */ + +DEFINE_func_80165840() /* dedup: shared engine-core @0x80165840 (src/shared) */ + +DEFINE_func_80165874() /* dedup: shared engine-core @0x80165874 (src/shared) */ + +DEFINE_func_801658DC() /* dedup: shared engine-core @0x801658DC (src/shared) */ + +DEFINE_func_801658EC() /* dedup: shared engine-core @0x801658EC (src/shared) */ + +DEFINE_func_80165900() /* dedup: shared engine-core @0x80165900 (src/shared) */ + +DEFINE_func_80165910() /* dedup: shared engine-core @0x80165910 (src/shared) */ + +DEFINE_func_80165938() /* dedup: shared engine-core @0x80165938 (src/shared) */ + +DEFINE_func_80165958() /* dedup: shared engine-core @0x80165958 (src/shared) */ + +DEFINE_func_80165978() /* dedup: shared engine-core @0x80165978 (src/shared) */ + +DEFINE_func_80165988() /* dedup: shared engine-core @0x80165988 (src/shared) */ + +DEFINE_func_801659A8() /* dedup: shared engine-core @0x801659A8 (src/shared) */ + +DEFINE_func_801659B8() /* dedup: shared engine-core @0x801659B8 (src/shared) */ + +DEFINE_func_801659CC() /* dedup: shared engine-core @0x801659CC (src/shared) */ + + + +s32 func_801659DC(u8 *a0) { + + extern void (*D_80187C74[])(void); + D_80187C74[*(u8 *)((s32)a0 + 0x1A0)](); +} + + +DEFINE_func_80165A18() /* dedup: shared engine-core @0x80165A18 (src/shared) */ + +DEFINE_func_80165A20() /* dedup: shared engine-core @0x80165A20 (src/shared) */ + +DEFINE_func_80165A50() /* dedup: shared engine-core @0x80165A50 (src/shared) */ + +DEFINE_func_80165A78() /* dedup: shared engine-core @0x80165A78 (src/shared) */ + + +extern u8 D_80078EC1; +extern void (*D_80187CF0[])(void); + +void func_80165AC8(void) { + D_80187CF0[D_80078EC1 & 0x7F](); +} + + +DEFINE_func_80165B08() /* dedup: shared engine-core @0x80165B08 (src/shared) */ + +DEFINE_func_80165B10() /* dedup: shared engine-core @0x80165B10 (src/shared) */ + +DEFINE_func_80165B18() /* dedup: shared engine-core @0x80165B18 (src/shared) */ + +DEFINE_func_80165B20() /* dedup: shared engine-core @0x80165B20 (src/shared) */ + + +extern void (*D_80187D6C[])(void); + +void func_80165B28(void *a0) { + *(u32 *)((s32)a0 + 0x44) |= 8; + D_80187D6C[*(u8 *)((s32)a0 + 0x197)](); +} + + +DEFINE_func_80165B6C() /* dedup: shared engine-core @0x80165B6C (src/shared) */ + +DEFINE_func_80165BB4() /* dedup: shared engine-core @0x80165BB4 (src/shared) */ + +DEFINE_func_80165BFC() /* dedup: shared engine-core @0x80165BFC (src/shared) */ + +DEFINE_func_80165C58() /* dedup: shared engine-core @0x80165C58 (src/shared) */ + +DEFINE_func_80165C78() /* dedup: shared engine-core @0x80165C78 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80165CA0); + +extern M2C_UNK D_8019DC20; + +void func_80165E2C(u16 *arg0) { + func_8001534C(0, &D_8019DC20, 0x80, 0x80, 0, 0); + func_800153CC(1, *arg0, 0xA8, 0x80, 0x40, 0); +} + + +DEFINE_func_80165E90() /* dedup: shared engine-core @0x80165E90 (src/shared) */ + +DEFINE_func_80165FA4() /* dedup: shared engine-core @0x80165FA4 (src/shared) */ + + +extern void (*D_80187D78[])(void); + +void func_80166018(void *a0) { + D_80187D78[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166054() /* dedup: shared engine-core @0x80166054 (src/shared) */ + +DEFINE_func_801661CC() /* dedup: shared engine-core @0x801661CC (src/shared) */ + +DEFINE_func_80166244() /* dedup: shared engine-core @0x80166244 (src/shared) */ + +DEFINE_func_8016629C() /* dedup: shared engine-core @0x8016629C (src/shared) */ + +DEFINE_func_801662F4() /* dedup: shared engine-core @0x801662F4 (src/shared) */ + +DEFINE_func_8016634C() /* dedup: shared engine-core @0x8016634C (src/shared) */ + +DEFINE_func_801663A4() /* dedup: shared engine-core @0x801663A4 (src/shared) */ + + +extern void (*D_80187D80[])(void); + +void func_801663FC(void *a0) { + D_80187D80[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80166438() /* dedup: shared engine-core @0x80166438 (src/shared) */ + +DEFINE_func_801665B4() /* dedup: shared engine-core @0x801665B4 (src/shared) */ + + +extern void (*D_80187E48[])(void); + +void func_80166618(void *a0) { + D_80187E48[*(u16 *)((s32)a0 + 0x2)](); +} + + + +extern void (*D_80187E58[])(void); + +void func_80166654(void *a0) { + D_80187E58[*(u16 *)((s32)a0 + 0x2)](); +} + + +#include "common.h" + +typedef struct { u16 h[6]; } Rec_80166690_80166690; /* 12-byte sub-table record (stride 0xC) */ + +typedef struct { + short v0, v1, v2, pad06, w0, w1, w2, pad0E; /* 0x00..0x0F */ + short v3, v4, v5, pad16, w3, w4, w5, pad1E; /* 0x10..0x1F */ + u8 c00, c01, c02, pad23; /* 0x20 */ + u8 c10, c11, c12, pad27; /* 0x24 */ + u8 c20, c21, c22, pad2B; /* 0x28 */ + u8 c30, c31, c32, pad2F; /* 0x2C */ + int tag; /* 0x30 -> struct size 0x34; tag lands at sp+0x40 */ +} Frame_80166690_80166690; + + +s32 func_80166690(s32 param_1, s32 param_2) +{ + extern s32 func_80017758(void *a0, void *a1); + extern Blk20 D_800AE620; + extern u8 D_8019E658[]; + + Frame_80166690_80166690 c; + Blk20 blk; + Rec_80166690_80166690 *sub; + Rec_80166690_80166690 *pv; + u8 *rec; + int i6; + int lt2; + int p2; + unsigned int uVar7, uVar8, uVar9; + int iVar3; + unsigned int w9, w7, w, t, w3b; + int w3; + short sVar10; + register unsigned int zr __asm__("$0"); + + blk = D_800AE620; + i6 = (short)param_1; + c.tag = 0x50000000; + rec = &D_8019E658[i6 * 0xC4]; + sVar10 = 0; + if (rec[0] == 0) { + return 0; + } + sub = (Rec_80166690_80166690 *)(rec + 4); + uVar9 = rec[1]; + uVar8 = rec[3]; + uVar7 = uVar8 >> 1; + iVar3 = rec[2]; + w3 = iVar3 - 1; + iVar3 = w3 + zr; + if (w3 != -1) { + lt2 = i6 < 2; + p2 = (short)param_2; + do { + pv = &sub[(short)uVar9]; + c.v0 = pv->h[0]; + c.v1 = pv->h[1]; + c.v2 = pv->h[2]; + c.w0 = pv->h[3]; + c.w1 = pv->h[4]; + c.w2 = pv->h[5]; + sVar10 = sVar10 + 1; + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c12 = t; c.c02 = t; + t = uVar7 + zr; + } else { + w = ((int)(uVar8 << 16) >> 17) + ((int)(uVar8 << 16) >> 19); + uVar7 = w + zr; + c.c12 = w; c.c02 = w; + t = uVar8 + zr; + } + c.c11 = t; c.c01 = t; c.c10 = t; c.c00 = t; + } else { + t = uVar8 + zr; + c.c10 = t; c.c00 = t; + t = uVar7 + zr; + c.c12 = t; c.c02 = t; c.c11 = t; c.c01 = t; + } + + w9 = uVar9 - 1; + uVar9 = w9 + zr; + if ((int)(w9 << 16) < 0) { + uVar9 = 0xF; + } + pv = &sub[(short)uVar9]; + c.v3 = pv->h[0]; + c.v4 = pv->h[1]; + c.v5 = pv->h[2]; + c.w3 = pv->h[3]; + c.w4 = pv->h[4]; + uVar8 = uVar8 - 0x10; + w7 = uVar7 - 0x10; + uVar7 = w7 + zr; + c.w5 = pv->h[5]; + if ((int)(w7 << 16) < 0) { + uVar7 = 0; + } + + if (lt2) { + if (p2 == 0) { + t = uVar8 + zr; + c.c32 = t; c.c22 = t; + t = uVar7 + zr; + } else { + t = uVar7 + zr; + c.c32 = t; c.c22 = t; + t = uVar8 + zr; + } + c.c31 = t; c.c21 = t; c.c30 = t; c.c20 = t; + } else { + t = uVar8 + zr; + c.c30 = t; c.c20 = t; + t = uVar7 + zr; + c.c32 = t; c.c22 = t; c.c31 = t; c.c21 = t; + } + + __asm__ __volatile__("" :: "r"(iVar3)); + func_80017758(&c, &blk); + w3b = iVar3 - 1; + iVar3 = w3b + zr; + } while ((short)w3b != -1); + } + return (short)sVar10; +} + + + + +/* func_80166994 — trail/afterimage ring recorder (0xC4-stride Trail records at D_8019E658). + * param_2: 0=init, 1=advance(record), 2=fadeout; param_3: trail index (s16); param_4: divisor (s16). + * + * K&R definition: true s16 params => callee-side lazy per-use narrow/extend with raw pseudos + * (s3/t0/s4 hold raw a1/a2/a3; first-use extension allocates IN PLACE into the arg reg), while + * the promoted K&R type (int x4) stays compatible with the canon-sig s32 prototype in the TU. + * Returns s32 (v0=1 when the fadeout completes, else 0) => the //@EDIT above flips the split's + * canon-sig prototype return type, AND engine_core.h needs the once-global ec_edit (all 5 sites, + * byte-neutral: every caller discards the result): + * ec_edit old: "extern void func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * ec_edit new: "extern s32 func_80166994(s32 a0, s32 a1, s32 a2, s32 a3); \" + * Without the ec_edit, cc1 hard-errors (conflicting types vs the void decls in DEFINE_ macros). + * + * Fully block-scoped (typedefs + externs inside the body) so the crack propagates ×134 via + * family_remap with zero file-scope footprint. No register pins. + */ +s32 func_80166994(param_1, param_2, param_3, param_4) + s32 param_1; + s16 param_2; + s16 param_3; + s16 param_4; +{ + typedef struct { s16 f0, f1, f2, f3, f4, f5; } TrailEntry; + typedef struct { u8 flag, idx, count, timer; TrailEntry e[16]; } Trail; + extern u8 D_8019E658[]; + extern void RotTransSV(void *a0, void *a1, void *a2); + extern s32 VectorNormalSS(void *a0, void *a1); + + Trail *p = &((Trail *)D_8019E658)[param_3]; + s32 uVar6 = *(s32 *)(param_1 + 0x34); + s16 v10[4]; + s16 v18[4]; + s16 v20[4]; + s16 v28[4]; + s16 out[4]; + s32 c; + + switch (param_2) { + case 0: + p->flag = 1; + p->count = 0; + p->idx = 0; + p->timer = 0xf4; + break; + case 1: + v20[0] = p->e[p->idx].f0; + v20[1] = p->e[p->idx].f1; + v20[2] = p->e[p->idx].f2; + v28[0] = p->e[p->idx].f3; + v28[1] = p->e[p->idx].f4; + v28[2] = p->e[p->idx].f5; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + break; + case 2: { + u8 bVar3 = p->timer - 0x10; + p->timer = bVar3; + if (bVar3 < 0x10) { + p->flag = 0; + return 1; + } + { + u8 bVar1 = p->count; + if (bVar1 >= 2 && (bVar3 >> 4) < bVar1) { + p->count = bVar1 - 1; + } + } + return 0; + } + } + + if (param_3 < 2) { + func_801484B0((s32)v10, (s32)v18); + } else { + func_80148534((s32)v10, (s32)v18); + } + func_80165FA4(uVar6, (s32)v10, (s32)v18); + ((void (*)(s32, s32, s32))func_80149350)(uVar6, (s32)v10, (s32)v10); + RotTransSV(v18, v18, out); + + if (param_2 != 0) { + v20[0] = (v10[0] + v20[0]) >> 1; + v20[1] = (v10[1] + v20[1]) >> 1; + v20[2] = (v10[2] + v20[2]) >> 1; + v28[0] = (v18[0] + v28[0]) >> 1; + v28[1] = (v18[1] + v28[1]) >> 1; + v28[2] = (v18[2] + v28[2]) >> 1; + v20[0] = v20[0] - v28[0]; + v20[1] = v20[1] - v28[1]; + v20[2] = v20[2] - v28[2]; + VectorNormalSS(v20, v20); + v20[0] = v28[0] + v20[0] / param_4; + v20[1] = v28[1] + v20[1] / param_4; + v20[2] = v28[2] + v20[2] / param_4; + p->e[p->idx].f0 = v20[0]; + p->e[p->idx].f1 = v20[1]; + p->e[p->idx].f2 = v20[2]; + p->e[p->idx].f3 = v28[0]; + p->e[p->idx].f4 = v28[1]; + p->e[p->idx].f5 = v28[2]; + c = p->idx; + p->idx = c + 1; + if ((u8)(c + 1) > 0xf) { + p->idx = 0; + } + if (p->count < 0xf) { + p->count = p->count + 1; + } + } + + p->e[p->idx].f0 = v10[0]; + p->e[p->idx].f1 = v10[1]; + p->e[p->idx].f2 = v10[2]; + p->e[p->idx].f3 = v18[0]; + p->e[p->idx].f4 = v18[1]; + p->e[p->idx].f5 = v18[2]; + return 0; +} + + +// @class: regalloc-order +// @stuck: none — MATCH (69 ins). Pins $s4/$s1 for param_2/param_3 + a1/a2-pinned temps +// with non-volatile SHB barriers force the sign-ext move-form; short iVar2 (unpinned) +// gives the temp-form counter increment that fills the skip-branch delay slots; +// loop-invariant eq=(p2==p3) hoisted; SHB(p2) after the move serializes param_2 before +// param_3's sign-ext (last ordering swap); param_1/param_4 left natural (arg-order saves). + + +#define SHB(x) __asm__("" : "=r"(x) : "0"(x)) + +s32 func_80166F58(s32 param_1, s32 param_2, s32 param_3, s32 param_4) +{ + extern unsigned char D_8019E658[]; + + register int p2 __asm__("$20"); /* $s4 */ + register int p3 __asm__("$17"); /* $s1 */ + register int t2 __asm__("$5"); /* a1 */ + register int t3 __asm__("$6"); /* a2 */ + unsigned short *puVar1; + short iVar2; + int eq; + + iVar2 = 0; + puVar1 = ((unsigned short *)&D_8011D030); + t2 = ((short)param_2); SHB(t2); p2 = t2; SHB(p2); + t3 = ((short)param_3); SHB(t3); p3 = t3; + eq = (p2 == p3); + do { + if ((puVar1 != ((unsigned short *)param_1)) && + ((unsigned int)*puVar1 == p2 || (unsigned int)*puVar1 == p3) && + (!eq || + *(int *)(puVar1 + 0x16) == *(int *)(((unsigned short *)param_1) + 0x16))) { + ((void(*)(unsigned short *))func_80146C3C)(puVar1); + } + iVar2 = iVar2 + 1; + puVar1 = puVar1 + 0x2c; + } while (iVar2 < 0x1e); + ((void(*)(void *, int))func_80016714)(&D_8019E658[((short)param_4) * 0xc4], 0xc4); +} + + + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_8016706C); + + +// @class: schedule +// @stuck: 16/279 masked. 3 runs, ONE residual class: gcc's list-scheduler puts `la $s2` (p=DATA) + `addu $s4,$zero,$zero` (i=0) BEFORE the callee-arg address setup (addiu $a1,$sp,0x10 / addu $a2,$a1,$zero); the target emits them AFTER. Inert to ~40 statement-order permutations + pin/barrier combos (sched priority dominates the LUID tie-break, sched.c rank_for_schedule). Runs: 19-24 (blk1), 111-114 (region-B cx-load rotation), 177-182 (blk3). Permuter fuel. + + + + +extern void func_80149350(s32); +extern void func_800D20C0(void *a0, void *a1, s32 a2); +extern void func_80017E68(void *a0, void *a1); +extern void func_800D23D0(void *a0); +extern void RotMatrixYXZ(void *a0, void *a1); +extern s32 func_80017758(void *a0, void *a1); +extern s32 func_80017DC4(void *a0, void *a1); +extern void func_80048EAC(void *a0, void *a1); + + +s32 func_801670E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + + extern u8 D_80187D9C[]; + extern u8 D_80187D88[]; + extern u8 D_80187DB0[]; + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80126CE0; + Fr_801670E4 f; + register u8 *p __asm__("$18"); /* $s2 */ + register s32 ent __asm__("$19"); /* $s3 */ + s16 i; + s32 d; + s32 node; + u16 c; + u8 cv; + u8 cv2; + register s32 gA __asm__("$2"); + register s32 cxv __asm__("$4"); + register s32 czv __asm__("$5"); + u8 *vc; + u8 *ap; + u8 *mp; + u8 *va; + u8 *vb; + + ent = arg0; + node = *(s32 *)(ent + 0x34); + f.v[1].z = 0; + f.v[1].y = 0; + f.v[1].x = 0; + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + f.col[1].b = 0x70; + cv = *(u8 *)(ent + 0x12); + f.cx = arg1; + __asm__ __volatile__(""); + va = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(va) : "0"(va)); + f.cy = arg2; + vb = va; + __asm__ __volatile__("" : "=r"(vb) : "0"(vb)); + p = D_80187D9C; + i = 0; + f.col[0].b = 0; + f.col[0].g = 0; + f.col[0].r = 0; + f.col[2].b = 0; + f.col[2].g = 0; + f.col[2].r = 0; + f.col[3].b = 0; + f.col[3].g = 0; + f.col[3].r = 0; + f.code = 0x50000000; + f.cz = arg3; + f.col[1].r = cv; + f.col[1].g = cv; + ((void (*)(s32, void *, void *))func_80149350)(node, va, vb); + + c = f.cx; + *(s16 *)(ent + 0x06) = c; + *(s32 *)(ent + 0x4C) = (s16)c; + c = f.cy; + *(s16 *)(ent + 0x0A) = c; + *(s32 *)(ent + 0x50) = (s16)c; + c = f.cz; + *(s16 *)(ent + 0x0E) = c; + *(s32 *)(ent + 0x54) = (s16)c; + func_800D20C0(&f.cx, f.a8, 7); + func_80017E68(&f.cx, f.m1); + func_800D23D0(f.a8); + RotMatrixYXZ(f.a8, f.m1); + + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 4); + + p = D_80187D88; + gA = 0xA0; + cxv = (s16)f.cx; + f.col[1].g = gA; + gA = D_801269A4; + czv = (s16)f.cz; + f.col[1].b = 0x10; + f.col[1].r = 0x10; + f.pos[0] = gA - cxv; + i = 0; + f.v[3].y = 0; + f.v[2].y = 0; + f.v[0].y = 0; + f.pos[1] = D_801269A8 - (s16)f.cy; + f.pos[2] = D_801269AC - czv; + + do { + f.v[0].x = (s8)*p++; + f.v[0].z = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].z = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].z = (s8)*p--; + func_80017758(f.v, (void *)(ent + 0x38)); + } while ((i = i + 1) < 4); + + if (*(s32 *)(ent + 0x30) > 0) { + vc = (u8 *)&f.cx; + __asm__ __volatile__("" : "=r"(vc) : "0"(vc)); + mp = f.m1; + ap = mp; + __asm__ __volatile__("" : "=r"(ap) : "0"(ap)); + p = D_80187DB0; + i = 0; + d = (s16)f.a8[0] >> 6; + f.cx += d; + f.cy += d; + f.cz += d; + func_80017E68(vc, ap); + f.cx = f.cy = f.cz = ((u32)*(s32 *)(ent + 0x30) >> 1) + D_80126CE0 * 0x20; + func_80017DC4(&f.cx, f.m2); + func_80048EAC(f.m2, mp); + f.v[3].z = 0; + f.v[2].z = 0; + f.v[0].z = 0; + cv2 = *(u8 *)(ent + 0x12); + f.col[1].b = 0x20; + f.col[1].r = 0x20; + f.col[3].b = 0; + f.col[3].r = 0; + f.col[2].b = 0; + f.col[2].r = 0; + f.col[0].b = 0; + f.col[0].r = 0; + f.col[3].g = 0; + f.col[2].g = 0; + f.col[0].g = 0; + f.col[1].g = cv2 + 0x60; + do { + f.v[0].x = (s8)*p++; + f.v[0].y = (s8)*p++; + f.v[2].x = (s8)*p++; + f.v[2].y = (s8)*p++; + f.v[3].x = (s8)*p++; + f.v[3].y = (s8)*p--; + func_80017758(f.v, f.m1); + } while ((i = i + 1) < 8); + } +} + + + +typedef struct { s32 m[8]; } Mat_80167540; /* 0x20 bytes */ + +struct Src_80167540 { + u8 pad0[0x34]; + Mat_80167540 mat; /* 0x34 */ +}; + +struct Sub2_80167540 { + u8 pad0[0x44]; + s32 unk44; /* 0x44 */ +}; + +struct Node_80167540 { + /* 0x0 */ u16 unk0; + u8 pad2[0x4]; + /* 0x6 */ s16 unk6; + u8 pad8[0x2]; + /* 0xA */ s16 unkA; + u8 padC[0x2]; + /* 0xE */ s16 unkE; + u8 pad10[0x10]; + /* 0x20 */ struct Src_80167540 *unk20; + u8 pad24[0x28]; + /* 0x4C */ struct Sub2_80167540 *unk4C; +}; + +struct Entity_80167540 { + /* 0x0 */ s16 unk0; + /* 0x2 */ u16 unk2; + u8 pad4[0xC]; + /* 0x10 */ s16 unk10; + /* 0x12 */ s16 unk12; + u8 pad14[0x8]; + /* 0x1C */ s32 unk1C; + u8 pad20[0x10]; + /* 0x30 */ s32 unk30; + /* 0x34 */ struct Node_80167540 *unk34; + /* 0x38 */ Mat_80167540 mat; +}; + + +s32 func_80167540(s32 arg0) { + + struct Node_80167540 *node; + struct Entity_80167540 *ent; + s32 v; + + node = ((struct Entity_80167540 *)arg0)->unk34; + if (node->unk0 == 1) { + if (((struct Entity_80167540 *)arg0)->unk12 > ((struct Entity_80167540 *)arg0)->unk10) { + if (((struct Entity_80167540 *)arg0)->unk1C > 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) (rand() & 0x30); + v = -0x30; + goto shared; + } + } else if (((struct Entity_80167540 *)arg0)->unk1C < 0) { + ((struct Entity_80167540 *)arg0)->unk10 = (s16) ((rand() & 0x30) + 0x40); + v = 0x30; +shared: + ((struct Entity_80167540 *)arg0)->unk1C = v; + } + ((struct Entity_80167540 *)arg0)->unk12 = (s16) (((struct Entity_80167540 *)arg0)->unk12 + ((struct Entity_80167540 *)arg0)->unk1C); + ((struct Entity_80167540 *)arg0)->mat = node->unk20->mat; + ((void (*)(struct Entity_80167540 *, s32, s32, s32))func_801670E4)(((struct Entity_80167540 *)arg0), 0, 0, 0); + ent = ((struct Entity_80167540 *(*)(s32, struct Entity_80167540 *, s16, s16, s32, s32, s32))func_80146A6C)(0xE, ((struct Entity_80167540 *)arg0), node->unk6, node->unkA, node->unkE, 0, 0); + if (ent != 0) { + ent->mat = node->unk20->mat; + } + if (((struct Entity_80167540 *)arg0)->unk34->unk4C->unk44 & 0x20) { + ((struct Entity_80167540 *)arg0)->unk30 = 0x600; + ((struct Entity_80167540 *)arg0)->unk2 = (u16) (((struct Entity_80167540 *)arg0)->unk2 + 1); + } + } else { + ((void(*)(struct Entity_80167540 *))func_80146C3C)(((struct Entity_80167540 *)arg0)); + } +} + + + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80167714); + + +extern void (*D_80187E68[])(void); + +void func_801678B4(void *a0) { + D_80187E68[*(u16 *)((s32)a0 + 0x2)](); +} + + + +DEFINE_func_801678F0() /* dedup: shared engine-core @0x801678F0 (src/shared) */ + + + +extern void (*D_80187E74[])(void); + +void func_80167A9C(void *a0) { + D_80187E74[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80167AD8() /* dedup: shared engine-core @0x80167AD8 (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH expected; mirrors already-matched sibling func_8016A290 (same 3-loop tail), swapping the inline matrix-setup for a func_80168070 call + constant color block. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_80167AE0; + +struct Fr_80167AE0 { + u8 matrix[0x20]; /* 0x00 -> sp+0x10 */ + SVEC_80167AE0 v[4]; /* 0x20 -> sp+0x30 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x40 -> sp+0x50 */ + u32 code; /* 0x50 -> sp+0x60 */ +}; + +s32 func_80167AE0(s32 param_1, s32 param_2, s32 param_3) { + extern void func_80168070(s32 param_1, s16 *param_2, s16 *param_3, void *param_4); + extern s32 func_80017758(void *a0, void *a1); + extern u8 D_80187F80; + extern u8 D_80187F94[]; + + struct Fr_80167AE0 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + + func_80168070(param_1, ((s16 *)param_2), ((s16 *)param_3), fr.matrix); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = 0xa0; + } else if (flags & 2) { + fr.col[1].r = 0xc0; + } else { + fr.col[1].r = 0x80; + } + + p = ((u8 *)&D_80187F80); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 2; + fr.col[1].g = fr.col[1].r >> 2; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187F94; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.matrix); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.matrix); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +// @class: schedule +// @stuck: none — MATCH. The between-loops f1/f2 store-swap (0x55/0x56) is fixed by writing f2's assign first, then the chained `buf[0x44] = buf[0x45] = buf[0x45] << 1;` — the chain keeps f1's read first (read order fixed by -0x12 in $v0) while emitting f2's store (0x56) ahead of the f1/f0 pair (0x55,0x54). 173/173. + +extern void func_80168070(s32 a0, s16 *a1, s16 *a2, void *a3); +extern u16 D_800B99DA; +extern u8 D_80187DD4[]; +extern u8 D_80187DE8[]; + +s32 func_80167DBC(s32 arg0, s32 arg1, s32 arg2) { + u8 buf[0x54]; + u8 *p; + s16 i; + + func_80168070(arg0, ((s16 *)arg1), ((s16 *)arg2), buf); + + *(s16 *)(buf + 0x3C) = 0; + *(s16 *)(buf + 0x34) = 0; + *(s16 *)(buf + 0x24) = 0; + *(s16 *)(buf + 0x2C) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + if (D_800B99DA & 1) { + buf[0x46] = 0x58; + } else { + buf[0x46] = 0x48; + } + buf[0x45] = buf[0x46] >> 2; + buf[0x44] = buf[0x45]; + if (((u8 (*)(s32))func_80029178)(0x81) != 0) { + buf[0x45] = buf[0x45] << 2; + buf[0x46] = buf[0x46] >> 1; + } + + p = D_80187DD4; + buf[0x42] = 0; + buf[0x41] = 0; + buf[0x40] = 0; + buf[0x4A] = 0; + buf[0x49] = 0; + buf[0x48] = 0; + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = 0; + *(s32 *)(buf + 0x50) = 0x50000000; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x22) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x32) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3A) = (s8)*p--; + func_80017758(buf + 0x20, buf); + } + + p = D_80187DE8; + *(s16 *)(buf + 0x2C) = -0x12; + *(s16 *)(buf + 0x3A) = 0; + *(s16 *)(buf + 0x32) = 0; + *(s16 *)(buf + 0x22) = 0; + *(s16 *)(buf + 0x2A) = 0; + *(s16 *)(buf + 0x28) = 0; + buf[0x46] = buf[0x46] << 1; + buf[0x44] = buf[0x45] = buf[0x45] << 1; + + for (i = 0; i < 4; i++) { + *(s16 *)(buf + 0x20) = (s8)*p++; + *(s16 *)(buf + 0x24) = (s8)*p++; + *(s16 *)(buf + 0x30) = (s8)*p++; + *(s16 *)(buf + 0x34) = (s8)*p++; + *(s16 *)(buf + 0x38) = (s8)*p++; + *(s16 *)(buf + 0x3C) = (s8)*p--; + if (i == 2) { + buf[0x4E] = buf[0x46]; + buf[0x4D] = buf[0x44]; + buf[0x4C] = buf[0x4D]; + } else if (i == 3) { + buf[0x4E] = 0; + buf[0x4D] = 0; + buf[0x4C] = buf[0x4D]; + buf[0x42] = buf[0x46]; + buf[0x41] = buf[0x44]; + buf[0x40] = buf[0x44]; + } + func_80017758(buf + 0x20, buf); + } +} + + +DEFINE_func_80168070() /* dedup: shared engine-core @0x80168070 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_801681FC); + +DEFINE_func_8016829C() /* dedup: shared engine-core @0x8016829C (src/shared) */ + +DEFINE_func_80168328() /* dedup: shared engine-core @0x80168328 (src/shared) */ + +DEFINE_func_801683D8() /* dedup: shared engine-core @0x801683D8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80168430); + +DEFINE_func_801684B4() /* dedup: shared engine-core @0x801684B4 (src/shared) */ + +DEFINE_func_80168540() /* dedup: shared engine-core @0x80168540 (src/shared) */ + +DEFINE_func_801685EC() /* dedup: shared engine-core @0x801685EC (src/shared) */ + +DEFINE_func_80168640() /* dedup: shared engine-core @0x80168640 (src/shared) */ + +DEFINE_func_80168664() /* dedup: shared engine-core @0x80168664 (src/shared) */ + + +extern void (*D_80187E8C[])(void); + +void func_80168744(void *a0) { + D_80187E8C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168780() /* dedup: shared engine-core @0x80168780 (src/shared) */ + +DEFINE_func_801687CC() /* dedup: shared engine-core @0x801687CC (src/shared) */ + +// @class: decl-conflict (reconcile) — MATCH (108 ins), real-TU verified via rtu_match +// @crack: The wave-2 "8-residual SCHEDULE" note was a STALE-OBJECT / isolation phantom (§42b): +// in the real TU the draft NOCOMPILEs — DEFINE_func_801687CC() (split line ~6757) expands +// `extern void func_80168828(void);` right before the def, so `void func_80168828(s32 param_1)` +// is a HARD `conflicting types` error (cc1 exit 33). RECONCILE-FIRST fix (sweep-safe, lives +// entirely in the def — no //@EDIT, no macro edit): declare the fn `(void)` and capture a0 via +// register s32 a0v __asm__("$4"); s32 param_1 = a0v; +// The register-var binds incoming $a0; copying it into a NORMAL pseudo (live across the calls) +// makes gcc allocate param_1 to a callee-saved reg, emitting the target's `addu $s1,$a0,$zero` +// at idx2. NOTE: a DIRECT `register s32 param_1 __asm__("$4")` FAILS (param_1 stays in the +// call-clobbered $a0 → 100-off). With this reconcile, gcc's natural schedule places the CSE'd +// `li $v1,0x40` at idx15 with ZERO extra levers — the §42a lever-4 consumer-block reorder was +// never needed. The $v1 pin (register c40 __asm__("$3")) is still load-bearing (else 0x40 folds +// to a $v0 immediate). 134-overlay family exemplar: only D_80187E7C differs -> banks x134. +#include "common.h" + +typedef struct { + u16 f00, f02, f04, f06; + s16 f08; + u16 f0a, f0c, f0e, f10, f12, f14, f16; + u8 f18, f19, f1a, f1b, f1c, f1d, f1e, f1f, f20, f21, f22, f23; + u32 f24; +} Thing_80168828_80168828; + + +void func_80168828() +{ + extern s32 func_80017DC4(void *a0, void *a1); + extern void func_80049CAC(s32 a0, s32 a1); + extern void func_800173BC(void *a0, void *a1); + extern u16 D_80187E7C[]; + + + register s32 a0v __asm__("$4"); + s32 param_1 = a0v; + Thing_80168828_80168828 thing; + s16 matA[16]; + s16 matB[16]; + s16 svec[4]; + u16 *p; + short i; + register s32 c40 __asm__("$3"); /* $v1: hold the CSE'd 0x40 (else gcc folds to $v0 immediate) */ + + c40 = 0x40; + thing.f04 = 2; + thing.f0c = 0x24; + thing.f14 = 0x28; + thing.f08 = -3; + thing.f10 = 3; + thing.f02 = 0; + thing.f00 = 0; + thing.f12 = 0; + thing.f0a = 0; + thing.f18 = c40; + thing.f19 = c40; + thing.f22 = c40; + thing.f1e = c40; + thing.f1a = 0x10; + thing.f20 = 0xff; + thing.f1c = 0xff; + thing.f21 = 0xc0; + thing.f1d = 0xc0; + thing.f24 = 0x50000000; + + svec[0] = *(u16 *)(param_1 + 6); + svec[1] = *(u16 *)(param_1 + 0xA); + svec[2] = *(u16 *)(param_1 + 0xE); + func_80017E68(svec, matA); + + svec[0] = svec[1] = svec[2] = (*(s32 *)(param_1 + 0x1C) << 11) + 0x1000; + ((void (*)(void *, void *))func_80017DC4)(svec, matA); + + svec[0] = *(u16 *)(param_1 + 0x12); + svec[1] = *(u16 *)(param_1 + 0x16); + svec[2] = *(u16 *)(param_1 + 0x1A); + RotMatrixYXZ(svec, matB); + + func_80048EAC(matA, matB); + + svec[1] = 0; + p = D_80187E7C; + for (i = 0; i < 4; i++) { + svec[0] = *p++; + svec[2] = *p++; + ((void (*)(void *, void *))func_80049CAC)(svec, matA); + func_80048EAC(matB, matA); + func_800173BC(&thing, matA); + } +} + + + + +extern void (*D_80187E94[])(void); + +void func_801689D8(void *a0) { + D_80187E94[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168A14() /* dedup: shared engine-core @0x80168A14 (src/shared) */ + +DEFINE_func_80168A88() /* dedup: shared engine-core @0x80168A88 (src/shared) */ + + +extern void (*D_80187E9C[])(void); + +void func_80168AA8(void *a0) { + D_80187E9C[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168AE4() /* dedup: shared engine-core @0x80168AE4 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80168B70); + +DEFINE_func_80168BDC() /* dedup: shared engine-core @0x80168BDC (src/shared) */ + + +extern void (*D_80187EA4[])(void); + +void func_80168D58(void *a0) { + D_80187EA4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80168D94() /* dedup: shared engine-core @0x80168D94 (src/shared) */ + +DEFINE_func_80168EC4() /* dedup: shared engine-core @0x80168EC4 (src/shared) */ + +DEFINE_func_80168F40() /* dedup: shared engine-core @0x80168F40 (src/shared) */ + + +extern void (*D_80187EAC[])(void); + +void func_8016901C(void *a0) { + D_80187EAC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169058() /* dedup: shared engine-core @0x80169058 (src/shared) */ + +DEFINE_func_801691B8() /* dedup: shared engine-core @0x801691B8 (src/shared) */ + +INCLUDE_ASM("asm/ov_SC06_016/nonmatchings/ov_SC06_016_jr_8015C32C", func_80169228); + + +extern void (*D_80187EB4[])(void); + +void func_801693CC(void *a0) { + D_80187EB4[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_80169408() /* dedup: shared engine-core @0x80169408 (src/shared) */ + +DEFINE_func_8016951C() /* dedup: shared engine-core @0x8016951C (src/shared) */ + +DEFINE_func_80169584() /* dedup: shared engine-core @0x80169584 (src/shared) */ + +DEFINE_func_801696D8() /* dedup: shared engine-core @0x801696D8 (src/shared) */ + + +extern void (*D_80187EBC[])(void); + +void func_80169830(void *a0) { + D_80187EBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016986C() /* dedup: shared engine-core @0x8016986C (src/shared) */ + +DEFINE_func_801699D0() /* dedup: shared engine-core @0x801699D0 (src/shared) */ + +DEFINE_func_80169A4C() /* dedup: shared engine-core @0x80169A4C (src/shared) */ + + +extern void (*D_80187F70[])(void); + +void func_80169B80(void *a0) { + D_80187F70[*(u16 *)((s32)a0 + 0x2)](); +} + + + + +extern void func_800D2318(void); +extern void RotMatrixYXZ(void *a0, void *a1); +extern void ApplyMatrixSV(void *a0, void *a1, void *a2); +extern s32 func_80146A6C(s32 a0, void *a1, s32 a2, s32 a3, s32 a4, s32 a5, s32 a6); +extern s32 func_800D222C(void *a0, void *a1, s32 a2); +extern void ApplyTransposeMatrixLV(void *a0, void *a1, void *a2); +extern s32 ratan2(s32 a0, s32 a1); +extern void func_80048D9C(void *a0, void *a1); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +void func_80169BBC(s32 arg0) { + + extern s32 D_801269A4; + extern s32 D_801269A8; + extern s32 D_801269AC; + extern u16 D_80187EC4[]; + extern u8 D_80187F34[]; + extern u8 D_80187F64[]; + extern u8 D_801A0128[]; + u16 rot[4]; + s16 vec[4]; + s32 pos[4]; + s16 mtx[16]; + s32 p1; + s32 s2; + + func_800D2318(); + rot[0] = *(u16 *)(arg0 + 0x12); + rot[1] = *(u16 *)(arg0 + 0x16); + rot[2] = 0; + RotMatrixYXZ(rot, mtx); + vec[0] = 0; + vec[1] = -2; + vec[2] = -0x14; + ApplyMatrixSV(mtx, vec, vec); + *(u16 *)(arg0 + 6) = *(u16 *)(arg0 + 6) + (u16)vec[0]; + *(u16 *)(arg0 + 0xA) = *(u16 *)(arg0 + 0xA) + (u16)vec[1]; + *(u16 *)(arg0 + 0xE) = *(u16 *)(arg0 + 0xE) + (u16)vec[2]; + p1 = func_80146A6C(9, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + if (p1 != 0) { + *(u16 *)(p1 + 0x12) = rot[0]; + *(u16 *)(p1 + 0x16) = rot[1]; + *(u16 *)(p1 + 0x1A) = rot[2]; + } + func_80146A6C(0xC, (void *)arg0, *(s16 *)(arg0 + 6), *(s16 *)(arg0 + 0xA), + *(s16 *)(arg0 + 0xE), 0, 0); + s2 = func_800D222C((void *)arg0, D_80187F64, 0x17); + if (s2 != 0) { + *(s32 *)(arg0 + 0x20) = s2; + rot[0] = rot[0] + D_80187EC4[*(s32 *)(arg0 + 0x30)]; + rot[1] = rot[1] - 0x400; + RotMatrixYXZ(rot, mtx); + pos[0] = D_801269A4 - *(s16 *)(arg0 + 6); + pos[1] = D_801269A8 - *(s16 *)(arg0 + 0xA); + pos[2] = D_801269AC - *(s16 *)(arg0 + 0xE); + ApplyTransposeMatrixLV(mtx, pos, pos); + rot[2] = -ratan2(pos[0], pos[1]); + vec[0] = 0x400; + vec[1] = -0x400; + vec[2] = 0; + RotMatrixYXZ(vec, mtx); + *(s32 *)(s2 + 0x34) = (s32)D_801A0128; + RotMatrixYXZ(rot, D_801A0128); + func_80048D9C(D_801A0128, mtx); + *(u16 *)(s2 + 0x18) = 0x5000; + *(u16 *)(s2 + 0x1A) = 0x2000; + *(s32 *)(s2 + 4) = *(s32 *)(s2 + 4) | 0xC000140; + func_80128EA8(s2, arg0 + 0x24, (s32)D_80187F34); + *(u16 *)(arg0 + 2) = *(u16 *)(arg0 + 2) + 1; + } else { + ((void (*)(s32))func_80146C3C)(arg0); + } +} + + +DEFINE_func_80169E44() /* dedup: shared engine-core @0x80169E44 (src/shared) */ + + +extern void (*D_80187F78[])(void); + +void func_80169F00(void *a0) { + D_80187F78[*(u16 *)((s32)a0 + 0x2)](); +} + + + +// @class: plumbing +// @stuck: none — MATCH (expected; simple straight-line + single branch, one call-crossing local in $s0) + +extern void func_800D1FC8(s32 a0, s32 a1); +extern s32 func_800D21C4(s32 a0, void *a1, s32 a2); +extern void func_80128EA8(s32 a0, s32 a1, s32 a2); +extern void func_80146C3C(void); + +extern char D_80187F28[]; +extern char D_80187EE8[]; + +void func_80169F3C(int param_1) +{ + int iVar1; + + ((int (*)(int, int))func_800D1FC8)(param_1, 6); + iVar1 = func_800D21C4(param_1, D_80187F28, 0x16); + if (iVar1 != 0) { + *(int *)(param_1 + 0x20) = iVar1; + *(short *)(iVar1 + 0x1a) = 0x2000; + *(short *)(iVar1 + 0x18) = 0x2000; + *(char *)(iVar1 + 0x26) = 0x60; + *(char *)(iVar1 + 0x25) = 0x60; + *(char *)(iVar1 + 0x24) = 0x60; + *(unsigned int *)(iVar1 + 4) = *(unsigned int *)(iVar1 + 4) | 0x50000000; + ((void (*)(int, int, void *))func_80128EA8)(iVar1, param_1 + 0x24, D_80187EE8); + *(short *)(param_1 + 2) = *(short *)(param_1 + 2) + 1; + } else { + ((void (*)(int))func_80146C3C)(param_1); + } +} + + +DEFINE_func_80169FE0() /* dedup: shared engine-core @0x80169FE0 (src/shared) */ + + +extern void (*D_80187FB0[])(void); + +void func_8016A020(void *a0) { + D_80187FB0[*(u16 *)((s32)a0 + 0x2)](); +} + + +DEFINE_func_8016A05C() /* dedup: shared engine-core @0x8016A05C (src/shared) */ + +DEFINE_func_8016A08C() /* dedup: shared engine-core @0x8016A08C (src/shared) */ + +DEFINE_func_8016A1CC() /* dedup: shared engine-core @0x8016A1CC (src/shared) */ + +// @class: regalloc-order +// @stuck: none — MATCH (284 ins). Loop-counter biv update: pinned $v0 temp + $0-add opaque copy (i = t + zr) forces the target's 2-insn `addiu v0,s1,1; addu s1,v0,zero` and keeps CSE from rewriting the (s16)t test to read s1. + +#include "common.h" + + + +typedef struct { s16 x, y, z, pad; } SVEC_8016A290; + +struct Fr_8016A290 { + SVEC_8016A290 center; /* 0x00 -> sp+0x10 */ + SVEC_8016A290 diff; /* 0x08 -> sp+0x18 */ + s32 pos[3]; /* 0x10 -> sp+0x20 */ + s32 _pad1c; /* 0x1C -> sp+0x2C */ + s16 mtx[32]; /* 0x20 -> sp+0x30 */ + SVEC_8016A290 v[4]; /* 0x60 -> sp+0x70 */ + struct { u8 r, g, b, pad; } col[4]; /* 0x80 -> sp+0x90 */ + u32 code; /* 0x90 -> sp+0xA0 */ +}; + +void func_8016A290(s32 param_1, void *param_2, void *param_3) { + extern u8 D_80187F80; + extern u8 D_80187F94[]; + + struct Fr_8016A290 fr; + u8 *p; + s32 i; + register s32 t __asm__("$2"); + register s32 zr __asm__("$0"); + s32 flags; + s32 iVar3; + + iVar3 = *(s32 *)(param_1 + 0x34); + + fr.center.x = (*((s16 *)param_2) + *((s16 *)param_3)) >> 1; + fr.center.y = (((s16 *)param_2)[1] + ((s16 *)param_3)[1]) >> 1; + fr.center.z = (((s16 *)param_2)[2] + ((s16 *)param_3)[2]) >> 1; + ((void(*)(s32, void *, void *))func_80149350)(iVar3, &fr.center, &fr.center); + + *(u16 *)(param_1 + 0x6) = *(u16 *)&fr.center.x; + *(u16 *)(param_1 + 0xA) = *(u16 *)&fr.center.y; + *(u16 *)(param_1 + 0xE) = *(u16 *)&fr.center.z; + func_800D20C0(&fr.center, &fr.diff, 8); + func_80017E68(&fr.center, fr.mtx); + + fr.diff.x = *(u16 *)((s16 *)param_3) - *(u16 *)((s16 *)param_2); + fr.diff.y = *(u16 *)(((s16 *)param_3) + 1) - *(u16 *)(((s16 *)param_2) + 1); + fr.diff.z = *(u16 *)(((s16 *)param_3) + 2) - *(u16 *)(((s16 *)param_2) + 2); + ((void(*)(s32, void *, void *))ApplyMatrixSV)(*(s32 *)(iVar3 + 0x20) + 0x34, &fr.diff, &fr.diff); + func_800D23D0(&fr.diff); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.pos[0] = D_801269A4 - fr.center.x; + fr.pos[1] = D_801269A8 - fr.center.y; + fr.pos[2] = D_801269AC - fr.center.z; + ApplyTransposeMatrixLV(fr.mtx, fr.pos, fr.pos); + fr.diff.z = -ratan2(fr.pos[0], fr.pos[1]); + RotMatrixYXZ(&fr.diff, fr.mtx); + + fr.v[3].z = 0; + fr.v[2].z = 0; + fr.v[0].z = 0; + fr.v[1].z = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + flags = D_800B99DA; + if (flags & 1) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x20; + } else if (flags & 2) { + fr.col[1].r = *(s32 *)(param_1 + 0x30) + 0x40; + } else { + fr.col[1].r = *(s32 *)(param_1 + 0x30); + } + + p = ((u8 *)&D_80187F80); + fr.col[0].b = 0; + fr.col[0].g = 0; + fr.col[0].r = 0; + fr.col[2].b = 0; + fr.col[2].g = 0; + fr.col[2].r = 0; + fr.col[3].b = 0; + fr.col[3].g = 0; + fr.col[3].r = 0; + fr.code = 0x50000000; + fr.col[1].b = fr.col[1].r >> 3; + fr.col[1].g = fr.col[1].r >> 3; + i = 0; +L1: + fr.v[0].x = (s8)*p++; + fr.v[0].y = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].y = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].y = (s8)*p--; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L1; + + fr.v[3].y = 0; + fr.v[2].y = 0; + fr.v[0].y = 0; + fr.v[1].y = 0; + fr.v[1].x = 0; + fr.v[1].z = -0x20; + p = D_80187F94; + i = 0; +L2: + fr.v[0].x = (s8)*p++; + fr.v[0].z = (s8)*p++; + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p--; + func_80017758(fr.v, fr.mtx); + if ((s16)i == 1) { + fr.v[1].z = 0x20; + p += 2; + } + t = i + 1; + i = t + zr; + if ((s16)t < 4) goto L2; + + p += 2; + fr.v[0].x = 0; + fr.v[0].z = -0x20; + fr.col[0].r = fr.col[1].r; + fr.col[0].b = fr.col[1].g; + fr.col[0].g = fr.col[1].g; + i = 0; +L3: + fr.v[2].x = (s8)*p++; + fr.v[2].z = (s8)*p++; + fr.v[3].x = (s8)*p++; + fr.v[3].z = (s8)*p++; + func_80017758(fr.v, fr.mtx); + t = i + 1; + i = t + zr; + if ((s16)t < 2) goto L3; +} + + + + +extern void (*D_80187FBC[])(void); + +void func_8016A700(void *a0) { + D_80187FBC[*(u16 *)((s32)a0 + 0x2)](); +} + + +// Seed for func_8016A73C (ov_SC01_077 exemplar). Overlay-local struct guessed. +typedef struct SubB_8016A73C { char pad[0x20]; int unk20; } SubB_8016A73C; +typedef struct SubA_8016A73C { char pad[0x34]; SubB_8016A73C *unk34; } SubA_8016A73C; + +typedef struct Mat_8016A73C { int w[8]; } Mat_8016A73C; + +typedef struct Obj_8016A73C { + short unk0; + short unk2; + short unk4; + short unk6; + short unk8; + short unkA; + short unkC; + short unkE; + char pad10[0x24]; /* 0x10 .. 0x33 */ + SubA_8016A73C *unk34; /* 0x34 */ + Mat_8016A73C mat; /* 0x38 .. 0x57 */ +} Obj_8016A73C; + + + +s32 func_8016A73C(s32 arg0) { + int sp10[8]; + short v[3]; /* sp30, sp32, sp34 */ + int r; + short tmp; + + r = ((int(*)())rand)(); + v[1] = ((r & 0x7F) << 4) + 0x400; + v[0] = ((unsigned)(r & 0x7F00) >> 5) - 0x300; + v[2] = 0; + ((void(*)(short *, void *))RotMatrixYXZ)(v, sp10); + ((void(*)(int, void *))func_80048EAC)(((Obj_8016A73C *)arg0)->unk34->unk34->unk20 + 0x34, sp10); + v[0] = 0; + v[1] = 0; + v[2] = -0x50; + ((int(*)(void *, short *, short *))ApplyMatrixSV)(sp10, v, v); + + ((Obj_8016A73C *)arg0)->mat = (*(Mat_8016A73C*)&D_800AE620); + + tmp = ((Obj_8016A73C *)arg0)->unk6 + v[0]; + ((Obj_8016A73C *)arg0)->unk6 = tmp; + ((Obj_8016A73C *)arg0)->mat.w[5] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkA + v[1]; + ((Obj_8016A73C *)arg0)->unkA = tmp; + ((Obj_8016A73C *)arg0)->mat.w[6] = tmp; + tmp = ((Obj_8016A73C *)arg0)->unkE + v[2]; + ((Obj_8016A73C *)arg0)->unkE = tmp; + ((Obj_8016A73C *)arg0)->unk2 = ((Obj_8016A73C *)arg0)->unk2 + 1; + ((Obj_8016A73C *)arg0)->mat.w[7] = tmp; +} + + + +DEFINE_func_8016A890() /* dedup: shared engine-core @0x8016A890 (src/shared) */ + + +// @class: struct +// @stuck: none — expect MATCH (single-call leaf, stack-struct prim build + averaging writeback) + +DEFINE_func_8016A8FC() /* dedup: shared engine-core @0x8016A8FC (src/shared) */ + + +DEFINE_func_8016AA50() /* dedup: shared engine-core @0x8016AA50 (src/shared) */ + + +extern void (*D_80188004[])(void); + +void func_8016AB30(void *a0) { + D_80188004[*(u16 *)((s32)a0 + 0x2)](); +} +